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 15 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 lighthouse-cli/test/cli/__snapshots__/index-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1494,9 +1494,11 @@ Object {
"settings": Object {
"additionalTraceCategories": null,
"auditMode": false,
"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 @@ -1506,11 +1508,14 @@ Object {
"locale": "en-US",
"maxWaitForFcp": 30000,
"maxWaitForLoad": 45000,
"networkQuietThresholdMs": 1000,
"onlyAudits": null,
"onlyCategories": null,
"output": Array [
"html",
],
"pauseAfterFcpMs": 1000,
"pauseAfterLoadMs": 1000,
"precomputedLanternData": null,
"screenEmulation": Object {
"deviceScaleFactor": 2.625,
Expand Down Expand Up @@ -1657,9 +1662,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 @@ -1669,13 +1676,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
15 changes: 0 additions & 15 deletions lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,6 @@ async function runLighthouse(url, configJson, testRunnerOptions = {}) {
.finally(() => !isDebug && fs.rm(tmpPath, {recursive: true, force: true}));
}

/**
* @param {LH.Config.Json=} configJson
* @return {LH.Config.Json|undefined}
*/
function convertToFraggleRockConfig(configJson) {
if (!configJson) return configJson;
if (!configJson.passes) return configJson;

return {
...configJson,
navigations: configJson.passes.map(pass => ({...pass, id: pass.passName})),
};
}

/**
* Internal runner.
* @param {string} url
Expand Down Expand Up @@ -83,7 +69,6 @@ async function internalRun(url, tmpPath, configJson, options) {

if (useFraggleRock) {
args.push('--fraggle-rock');
configJson = convertToFraggleRockConfig(configJson);
}

// Config can be optionally provided.
Expand Down
23 changes: 22 additions & 1 deletion lighthouse-cli/test/smokehouse/smokehouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,38 @@ function purpleify(str) {
return `${log.purple}${str}${log.reset}`;
}

/**
* @param {LH.Config.Json=} configJson
* @return {LH.Config.Json|undefined}
*/
function convertToFraggleRockConfig(configJson) {
if (!configJson) return configJson;
if (!configJson.passes) return configJson;

const settings = {...configJson.settings, ...configJson.passes[0]};

return {
...configJson,
settings,
};
}

/**
* Run Lighthouse in the selected runner.
* @param {Smokehouse.TestDfn} smokeTestDefn
* @param {{isDebug?: boolean, useFraggleRock?: boolean, retries: number, lighthouseRunner: Smokehouse.LighthouseRunner, takeNetworkRequestUrls?: () => string[]}} testOptions
* @return {Promise<SmokehouseResult>}
*/
async function runSmokeTest(smokeTestDefn, testOptions) {
const {id, config: configJson, expectations} = smokeTestDefn;
const {id, expectations} = smokeTestDefn;
const {lighthouseRunner, retries, isDebug, useFraggleRock, takeNetworkRequestUrls} = testOptions;
const requestedUrl = expectations.lhr.requestedUrl;

let configJson = smokeTestDefn.config;
if (useFraggleRock) {
configJson = convertToFraggleRockConfig(configJson);
}

console.log(`${purpleify(id)} smoketest starting…`);

// Rerun test until there's a passing result or retries are exhausted to prevent flakes.
Expand Down
8 changes: 8 additions & 0 deletions lighthouse-core/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ const defaultSettings = {
onlyAudits: null,
onlyCategories: null,
skipAudits: null,

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

/** @type {LH.Config.Pass} */
Expand Down
44 changes: 17 additions & 27 deletions lighthouse-core/fraggle-rock/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,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 @@ -79,11 +79,6 @@ function resolveExtensions(configJSON) {
artifacts,
artifact => artifact.id
);
mergedConfig.navigations = mergeConfigFragmentArrayByKey(
defaultClone.navigations,
navigations,
navigation => navigation.id
);

return mergedConfig;
}
Expand Down Expand Up @@ -204,39 +199,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;
function resolveFakeNavigations(artifactDefns, settings) {
if (!artifactDefns) throw new Error('Cannot use navigations without defining artifacts');

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 @@ -257,7 +246,8 @@ function initializeConfig(configJSON, context) {
overrideSettingsForGatherMode(settings, context);

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

const navigations = resolveFakeNavigations(artifacts, settings);

/** @type {LH.Config.FRConfig} */
let config = {
Expand Down
58 changes: 2 additions & 56 deletions lighthouse-core/fraggle-rock/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ const defaultConfig = {
{id: artifacts.EmbeddedContent, gatherer: 'seo/embedded-content'},
{id: artifacts.FontSize, gatherer: 'seo/font-size'},
{id: artifacts.Inputs, gatherer: 'inputs'},
{id: artifacts.FullPageScreenshot, gatherer: 'full-page-screenshot'},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a minor bug fix for timespan/snapshot because they weren't doing FPS as the final gatherer before.

{id: artifacts.GlobalListeners, gatherer: 'global-listeners'},
{id: artifacts.IFrameElements, gatherer: 'iframe-elements'},
{id: artifacts.ImageElements, gatherer: 'image-elements'},
Expand Down Expand Up @@ -128,62 +127,9 @@ const defaultConfig = {
// Artifact copies are renamed for compatibility with legacy artifacts.
{id: artifacts.devtoolsLogs, gatherer: 'devtools-log-compat'},
{id: artifacts.traces, gatherer: 'trace-compat'},
],
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,
],
},
// FullPageScreenshot comes at the very end so all other node analysis is captured.
{id: artifacts.FullPageScreenshot, gatherer: 'full-page-screenshot'},
],
settings: legacyDefaultConfig.settings,
audits: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@
"onlyCategories": null,
"skipAudits": [
"uses-http2"
]
],
"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 @@ -313359,7 +313364,12 @@
"onlyCategories": null,
"skipAudits": [
"uses-http2"
]
],
"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 @@ -672706,7 +672716,12 @@
"onlyCategories": null,
"skipAudits": [
"uses-http2"
]
],
"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 @@ -675588,7 +675603,12 @@
"onlyCategories": null,
"skipAudits": [
"uses-http2"
]
],
"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
Loading