Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: deprecate passes, remove config navigations from FR #13881

Merged
merged 25 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cli/test/cli/__snapshots__/index-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ Object {
"settings": Object {
"additionalTraceCategories": null,
"auditMode": true,
"blankPage": "about:blank",
"blockedUrlPatterns": null,
"budgets": null,
"channel": "cli",
"cpuQuietThresholdMs": 1000,
"debugNavigation": false,
"disableStorageReset": false,
"emulatedUserAgent": "Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4695.0 Mobile Safari/537.36 Chrome-Lighthouse",
Expand All @@ -172,13 +174,16 @@ Object {
"locale": "en-US",
"maxWaitForFcp": 30000,
"maxWaitForLoad": 45000,
"networkQuietThresholdMs": 1000,
"onlyAudits": Array [
"metrics",
],
"onlyCategories": null,
"output": Array [
"json",
],
"pauseAfterFcpMs": 1000,
"pauseAfterLoadMs": 1000,
"precomputedLanternData": null,
"screenEmulation": Object {
"deviceScaleFactor": 2.625,
Expand Down Expand Up @@ -333,9 +338,11 @@ Object {
"settings": Object {
"additionalTraceCategories": null,
"auditMode": true,
"blankPage": "about:blank",
"blockedUrlPatterns": null,
"budgets": null,
"channel": "cli",
"cpuQuietThresholdMs": 1000,
"debugNavigation": false,
"disableStorageReset": false,
"emulatedUserAgent": "Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4695.0 Mobile Safari/537.36 Chrome-Lighthouse",
Expand All @@ -345,13 +352,16 @@ Object {
"locale": "en-US",
"maxWaitForFcp": 30000,
"maxWaitForLoad": 45000,
"networkQuietThresholdMs": 1000,
"onlyAudits": Array [
"charset",
],
"onlyCategories": null,
"output": Array [
"json",
],
"pauseAfterFcpMs": 1000,
"pauseAfterLoadMs": 1000,
"precomputedLanternData": null,
"screenEmulation": Object {
"deviceScaleFactor": 2.625,
Expand Down
10 changes: 8 additions & 2 deletions cli/test/smokehouse/smokehouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,17 @@ function purpleify(str) {
*/
function convertToLegacyConfig(configJson) {
if (!configJson) return configJson;
if (!configJson.navigations) return configJson;

return {
...configJson,
passes: configJson.navigations.map(nav => ({...nav, passName: nav.id.concat('Pass')})),
passes: [{
passName: 'defaultPass',
pauseAfterFcpMs: configJson.settings?.pauseAfterFcpMs,
pauseAfterLoadMs: configJson.settings?.pauseAfterLoadMs,
networkQuietThresholdMs: configJson.settings?.networkQuietThresholdMs,
cpuQuietThresholdMs: configJson.settings?.cpuQuietThresholdMs,
blankPage: configJson.settings?.blankPage,
}],
};
}

Expand Down
5 changes: 1 addition & 4 deletions cli/test/smokehouse/test-definitions/oopif-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ const config = {
// Be a little more forgiving on how long it takes all network requests of several nested iframes
// to complete.
maxWaitForLoad: 180000,
},
navigations: [{
id: 'default',
// CI machines are pretty weak which lead to many more long tasks than normal.
// Reduce our requirement for CPU quiet.
cpuQuietThresholdMs: 500,
}],
},
};

/**
Expand Down
9 changes: 2 additions & 7 deletions cli/test/smokehouse/test-definitions/oopif-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,10 @@ const config = {
// Be a little more forgiving on how long it takes all network requests of several nested iframes
// to complete.
maxWaitForLoad: 180000,
},
navigations: [
// CI machines are pretty weak which lead to many more long tasks than normal.
// Reduce our requirement for CPU quiet.
{
id: 'default',
cpuQuietThresholdMs: 500,
},
],
cpuQuietThresholdMs: 500,
},
};

/**
Expand Down
8 changes: 8 additions & 0 deletions core/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ const defaultSettings = {
onlyCategories: null,
skipAudits: null,
skipAboutBlank: false,

// The following settings are from SharedPassNavigationJson
// They are historically defined on a legacy pass but have been moved here as part of FR.
adamraine marked this conversation as resolved.
Show resolved Hide resolved
pauseAfterFcpMs: 1000,
pauseAfterLoadMs: 1000,
networkQuietThresholdMs: 1000,
cpuQuietThresholdMs: 1000,
blankPage: 'about:blank',
};

/** @type {LH.Config.Pass} */
Expand Down
56 changes: 0 additions & 56 deletions core/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,62 +221,6 @@ const defaultConfig = {
// FullPageScreenshot comes at the very end so all other node analysis is captured.
{id: artifacts.FullPageScreenshot, gatherer: 'full-page-screenshot'},
],
navigations: [
{
id: 'default',
pauseAfterFcpMs: 1000,
pauseAfterLoadMs: 1000,
networkQuietThresholdMs: 1000,
cpuQuietThresholdMs: 1000,
artifacts: [
// Artifacts which can be depended on come first.
artifacts.DevtoolsLog,
artifacts.Trace,

artifacts.Accessibility,
artifacts.AnchorElements,
artifacts.CacheContents,
artifacts.ConsoleMessages,
artifacts.CSSUsage,
artifacts.Doctype,
artifacts.DOMStats,
artifacts.EmbeddedContent,
artifacts.FontSize,
artifacts.Inputs,
artifacts.GlobalListeners,
artifacts.IFrameElements,
artifacts.ImageElements,
artifacts.InstallabilityErrors,
artifacts.InspectorIssues,
artifacts.JsUsage,
artifacts.LinkElements,
artifacts.MainDocumentContent,
artifacts.MetaElements,
artifacts.NetworkUserAgent,
artifacts.OptimizedImages,
artifacts.PasswordInputsWithPreventedPaste,
artifacts.ResponseCompression,
artifacts.RobotsTxt,
artifacts.ServiceWorker,
artifacts.ScriptElements,
artifacts.Scripts,
artifacts.SourceMaps,
artifacts.Stacks,
artifacts.TagsBlockingFirstPaint,
artifacts.TapTargets,
artifacts.TraceElements,
artifacts.ViewportDimensions,
artifacts.WebAppManifest,

// Compat artifacts come last.
artifacts.devtoolsLogs,
artifacts.traces,

// FullPageScreenshot comes at the very end so all other node analysis is captured.
artifacts.FullPageScreenshot,
],
},
],
audits: [
'is-on-https',
'service-worker',
Expand Down
1 change: 0 additions & 1 deletion core/config/legacy-default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ if (!legacyDefaultConfig.categories) {

// These properties are ignored in Legacy navigations.
delete legacyDefaultConfig.artifacts;
delete legacyDefaultConfig.navigations;

// These audits don't work in Legacy navigation mode so we remove them.
const unsupportedAuditIds = [
Expand Down
46 changes: 18 additions & 28 deletions core/fraggle-rock/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function resolveExtensions(configJSON) {
throw new Error('`lighthouse:default` is the only valid extension method.');
}

const {artifacts, navigations, ...extensionJSON} = configJSON;
const {artifacts, ...extensionJSON} = configJSON;
const defaultClone = deepCloneConfigJson(defaultConfig);
const mergedConfig = mergeConfigFragment(defaultClone, extensionJSON);

Expand All @@ -87,11 +87,6 @@ function resolveExtensions(configJSON) {
artifacts,
artifact => artifact.id
);
mergedConfig.navigations = mergeConfigFragmentArrayByKey(
defaultClone.navigations,
navigations,
navigation => navigation.id
);

return mergedConfig;
}
Expand Down Expand Up @@ -213,39 +208,33 @@ function overrideNavigationThrottlingWindows(navigation, settings) {
}

/**
*
* @param {LH.Config.NavigationJson[]|null|undefined} navigations
* @param {LH.Config.AnyArtifactDefn[]|null|undefined} artifactDefns
* @param {LH.Config.Settings} settings
* @return {LH.Config.NavigationDefn[] | null}
*/
function resolveNavigationsToDefns(navigations, artifactDefns, settings) {
if (!navigations) return null;
if (!artifactDefns) throw new Error('Cannot use navigations without defining artifacts');
function resolveFakeNavigations(artifactDefns, settings) {
if (!artifactDefns) return null;

const status = {msg: 'Resolve navigation definitions', id: 'lh:config:resolveNavigationsToDefns'};
log.time(status, 'verbose');

const artifactsById = new Map(artifactDefns.map(defn => [defn.id, defn]));

const navigationDefns = navigations.map(navigation => {
const navigationWithDefaults = {...defaultNavigationConfig, ...navigation};
const navId = navigationWithDefaults.id;
const artifacts = navigationWithDefaults.artifacts.map(id => {
const artifact = artifactsById.get(id);
if (!artifact) throw new Error(`Unrecognized artifact "${id}" in navigation "${navId}"`);
return artifact;
});
const resolvedNavigation = {
...defaultNavigationConfig,
artifacts: artifactDefns,
pauseAfterFcpMs: settings.pauseAfterFcpMs,
pauseAfterLoadMs: settings.pauseAfterLoadMs,
networkQuietThresholdMs: settings.networkQuietThresholdMs,
cpuQuietThresholdMs: settings.cpuQuietThresholdMs,
blankPage: settings.blankPage,
};

const resolvedNavigation = {...navigationWithDefaults, artifacts};
overrideNavigationThrottlingWindows(resolvedNavigation, settings);
return resolvedNavigation;
});
overrideNavigationThrottlingWindows(resolvedNavigation, settings);

assertArtifactTopologicalOrder(navigationDefns);
const navigations = [resolvedNavigation];
assertArtifactTopologicalOrder(navigations);

log.timeEnd(status);
return navigationDefns;
return navigations;
}

/**
Expand All @@ -267,7 +256,8 @@ async function initializeConfig(gatherMode, configJSON, flags = {}) {
overrideSettingsForGatherMode(settings, gatherMode);

const artifacts = await resolveArtifactsToDefns(configWorkingCopy.artifacts, configDir);
const navigations = resolveNavigationsToDefns(configWorkingCopy.navigations, artifacts, settings);

const navigations = resolveFakeNavigations(artifacts, settings);

/** @type {LH.Config.FRConfig} */
let config = {
Expand Down
6 changes: 6 additions & 0 deletions core/scripts/update-flow-fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ async function rebaselineArtifacts(artifactKeys) {
for (let i = 0; i < flowArtifacts.gatherSteps.length; ++i) {
const gatherStep = flowArtifacts.gatherSteps[i];
const newGatherStep = newFlowArtifacts.gatherSteps[i];

// Always update these three values
gatherStep.config = newGatherStep.config;
gatherStep.flags = newGatherStep.flags;
gatherStep.name = newGatherStep.name;

for (const key of artifactKeys) {
// @ts-expect-error
gatherStep.artifacts[key] = newGatherStep.artifacts[key];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,12 @@
"skipAudits": [
"uses-http2"
],
"skipAboutBlank": true
"skipAboutBlank": true,
"pauseAfterFcpMs": 1000,
"pauseAfterLoadMs": 1000,
"networkQuietThresholdMs": 1000,
"cpuQuietThresholdMs": 1000,
"blankPage": "about:blank"
},
"BenchmarkIndex": 2094,
"HostUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4945.0 Safari/537.36",
Expand Down Expand Up @@ -313240,6 +313245,10 @@
]
}
},
"configContext": {
"skipAboutBlank": true,
"settingsOverrides": {}
},
"flags": {
"skipAboutBlank": true
}
Expand Down Expand Up @@ -313360,7 +313369,12 @@
"skipAudits": [
"uses-http2"
],
"skipAboutBlank": false
"skipAboutBlank": false,
"pauseAfterFcpMs": 1000,
"pauseAfterLoadMs": 1000,
"networkQuietThresholdMs": 1000,
"cpuQuietThresholdMs": 1000,
"blankPage": "about:blank"
},
"BenchmarkIndex": 2096.5,
"HostUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4945.0 Safari/537.36",
Expand Down Expand Up @@ -672708,7 +672722,12 @@
"skipAudits": [
"uses-http2"
],
"skipAboutBlank": false
"skipAboutBlank": false,
"pauseAfterFcpMs": 1000,
"pauseAfterLoadMs": 1000,
"networkQuietThresholdMs": 1000,
"cpuQuietThresholdMs": 1000,
"blankPage": "about:blank"
},
"BenchmarkIndex": 2206.5,
"HostUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4945.0 Safari/537.36",
Expand Down Expand Up @@ -675591,7 +675610,12 @@
"skipAudits": [
"uses-http2"
],
"skipAboutBlank": true
"skipAboutBlank": true,
"pauseAfterFcpMs": 1000,
"pauseAfterLoadMs": 1000,
"networkQuietThresholdMs": 1000,
"cpuQuietThresholdMs": 1000,
"blankPage": "about:blank"
},
"BenchmarkIndex": 2210.5,
"HostUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4945.0 Safari/537.36",
Expand Down Expand Up @@ -890328,6 +890352,12 @@
]
}
},
"configContext": {
"skipAboutBlank": true,
"settingsOverrides": {
"disableStorageReset": true
}
},
"flags": {
"skipAboutBlank": true,
"disableStorageReset": true
Expand Down
Loading