Skip to content

Commit

Permalink
Merge branch 'main' into warn-worker-target
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine committed Jan 12, 2024
2 parents d69dc34 + f8a16b7 commit 2fd09e1
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
basics:
runs-on: ubuntu-latest
env:
CHROME_PATH: ${{ github.workspace }}/.tmp/chrome-tot/chrome
FORCE_COLOR: true

# A few steps are duplicated across all jobs. Can be done better when this feature lands:
Expand All @@ -25,7 +26,6 @@ jobs:
fetch-depth: 100
- run: bash core/scripts/github-actions-commit-range.sh
env:
CHROME_PATH: ${{ github.workspace }}/lighthouse/.tmp/chrome-tot/chrome
GITHUB_CONTEXT_PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_CONTEXT_BASE_SHA: ${{ github.event.before }}

Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
fail-fast: false
runs-on: ubuntu-latest
env:
CHROME_PATH: ${{ github.workspace }}/.tmp/chrome-tot/chrome
# The total number of shards. Set dynamically when length of *single* matrix variable is
# computable. See https://git.luolix.topmunity/t/get-length-of-strategy-matrix-or-get-all-matrix-options/18342
SHARD_TOTAL: 3
Expand All @@ -40,10 +41,6 @@ jobs:
with:
node-version: 18.x

- name: Define ToT chrome path
if: matrix.chrome-channel == 'ToT'
run: echo "CHROME_PATH=${{ github.workspace }}/lighthouse/.tmp/chrome-tot/chrome" >> $GITHUB_ENV

# Chrome Stable is already installed by default.
- name: Install Chrome ToT
if: matrix.chrome-channel == 'ToT'
Expand Down Expand Up @@ -95,7 +92,7 @@ jobs:
node-version: 18.x

- name: Define ToT chrome path
run: echo "CHROME_PATH=${env:GITHUB_WORKSPACE}\chrome-win\chrome.exe" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
run: echo "CHROME_PATH=${env:GITHUB_WORKSPACE}\.tmp\chrome-tot\chrome.exe" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append

# Chrome Stable is already installed by default.
- name: Install Chrome ToT
Expand Down Expand Up @@ -126,7 +123,7 @@ jobs:
fail-fast: false
runs-on: ubuntu-latest
env:
CHROME_PATH: ${{ github.workspace }}/lighthouse/.tmp/chrome-tot/chrome
CHROME_PATH: ${{ github.workspace }}/.tmp/chrome-tot/chrome
# The total number of shards. Set dynamically when length of *single* matrix variable is
# computable. See https://git.luolix.topmunity/t/get-length-of-strategy-matrix-or-get-all-matrix-options/18342
SHARD_TOTAL: 3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
name: node ${{ matrix.node }}
env:
CHROME_PATH: ${{ github.workspace }}/lighthouse/.tmp/chrome-tot/chrome
CHROME_PATH: ${{ github.workspace }}/.tmp/chrome-tot/chrome
LATEST_NODE: '18'
FORCE_COLOR: true

Expand Down
15 changes: 13 additions & 2 deletions core/audits/byte-efficiency/legacy-javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ class LegacyJavascript extends ByteEfficiencyAudit {
// Object.defineProperty(String.prototype, 'startsWith'
expression += `|defineProperty\\(${object || 'window'},\\s?${qt(property)}`;

// es-shims
// no(Object,{entries:r},{entries:function
if (object) {
expression += `|\\(${object},\\s*{${property}:.*},\\s*{${property}`;
}

// core-js
if (object) {
const objectWithoutPrototype = object.replace('.prototype', '');
Expand Down Expand Up @@ -234,6 +240,9 @@ class LegacyJavascript extends ByteEfficiencyAudit {
];

for (const [name, coreJs2Module] of coreJsPolyfills) {
// es-shims follows a pattern for its packages.
// Tack it onto the corejs size estimation, as it is likely close in size.
const esShimModule = name.toLowerCase();
data.push({
name,
modules: [
Expand All @@ -243,6 +252,7 @@ class LegacyJavascript extends ByteEfficiencyAudit {
.replace('es6.', 'es.')
.replace('es7.', 'es.')
.replace('typed.', 'typed-array.'),
esShimModule,
],
corejs: true,
});
Expand Down Expand Up @@ -333,8 +343,9 @@ class LegacyJavascript extends ByteEfficiencyAudit {
// Skip if the pattern matching found a match for this polyfill.
if (matches.some(m => m.name === name)) continue;

const source = bundle.rawMap.sources.find(source =>
modules.some(module => source.endsWith(`${module}.js`)));
const source = bundle.rawMap.sources.find(source => modules.some(module => {
return source.endsWith(`/${module}.js`) || source.includes(`node_modules/${module}/`);
}));
if (!source) continue;

const mapping = bundle.map.mappings().find(m => m.sourceURL === source);
Expand Down
2 changes: 1 addition & 1 deletion core/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ const defaultConfig = {
{id: 'third-party-facades', weight: 0},
{id: 'largest-contentful-paint-element', weight: 0},
{id: 'lcp-lazy-loaded', weight: 0},
{id: 'layout-shift-elements', weight: 0},
{id: 'layout-shifts', weight: 0},
{id: 'uses-passive-event-listeners', weight: 0},
{id: 'no-document-write', weight: 0},
Expand All @@ -505,6 +504,7 @@ const defaultConfig = {
{id: 'final-screenshot', weight: 0, group: 'hidden'},
{id: 'script-treemap-data', weight: 0, group: 'hidden'},
{id: 'resource-summary', weight: 0, group: 'hidden'},
{id: 'layout-shift-elements', weight: 0, group: 'hidden'},
],
},
'accessibility': {
Expand Down
17 changes: 17 additions & 0 deletions core/scripts/download-chrome.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,21 @@ curl "$url" -Lo chrome.zip && unzip -q chrome.zip && rm chrome.zip
mv * "$chrome_out"
cd - && rm -rf .tmp-download

echo "OUTPUT DIR: $chrome_out"
ls "$chrome_out"

echo "";
echo "Verifying CHROME_PATH...";

if ! [ -f $CHROME_PATH ]; then
echo "CHROME_PATH does not point to a valid file"
exit 1
else
echo "CHROME_PATH is good!"
fi

# TODO: Find a convenient way to check the version in windows
if [ "$machine" != "MinGw" ]; then
echo "CHROME_PATH version:"
$CHROME_PATH --version
fi
20 changes: 18 additions & 2 deletions core/test/audits/byte-efficiency/legacy-javascript-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ describe('LegacyJavaScript audit', () => {
'Object.defineProperty(String.prototype, "repeat", function() {})',
'$export($export.S,"Object",{values:function values(t){return i(t)}})',
'String.raw = function() {}',
// es-shims (object.entries)
'no(Object,{entries:r},{entries:function',
'no(Array.prototype,{find:r},{find:function',
// Currently are no polyfills that declare a class. Maybe in the future.
// 'Object.defineProperty(window, \'WeakMap\', function() {})',
// 'WeakMap = function() {}',
Expand Down Expand Up @@ -255,7 +258,11 @@ describe('LegacyJavaScript audit', () => {

it('detects non-corejs modules from source maps', async () => {
const map = {
sources: ['node_modules/focus-visible/dist/focus-visible.js'],
sources: [
'node_modules/focus-visible/dist/focus-visible.js',
'node_modules/array.prototype.find/index.js',
'node_modules/object.entries/index.js',
],
mappings: 'blah',
};
const script = {
Expand All @@ -266,13 +273,22 @@ describe('LegacyJavaScript audit', () => {
const result = await getResult([script]);

expect(result.items).toHaveLength(1);
expect(result.items[0].subItems.items).toHaveLength(3);
expect(result.items[0].subItems.items).toMatchObject([
{
signal: 'focus-visible',
location: {line: 0, column: 0},
},
{
signal: 'Array.prototype.find',
location: {line: 0, column: 0},
},
{
signal: 'Object.entries',
location: {line: 0, column: 0},
},
]);
expect(result.items[0].wastedBytes).toBe(3000);
expect(result.items[0].wastedBytes).toBe(38062);
});
});

Expand Down
31 changes: 19 additions & 12 deletions core/test/fixtures/user-flows/reports/sample-flow-result.json
Original file line number Diff line number Diff line change
Expand Up @@ -4072,10 +4072,6 @@
"id": "lcp-lazy-loaded",
"weight": 0
},
{
"id": "layout-shift-elements",
"weight": 0
},
{
"id": "layout-shifts",
"weight": 0
Expand Down Expand Up @@ -4167,6 +4163,11 @@
"id": "resource-summary",
"weight": 0,
"group": "hidden"
},
{
"id": "layout-shift-elements",
"weight": 0,
"group": "hidden"
}
],
"id": "performance",
Expand Down Expand Up @@ -7117,6 +7118,7 @@
"opportunityResourceColumnLabel": "Opportunity",
"opportunitySavingsColumnLabel": "Estimated Savings",
"passedAuditsGroupTitle": "Passed audits",
"pwaRemovalMessage": "Alongside [Chrome’s updated Installability Criteria](https://developer.chrome.com/blog/update-install-criteria), Lighthouse will be deprecating the PWA category in a future release. Please refer to the [updated PWA documentation](https://developer.chrome.com/docs/devtools/progressive-web-apps/) for future PWA testing.",
"runtimeAnalysisWindow": "Initial page load",
"runtimeAnalysisWindowSnapshot": "Point-in-time snapshot",
"runtimeAnalysisWindowTimespan": "User interactions timespan",
Expand Down Expand Up @@ -11129,10 +11131,6 @@
"id": "third-party-summary",
"weight": 0
},
{
"id": "layout-shift-elements",
"weight": 0
},
{
"id": "layout-shifts",
"weight": 0
Expand Down Expand Up @@ -11204,6 +11202,11 @@
"id": "resource-summary",
"weight": 0,
"group": "hidden"
},
{
"id": "layout-shift-elements",
"weight": 0,
"group": "hidden"
}
],
"id": "performance",
Expand Down Expand Up @@ -12197,6 +12200,7 @@
"opportunityResourceColumnLabel": "Opportunity",
"opportunitySavingsColumnLabel": "Estimated Savings",
"passedAuditsGroupTitle": "Passed audits",
"pwaRemovalMessage": "Alongside [Chrome’s updated Installability Criteria](https://developer.chrome.com/blog/update-install-criteria), Lighthouse will be deprecating the PWA category in a future release. Please refer to the [updated PWA documentation](https://developer.chrome.com/docs/devtools/progressive-web-apps/) for future PWA testing.",
"runtimeAnalysisWindow": "Initial page load",
"runtimeAnalysisWindowSnapshot": "Point-in-time snapshot",
"runtimeAnalysisWindowTimespan": "User interactions timespan",
Expand Down Expand Up @@ -17256,6 +17260,7 @@
"opportunityResourceColumnLabel": "Opportunity",
"opportunitySavingsColumnLabel": "Estimated Savings",
"passedAuditsGroupTitle": "Passed audits",
"pwaRemovalMessage": "Alongside [Chrome’s updated Installability Criteria](https://developer.chrome.com/blog/update-install-criteria), Lighthouse will be deprecating the PWA category in a future release. Please refer to the [updated PWA documentation](https://developer.chrome.com/docs/devtools/progressive-web-apps/) for future PWA testing.",
"runtimeAnalysisWindow": "Initial page load",
"runtimeAnalysisWindowSnapshot": "Point-in-time snapshot",
"runtimeAnalysisWindowTimespan": "User interactions timespan",
Expand Down Expand Up @@ -22189,10 +22194,6 @@
"id": "lcp-lazy-loaded",
"weight": 0
},
{
"id": "layout-shift-elements",
"weight": 0
},
{
"id": "layout-shifts",
"weight": 0
Expand Down Expand Up @@ -22284,6 +22285,11 @@
"id": "resource-summary",
"weight": 0,
"group": "hidden"
},
{
"id": "layout-shift-elements",
"weight": 0,
"group": "hidden"
}
],
"id": "performance",
Expand Down Expand Up @@ -25208,6 +25214,7 @@
"opportunityResourceColumnLabel": "Opportunity",
"opportunitySavingsColumnLabel": "Estimated Savings",
"passedAuditsGroupTitle": "Passed audits",
"pwaRemovalMessage": "Alongside [Chrome’s updated Installability Criteria](https://developer.chrome.com/blog/update-install-criteria), Lighthouse will be deprecating the PWA category in a future release. Please refer to the [updated PWA documentation](https://developer.chrome.com/docs/devtools/progressive-web-apps/) for future PWA testing.",
"runtimeAnalysisWindow": "Initial page load",
"runtimeAnalysisWindowSnapshot": "Point-in-time snapshot",
"runtimeAnalysisWindowTimespan": "User interactions timespan",
Expand Down
10 changes: 6 additions & 4 deletions core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -6236,10 +6236,6 @@
"id": "lcp-lazy-loaded",
"weight": 0
},
{
"id": "layout-shift-elements",
"weight": 0
},
{
"id": "layout-shifts",
"weight": 0
Expand Down Expand Up @@ -6331,6 +6327,11 @@
"id": "resource-summary",
"weight": 0,
"group": "hidden"
},
{
"id": "layout-shift-elements",
"weight": 0,
"group": "hidden"
}
],
"id": "performance",
Expand Down Expand Up @@ -9467,6 +9468,7 @@
"opportunityResourceColumnLabel": "Opportunity",
"opportunitySavingsColumnLabel": "Estimated Savings",
"passedAuditsGroupTitle": "Passed audits",
"pwaRemovalMessage": "Alongside [Chrome’s updated Installability Criteria](https://developer.chrome.com/blog/update-install-criteria), Lighthouse will be deprecating the PWA category in a future release. Please refer to the [updated PWA documentation](https://developer.chrome.com/docs/devtools/progressive-web-apps/) for future PWA testing.",
"runtimeAnalysisWindow": "Initial page load",
"runtimeAnalysisWindowSnapshot": "Point-in-time snapshot",
"runtimeAnalysisWindowTimespan": "User interactions timespan",
Expand Down
3 changes: 3 additions & 0 deletions proto/lighthouse-result.proto
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,9 @@ message I18n {

// Descriptive label that this analysis considers a snapshot of the page at a single point in time
string runtime_analysis_window_snapshot = 66;

// Message for PWA deprecation.
string pwa_removal_message = 67;
}

// The message holding all formatted strings used in the renderer.
Expand Down
6 changes: 6 additions & 0 deletions report/renderer/pwa-category-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export class PwaCategoryRenderer extends CategoryRenderer {
render(category, groupDefinitions = {}) {
const categoryElem = this.dom.createElement('div', 'lh-category');
categoryElem.id = category.id;
// Deprecation warning banner.
const pwaMessageContainer = this.dom.createComponent('warningsToplevel');
const pwaMessageEl = this.dom.find('.lh-warnings__msg', pwaMessageContainer);
pwaMessageEl.append(this.dom.convertMarkdownLinkSnippets(Globals.strings.pwaRemovalMessage));

categoryElem.append(pwaMessageContainer);
categoryElem.append(this.renderCategoryHeader(category, groupDefinitions));

const auditRefs = category.auditRefs;
Expand Down
3 changes: 3 additions & 0 deletions report/renderer/report-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@ const UIStrings = {
openInANewTabTooltip: 'Open in a new tab',
/** Generic category name for all resources that could not be attributed to a 1st or 3rd party entity. */
unattributable: 'Unattributable',

/** Message communicating the removal of the PWA category. */
pwaRemovalMessage: 'Alongside [Chrome’s updated Installability Criteria](https://developer.chrome.com/blog/update-install-criteria), Lighthouse will be deprecating the PWA category in a future release. Please refer to the [updated PWA documentation](https://developer.chrome.com/docs/devtools/progressive-web-apps/) for future PWA testing.',
};

export {
Expand Down
5 changes: 4 additions & 1 deletion report/test/renderer/report-renderer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ describe('ReportRenderer', () => {
const warningResults = Object.assign({}, sampleResults, {runWarnings: []});
const container = renderer._dom.document().body;
const output = renderer.renderReport(warningResults, container);
assert.strictEqual(output.querySelector('.lh-warnings--toplevel'), null);
const warningEls = output.querySelectorAll('.lh-warnings--toplevel');
// PWA deprecation warning.
expect(warningEls).toHaveLength(1);
expect(warningEls[0].textContent).toContain('deprecating the PWA category');
});

it('renders a warning section', () => {
Expand Down
3 changes: 3 additions & 0 deletions shared/localization/locales/en-US.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions shared/localization/locales/en-XL.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2fd09e1

Please sign in to comment.