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

WIP: remove devtoolsLogs and traces compat artifacts #15276

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ A PR adding or changing a gatherer almost always needs to include the following:
yarn update:sample-artifacts ScriptElements
```

This command works for updating `yarn update:sample-artifacts devtoolsLogs` or `traces` as well, but the resulting `sample_v2.json` churn may be extensive and you might be better off editing manually.
This command works for updating `yarn update:sample-artifacts DevtoolsLog` or `Trace` as well, but the resulting `sample_v2.json` churn may be extensive and you might be better off editing manually.

1. Run `yarn update:sample-json` to update the [sample Lighthouse result JSON](core/test/results/sample_v2.json) kept in the repo for testing. This will also pull any strings needed for localization into the correct files.

Expand Down
2 changes: 0 additions & 2 deletions build/build-sample-reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ async function generateErrorLHR() {
GatherContext: {gatherMode: 'navigation'},
Timing: [],
PageLoadError: null,
devtoolsLogs: {},
traces: {},
};

// Save artifacts to disk then run `lighthouse -A` with them.
Expand Down
2 changes: 1 addition & 1 deletion cli/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
const cwd = process.cwd();

if (flags.lanternDataOutputPath) {
const devtoolsLog = runnerResult.artifacts.devtoolsLogs.defaultPass;
const devtoolsLog = runnerResult.artifacts.DevtoolsLog;

Check warning on line 141 in cli/run.js

View check run for this annotation

Codecov / codecov/patch

cli/run.js#L141

Added line #L141 was not covered by tests
await assetSaver.saveLanternNetworkData(devtoolsLog, flags.lanternDataOutputPath);
}

Expand Down
10 changes: 3 additions & 7 deletions cli/test/smokehouse/test-definitions/errors-expired-ssl.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,14 @@ const expectations = {
audits: {
'first-contentful-paint': {
scoreDisplayMode: 'error',
errorMessage: 'Required traces gatherer did not run.',
errorMessage: /NO_NAVSTART/,
},
},
},
artifacts: {
PageLoadError: {code: 'INSECURE_DOCUMENT_REQUEST'},
devtoolsLogs: {
'pageLoadError-default': {...NONEMPTY_ARRAY},
},
traces: {
'pageLoadError-default': {traceEvents: NONEMPTY_ARRAY},
},
DevtoolsLog: {...NONEMPTY_ARRAY},
Trace: {traceEvents: NONEMPTY_ARRAY},
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ const expectations = {
},
},
artifacts: {
devtoolsLogs: {
defaultPass: NONEMPTY_ARRAY,
},
traces: {
defaultPass: {traceEvents: NONEMPTY_ARRAY},
},
DevtoolsLog: {...NONEMPTY_ARRAY},
Trace: {traceEvents: NONEMPTY_ARRAY},
},
};

Expand Down
10 changes: 3 additions & 7 deletions cli/test/smokehouse/test-definitions/errors-infinite-loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,14 @@ const expectations = {
audits: {
'first-contentful-paint': {
scoreDisplayMode: 'error',
errorMessage: 'Required traces gatherer did not run.',
errorMessage: /NO_FCP/,
},
},
},
artifacts: {
PageLoadError: {code: 'PAGE_HUNG'},
devtoolsLogs: {
'pageLoadError-default': {...NONEMPTY_ARRAY},
},
traces: {
'pageLoadError-default': {traceEvents: NONEMPTY_ARRAY},
},
DevtoolsLog: {...NONEMPTY_ARRAY},
Trace: {traceEvents: NONEMPTY_ARRAY},
},
};

Expand Down
4 changes: 2 additions & 2 deletions core/audits/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ class Audit {
* @returns {LH.Artifacts.MetricComputationDataInput}
*/
static makeMetricComputationDataInput(artifacts, context) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const trace = artifacts.Trace;
const devtoolsLog = artifacts.DevtoolsLog;
const gatherContext = artifacts.GatherContext;
return {trace, devtoolsLog, gatherContext, settings: context.settings, URL: artifacts.URL};
}
Expand Down
6 changes: 3 additions & 3 deletions core/audits/bootup-time.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BootupTime extends Audit {
failureTitle: str_(UIStrings.failureTitle),
description: str_(UIStrings.description),
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['traces', 'devtoolsLogs'],
requiredArtifacts: ['Trace', 'DevtoolsLog'],
};
}

Expand All @@ -68,8 +68,8 @@ class BootupTime extends Audit {
*/
static async audit(artifacts, context) {
const settings = context.settings || {};
const trace = artifacts.traces[BootupTime.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[BootupTime.DEFAULT_PASS];
const trace = artifacts.Trace;
const devtoolsLog = artifacts.DevtoolsLog;
const networkRecords = await NetworkRecords.request(devtoolsLog, context);
const tasks = await MainThreadTasks.request(trace, context);
const multiplier = settings.throttlingMethod === 'simulate' ?
Expand Down
2 changes: 1 addition & 1 deletion core/audits/byte-efficiency/byte-efficiency-audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class ByteEfficiencyAudit extends Audit {
*/
static async audit(artifacts, context) {
const gatherContext = artifacts.GatherContext;
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.DevtoolsLog;
const settings = context?.settings || {};
const simulatorOptions = {
devtoolsLog,
Expand Down
2 changes: 1 addition & 1 deletion core/audits/byte-efficiency/duplicated-javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DuplicatedJavascript extends ByteEfficiencyAudit {
title: str_(UIStrings.title),
description: str_(UIStrings.description),
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['devtoolsLogs', 'traces', 'SourceMaps', 'Scripts',
requiredArtifacts: ['DevtoolsLog', 'Trace', 'SourceMaps', 'Scripts',
'GatherContext', 'URL'],
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class EfficientAnimatedContent extends ByteEfficiencyAudit {
title: str_(UIStrings.title),
description: str_(UIStrings.description),
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['devtoolsLogs', 'traces', 'GatherContext', 'URL'],
requiredArtifacts: ['DevtoolsLog', 'Trace', 'GatherContext', 'URL'],
};
}

Expand Down
4 changes: 2 additions & 2 deletions core/audits/byte-efficiency/legacy-javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class LegacyJavascript extends ByteEfficiencyAudit {
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
description: str_(UIStrings.description),
title: str_(UIStrings.title),
requiredArtifacts: ['devtoolsLogs', 'traces', 'Scripts', 'SourceMaps',
requiredArtifacts: ['DevtoolsLog', 'Trace', 'Scripts', 'SourceMaps',
'GatherContext', 'URL'],
};
}
Expand Down Expand Up @@ -427,7 +427,7 @@ class LegacyJavascript extends ByteEfficiencyAudit {
* @return {Promise<ByteEfficiencyProduct>}
*/
static async audit_(artifacts, networkRecords, context) {
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.DevtoolsLog;
const classifiedEntities = await EntityClassification.request(
{URL: artifacts.URL, devtoolsLog}, context);

Expand Down
2 changes: 1 addition & 1 deletion core/audits/byte-efficiency/modern-image-formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ModernImageFormats extends ByteEfficiencyAudit {
title: str_(UIStrings.title),
description: str_(UIStrings.description),
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['OptimizedImages', 'devtoolsLogs', 'traces', 'URL', 'GatherContext',
requiredArtifacts: ['OptimizedImages', 'DevtoolsLog', 'Trace', 'URL', 'GatherContext',
'ImageElements'],
};
}
Expand Down
8 changes: 4 additions & 4 deletions core/audits/byte-efficiency/offscreen-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class OffscreenImages extends ByteEfficiencyAudit {
description: str_(UIStrings.description),
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
supportedModes: ['navigation'],
requiredArtifacts: ['ImageElements', 'ViewportDimensions', 'GatherContext', 'devtoolsLogs',
'traces', 'URL'],
requiredArtifacts: ['ImageElements', 'ViewportDimensions', 'GatherContext', 'DevtoolsLog',
'Trace', 'URL'],
};
}

Expand Down Expand Up @@ -180,8 +180,8 @@ class OffscreenImages extends ByteEfficiencyAudit {
const images = artifacts.ImageElements;
const viewportDimensions = artifacts.ViewportDimensions;
const gatherContext = artifacts.GatherContext;
const trace = artifacts.traces[ByteEfficiencyAudit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[ByteEfficiencyAudit.DEFAULT_PASS];
const trace = artifacts.Trace;
const devtoolsLog = artifacts.DevtoolsLog;
const URL = artifacts.URL;

/** @type {string[]} */
Expand Down
8 changes: 4 additions & 4 deletions core/audits/byte-efficiency/render-blocking-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class RenderBlockingResources extends Audit {
description: str_(UIStrings.description),
// TODO: look into adding an `optionalArtifacts` property that captures the non-required nature
// of CSSUsage
requiredArtifacts: ['URL', 'TagsBlockingFirstPaint', 'traces', 'devtoolsLogs', 'CSSUsage',
requiredArtifacts: ['URL', 'TagsBlockingFirstPaint', 'Trace', 'DevtoolsLog', 'CSSUsage',
'GatherContext', 'Stacks'],
};
}
Expand All @@ -129,8 +129,8 @@ class RenderBlockingResources extends Audit {
*/
static async computeResults(artifacts, context) {
const gatherContext = artifacts.GatherContext;
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const trace = artifacts.Trace;
const devtoolsLog = artifacts.DevtoolsLog;
const simulatorData = {devtoolsLog, settings: context.settings};
const processedNavigation = await ProcessedNavigation.request(trace, context);
const simulator = await LoadSimulator.request(simulatorData, context);
Expand Down Expand Up @@ -260,7 +260,7 @@ class RenderBlockingResources extends Audit {
try {
const unusedCssItems = await UnusedCSS.request({
CSSUsage: artifacts.CSSUsage,
devtoolsLog: artifacts.devtoolsLogs[Audit.DEFAULT_PASS],
devtoolsLog: artifacts.DevtoolsLog,
}, context);
for (const item of unusedCssItems) {
wastedBytesByUrl.set(item.url, item.wastedBytes);
Expand Down
4 changes: 2 additions & 2 deletions core/audits/byte-efficiency/total-byte-weight.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TotalByteWeight extends Audit {
failureTitle: str_(UIStrings.failureTitle),
description: str_(UIStrings.description),
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['devtoolsLogs'],
requiredArtifacts: ['DevtoolsLog'],
};
}

Expand All @@ -58,7 +58,7 @@ class TotalByteWeight extends Audit {
* @return {Promise<LH.Audit.Product>}
*/
static async audit(artifacts, context) {
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.DevtoolsLog;
const records = await NetworkRecords.request(devtoolsLog, context);

let totalBytes = 0;
Expand Down
2 changes: 1 addition & 1 deletion core/audits/byte-efficiency/unminified-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class UnminifiedCSS extends ByteEfficiencyAudit {
title: str_(UIStrings.title),
description: str_(UIStrings.description),
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['CSSUsage', 'devtoolsLogs', 'traces', 'URL', 'GatherContext'],
requiredArtifacts: ['CSSUsage', 'DevtoolsLog', 'Trace', 'URL', 'GatherContext'],
};
}

Expand Down
2 changes: 1 addition & 1 deletion core/audits/byte-efficiency/unminified-javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class UnminifiedJavaScript extends ByteEfficiencyAudit {
title: str_(UIStrings.title),
description: str_(UIStrings.description),
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['Scripts', 'devtoolsLogs', 'traces', 'GatherContext', 'URL'],
requiredArtifacts: ['Scripts', 'DevtoolsLog', 'Trace', 'GatherContext', 'URL'],
};
}

Expand Down
4 changes: 2 additions & 2 deletions core/audits/byte-efficiency/unused-css-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class UnusedCSSRules extends ByteEfficiencyAudit {
title: str_(UIStrings.title),
description: str_(UIStrings.description),
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['CSSUsage', 'URL', 'devtoolsLogs', 'traces', 'GatherContext'],
requiredArtifacts: ['CSSUsage', 'URL', 'DevtoolsLog', 'Trace', 'GatherContext'],
};
}

Expand All @@ -46,7 +46,7 @@ class UnusedCSSRules extends ByteEfficiencyAudit {
static async audit_(artifacts, _, context) {
const unusedCssItems = await UnusedCSS.request({
CSSUsage: artifacts.CSSUsage,
devtoolsLog: artifacts.devtoolsLogs[ByteEfficiencyAudit.DEFAULT_PASS],
devtoolsLog: artifacts.DevtoolsLog,
}, context);
const items = unusedCssItems
.filter(sheet => sheet && sheet.wastedBytes > IGNORE_THRESHOLD_IN_BYTES);
Expand Down
2 changes: 1 addition & 1 deletion core/audits/byte-efficiency/unused-javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class UnusedJavaScript extends ByteEfficiencyAudit {
description: str_(UIStrings.description),
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['JsUsage', 'Scripts', 'SourceMaps', 'GatherContext',
'devtoolsLogs', 'traces', 'URL'],
'DevtoolsLog', 'Trace', 'URL'],
};
}

Expand Down
6 changes: 3 additions & 3 deletions core/audits/byte-efficiency/uses-long-cache-ttl.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CacheHeaders extends Audit {
failureTitle: str_(UIStrings.failureTitle),
description: str_(UIStrings.description),
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['devtoolsLogs'],
requiredArtifacts: ['DevtoolsLog'],
};
}

Expand Down Expand Up @@ -195,8 +195,8 @@ class CacheHeaders extends Audit {
* @return {Promise<LH.Audit.Product>}
*/
static async audit(artifacts, context) {
const devtoolsLogs = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const records = await NetworkRecords.request(devtoolsLogs, context);
const devtoolsLog = artifacts.DevtoolsLog;
const records = await NetworkRecords.request(devtoolsLog, context);
const results = [];
let totalWastedBytes = 0;

Expand Down
4 changes: 2 additions & 2 deletions core/audits/byte-efficiency/uses-optimized-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class UsesOptimizedImages extends ByteEfficiencyAudit {
title: str_(UIStrings.title),
description: str_(UIStrings.description),
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['OptimizedImages', 'ImageElements', 'GatherContext', 'devtoolsLogs',
'traces', 'URL'],
requiredArtifacts: ['OptimizedImages', 'ImageElements', 'GatherContext', 'DevtoolsLog',
'Trace', 'URL'],
};
}

Expand Down
2 changes: 1 addition & 1 deletion core/audits/byte-efficiency/uses-responsive-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class UsesResponsiveImages extends ByteEfficiencyAudit {
description: str_(UIStrings.description),
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['ImageElements', 'ViewportDimensions', 'GatherContext',
'devtoolsLogs', 'traces', 'URL'],
'DevtoolsLog', 'Trace', 'URL'],
};
}

Expand Down
2 changes: 1 addition & 1 deletion core/audits/byte-efficiency/uses-text-compression.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ResponsesAreCompressed extends ByteEfficiencyAudit {
title: str_(UIStrings.title),
description: str_(UIStrings.description),
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['ResponseCompression', 'GatherContext', 'devtoolsLogs', 'traces', 'URL'],
requiredArtifacts: ['ResponseCompression', 'GatherContext', 'DevtoolsLog', 'Trace', 'URL'],
};
}

Expand Down
6 changes: 3 additions & 3 deletions core/audits/critical-request-chains.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CriticalRequestChains extends Audit {
description: str_(UIStrings.description),
scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE,
supportedModes: ['navigation'],
requiredArtifacts: ['traces', 'devtoolsLogs', 'URL'],
requiredArtifacts: ['Trace', 'DevtoolsLog', 'URL'],
};
}

Expand Down Expand Up @@ -167,8 +167,8 @@ class CriticalRequestChains extends Audit {
* @return {Promise<LH.Audit.Product>}
*/
static async audit(artifacts, context) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const trace = artifacts.Trace;
const devtoolsLog = artifacts.DevtoolsLog;
const URL = artifacts.URL;
const chains = await ComputedChains.request({devtoolsLog, trace, URL}, context);
let chainCount = 0;
Expand Down
4 changes: 2 additions & 2 deletions core/audits/csp-xss.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CspXss extends Audit {
scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE,
title: str_(UIStrings.title),
description: str_(UIStrings.description),
requiredArtifacts: ['devtoolsLogs', 'MetaElements', 'URL'],
requiredArtifacts: ['DevtoolsLog', 'MetaElements', 'URL'],
};
}

Expand All @@ -54,7 +54,7 @@ class CspXss extends Audit {
* @return {Promise<{cspHeaders: string[], cspMetaTags: string[]}>}
*/
static async getRawCsps(artifacts, context) {
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.DevtoolsLog;
const mainResource = await MainResource.request({devtoolsLog, URL: artifacts.URL}, context);

const cspMetaTags = artifacts.MetaElements
Expand Down
6 changes: 3 additions & 3 deletions core/audits/diagnostics.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Diagnostics extends Audit {
title: 'Diagnostics',
description: 'Collection of useful page vitals.',
supportedModes: ['navigation'],
requiredArtifacts: ['URL', 'traces', 'devtoolsLogs'],
requiredArtifacts: ['URL', 'Trace', 'DevtoolsLog'],
};
}

Expand All @@ -31,8 +31,8 @@ class Diagnostics extends Audit {
* @return {Promise<LH.Audit.Product>}
*/
static async audit(artifacts, context) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const trace = artifacts.Trace;
const devtoolsLog = artifacts.DevtoolsLog;
const tasks = await MainThreadTasks.request(trace, context);
const records = await NetworkRecords.request(devtoolsLog, context);
const analysis = await NetworkAnalysis.request(devtoolsLog, context);
Expand Down
Loading
Loading