Skip to content

Commit

Permalink
Merge branch 'main' into rm-pwa
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianaixba committed Apr 10, 2024
2 parents 0bf17c6 + c01e2ed commit d085d9b
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 46 deletions.
48 changes: 25 additions & 23 deletions cli/test/smokehouse/test-definitions/oopif-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,32 @@ const expectations = {
'network-requests': {
details: {
items: {
// Multiple session attach handling fixed in M105
// https://chromiumdash.appspot.com/commit/f42337f1d623ec913397610ccf01b5526e9e919d
_minChromiumVersion: '105',
_includes: [
{url: 'http://localhost:10200/oopif-scripts.html'},
{url: 'http://localhost:10200/oopif-simple-page.html'},
{url: 'http://localhost:10503/oopif-simple-page.html'},
// simple-script.js is included many times
// 2 * (1 from <script>, 1 from fetch) = 4
// Note, the network records from the workers are _not_ captured! If they
// were, then we would see 8 simple-script.js
{url: 'http://localhost:10200/simple-script.js', resourceType: 'Script'},
{url: 'http://localhost:10503/simple-script.js', resourceType: 'Script'},
{url: 'http://localhost:10200/simple-script.js', resourceType: 'Fetch'},
{url: 'http://localhost:10503/simple-script.js', resourceType: 'Fetch'},
{url: 'http://localhost:10200/simple-worker.js'},
{url: 'http://localhost:10503/simple-worker.js'},
{url: 'http://localhost:10200/simple-worker.mjs'},
{url: 'http://localhost:10503/simple-worker.mjs'},
// Requests from worker targets
{url: 'http://localhost:10200/simple-script.js?esm', resourceType: 'Script'},
{url: 'http://localhost:10503/simple-script.js?esm', resourceType: 'Script'},
{url: 'http://localhost:10200/simple-script.js?importScripts', resourceType: 'Other'},
{url: 'http://localhost:10503/simple-script.js?importScripts', resourceType: 'Other'},
{url: 'http://localhost:10200/oopif-scripts.html', sessionTargetType: 'page'},
{url: 'http://localhost:10200/oopif-simple-page.html', sessionTargetType: 'page'},
{url: 'http://localhost:10503/oopif-simple-page.html', sessionTargetType: 'iframe'},

// From in-process iframe
{url: 'http://localhost:10200/simple-script.js', resourceType: 'Script', sessionTargetType: 'page'},
{url: 'http://localhost:10200/simple-script.js', resourceType: 'Fetch', sessionTargetType: 'page'},
{url: 'http://localhost:10200/simple-worker.js', sessionTargetType: 'page'},
// This target type can vary depending on if Chrome's field trial config is being used
{url: 'http://localhost:10200/simple-worker.mjs', sessionTargetType: /(page|worker)/},
// From in-process iframe -> simple-worker.js
{url: 'http://localhost:10200/simple-script.js?importScripts', resourceType: 'Other', sessionTargetType: 'worker'},
// From in-process iframe -> simple-worker.mjs
{url: 'http://localhost:10200/simple-script.js?esm', resourceType: 'Script', sessionTargetType: 'worker'},

// From OOPIF
{url: 'http://localhost:10503/simple-script.js', resourceType: 'Script', sessionTargetType: 'iframe'},
{url: 'http://localhost:10503/simple-script.js', resourceType: 'Fetch', sessionTargetType: 'iframe'},
{url: 'http://localhost:10503/simple-worker.js', sessionTargetType: 'iframe'},
// This target type can vary depending on if Chrome's field trial config is being used
{url: 'http://localhost:10503/simple-worker.mjs', sessionTargetType: /(iframe|worker)/},
// From OOPIF -> simple-worker.js
{url: 'http://localhost:10503/simple-script.js?importScripts', resourceType: 'Other', sessionTargetType: 'worker'},
// From OOPIF -> simple-worker.mjs
{url: 'http://localhost:10503/simple-script.js?esm', resourceType: 'Script', sessionTargetType: 'worker'},
],
// Ensure the above is exhaustive (except for favicon, which won't be fetched in devtools/LR).
_excludes: [
Expand Down
7 changes: 6 additions & 1 deletion core/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,17 @@ const defaultConfig = {
manualDescription: str_(UIStrings.seoCategoryManualDescription),
supportedModes: ['navigation', 'snapshot'],
auditRefs: [
// Should be at least 31% of the score, such that this audit failing
// results in the SEO category failing.
// Solve for w:
// w / (w + T) >= 0.31
// where T is the sum of all the other weights.
{id: 'is-crawlable', weight: 93 / 23, group: 'seo-crawl'},
{id: 'document-title', weight: 1, group: 'seo-content'},
{id: 'meta-description', weight: 1, group: 'seo-content'},
{id: 'http-status-code', weight: 1, group: 'seo-crawl'},
{id: 'link-text', weight: 1, group: 'seo-content'},
{id: 'crawlable-anchors', weight: 1, group: 'seo-crawl'},
{id: 'is-crawlable', weight: 1, group: 'seo-crawl'},
{id: 'robots-txt', weight: 1, group: 'seo-crawl'},
{id: 'image-alt', weight: 1, group: 'seo-content'},
{id: 'hreflang', weight: 1, group: 'seo-content'},
Expand Down
11 changes: 11 additions & 0 deletions core/test/config/default-config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import assert from 'assert/strict';

import defaultConfig from '../../config/default-config.js';
import {ReportScoring} from '../../scoring.js';

describe('Default Config', () => {
it('relevantAudits map to existing perf audit', () => {
Expand All @@ -23,4 +24,14 @@ describe('Default Config', () => {
}
}
});

it('SEO fails if is-crawlable is failing', () => {
const scores = defaultConfig.categories.seo.auditRefs.map(auditRef => ({
score: auditRef.id === 'is-crawlable' ? 0 : 1,
weight: auditRef.weight,
}));
const score = ReportScoring.arithmeticMean(scores);
assert(score < 0.7);
assert(score >= 0.65);
});
});
22 changes: 11 additions & 11 deletions core/test/fixtures/user-flows/reports/sample-flow-result.json
Original file line number Diff line number Diff line change
Expand Up @@ -4423,6 +4423,11 @@
"snapshot"
],
"auditRefs": [
{
"id": "is-crawlable",
"weight": 4.043478260869565,
"group": "seo-crawl"
},
{
"id": "document-title",
"weight": 1,
Expand All @@ -4448,11 +4453,6 @@
"weight": 1,
"group": "seo-crawl"
},
{
"id": "is-crawlable",
"weight": 1,
"group": "seo-crawl"
},
{
"id": "robots-txt",
"weight": 0,
Expand Down Expand Up @@ -21676,6 +21676,11 @@
"snapshot"
],
"auditRefs": [
{
"id": "is-crawlable",
"weight": 4.043478260869565,
"group": "seo-crawl"
},
{
"id": "document-title",
"weight": 1,
Expand All @@ -21701,11 +21706,6 @@
"weight": 1,
"group": "seo-crawl"
},
{
"id": "is-crawlable",
"weight": 1,
"group": "seo-crawl"
},
{
"id": "robots-txt",
"weight": 0,
Expand All @@ -21732,7 +21732,7 @@
}
],
"id": "seo",
"score": 0.88
"score": 0.91
}
},
"categoryGroups": {
Expand Down
12 changes: 6 additions & 6 deletions core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -6510,6 +6510,11 @@
"snapshot"
],
"auditRefs": [
{
"id": "is-crawlable",
"weight": 4.043478260869565,
"group": "seo-crawl"
},
{
"id": "document-title",
"weight": 1,
Expand All @@ -6535,11 +6540,6 @@
"weight": 1,
"group": "seo-crawl"
},
{
"id": "is-crawlable",
"weight": 1,
"group": "seo-crawl"
},
{
"id": "robots-txt",
"weight": 0,
Expand All @@ -6566,7 +6566,7 @@
}
],
"id": "seo",
"score": 0.63
"score": 0.73
}
},
"categoryGroups": {
Expand Down
12 changes: 8 additions & 4 deletions core/test/scenarios/api-test-pptr.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,8 @@ describe('Individual modes API', function() {
expect(erroredAudits).toHaveLength(0);
});

// TODO: unskip https://github.com/GoogleChrome/lighthouse/issues/15654
// eslint-disable-next-line max-len
it.skip('should know target type of network requests from frames created before timespan', async () => {
it('should know target type of network requests from frames created before timespan', async () => {
const spy = jestMock.spyOn(TargetManager.prototype, '_onExecutionContextCreated');
state.server.baseDir = `${LH_ROOT}/cli/test/fixtures`;
const {page, serverBaseUrl} = state;
Expand All @@ -190,6 +189,11 @@ describe('Individual modes API', function() {
.map((r) => ({url: r.url, sessionTargetType: r.sessionTargetType}))
// @ts-expect-error
.sort((a, b) => a.url.localeCompare(b.url));

// These results will differ slightly from `yarn smoke oopif-scripts`
// The main worker requests will be assigned to the worker instead of the worker's parent
// This is because this test launches Chrome using puppeteer instead of Chrome launcher,
// and Puppeteer uses the flag `--disable-field-trial-config`
expect(networkRequests).toMatchInlineSnapshot(`
Array [
Object {
Expand All @@ -209,7 +213,7 @@ Array [
"url": "http://localhost:10200/simple-worker.js",
},
Object {
"sessionTargetType": "page",
"sessionTargetType": "worker",
"url": "http://localhost:10200/simple-worker.mjs",
},
Object {
Expand All @@ -229,7 +233,7 @@ Array [
"url": "http://localhost:10503/simple-worker.js",
},
Object {
"sessionTargetType": "iframe",
"sessionTargetType": "worker",
"url": "http://localhost:10503/simple-worker.mjs",
},
]
Expand Down
2 changes: 1 addition & 1 deletion report/test/generator/report-generator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ category,score
\\"performance\\",\\"0.28\\"
\\"accessibility\\",\\"0.78\\"
\\"best-practices\\",\\"0.39\\"
\\"seo\\",\\"0.63\\"
\\"seo\\",\\"0.73\\"
category,audit,score,displayValue,description
\\"performance\\",\\"first-contentful-paint\\",\\"0.01\\",\\"6.8 s\\",\\"First Contentful Paint marks the time at which the first text or image is painted. [Learn more about the First Contentful Paint metric](https://developer.chrome.com/docs/lighthouse/performance/first-contentful-paint/).\\"
Expand Down

0 comments on commit d085d9b

Please sign in to comment.