From 45defa8c5feb529513b58f72ab788387104b5265 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Fri, 30 Apr 2021 16:42:31 -0400 Subject: [PATCH 01/17] start --- lighthouse-core/gather/gather-runner.js | 13 ++++- .../gather/gatherers/link-elements.js | 56 ++++++++++++++----- lighthouse-core/index.js | 3 +- lighthouse-core/runner.js | 13 +++-- types/gatherer.d.ts | 6 ++ 5 files changed, 69 insertions(+), 22 deletions(-) diff --git a/lighthouse-core/gather/gather-runner.js b/lighthouse-core/gather/gather-runner.js index d95108ed92c5..11495771c80f 100644 --- a/lighthouse-core/gather/gather-runner.js +++ b/lighthouse-core/gather/gather-runner.js @@ -8,7 +8,7 @@ const log = require('lighthouse-logger'); const LHError = require('../lib/lh-error.js'); const NetworkAnalyzer = require('../lib/dependency-graph/simulator/network-analyzer.js'); -const NetworkRecorder = require('../lib/network-recorder.js'); +const NetworkRecords = require('../computed/network-records.js'); const emulation = require('../lib/emulation.js'); const constants = require('../config/constants.js'); const i18n = require('../lib/i18n/i18n.js'); @@ -54,6 +54,7 @@ const SLOW_CPU_BENCHMARK_INDEX_THRESHOLD = 1000; const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings); /** @typedef {import('../gather/driver.js')} Driver */ +/** @typedef {import('../lib/arbitrary-equality-map.js')} ArbitraryEqualityMap */ /** * Each entry in each gatherer result array is the output of a gatherer phase: @@ -477,7 +478,12 @@ class GatherRunner { }; log.time(status); const devtoolsLog = driver.endDevtoolsLog(); - const networkRecords = NetworkRecorder.recordsFromLogs(devtoolsLog); + const context = { + computedCache: passContext.computedCache, + settings: passContext.settings, + options: {}, + }; + const networkRecords = await NetworkRecords.request(devtoolsLog, context); log.timeEnd(status); return { @@ -707,7 +713,7 @@ class GatherRunner { /** * @param {Array} passConfigs - * @param {{driver: Driver, requestedUrl: string, settings: LH.Config.Settings}} options + * @param {{driver: Driver, requestedUrl: string, settings: LH.Config.Settings, computedCache: Map}} options * @return {Promise} */ static async run(passConfigs, options) { @@ -737,6 +743,7 @@ class GatherRunner { settings: options.settings, passConfig, baseArtifacts, + computedCache: options.computedCache, LighthouseRunWarnings: baseArtifacts.LighthouseRunWarnings, }; const passResults = await GatherRunner.runPass(passContext); diff --git a/lighthouse-core/gather/gatherers/link-elements.js b/lighthouse-core/gather/gatherers/link-elements.js index 90c6fb6c606b..50f4a25ddc1c 100644 --- a/lighthouse-core/gather/gatherers/link-elements.js +++ b/lighthouse-core/gather/gatherers/link-elements.js @@ -6,10 +6,12 @@ 'use strict'; const LinkHeader = require('http-link-header'); -const Gatherer = require('./gatherer.js'); +const FRGatherer = require('../../fraggle-rock/gather/base-gatherer.js'); const {URL} = require('../../lib/url-shim.js'); +const NetworkRecords = require('../../computed/network-records.js'); const NetworkAnalyzer = require('../../lib/dependency-graph/simulator/network-analyzer.js'); const pageFunctions = require('../../lib/page-functions.js'); +const DevtoolsLog = require('./devtools-log.js'); /* globals HTMLLinkElement getNodeDetails */ @@ -79,9 +81,15 @@ function getLinkElementsInDOM() { } /* c8 ignore stop */ -class LinkElements extends Gatherer { +class LinkElements extends FRGatherer { + /** @type {LH.Gatherer.GathererMeta<'DevtoolsLog'>} */ + meta = { + supportedModes: ['timespan', 'navigation'], + dependencies: {DevtoolsLog: DevtoolsLog.symbol}, + } + /** - * @param {LH.Gatherer.PassContext} passContext + * @param {LH.Gatherer.CompatibilityContext} passContext * @return {Promise} */ static getLinkElementsInDOM(passContext) { @@ -98,14 +106,13 @@ class LinkElements extends Gatherer { } /** - * @param {LH.Gatherer.PassContext} passContext - * @param {LH.Gatherer.LoadData} loadData - * @return {LH.Artifacts['LinkElements']} + * @param {LH.Gatherer.CompatibilityContext} passContext + * @param {LH.Artifacts.NetworkRequest[]} networkRecords + * @return {Promise} */ - static getLinkElementsInHeaders(passContext, loadData) { + static async getLinkElementsInHeaders(passContext, networkRecords) { const finalUrl = passContext.url; - const records = loadData.networkRecords; - const mainDocument = NetworkAnalyzer.findMainDocument(records, finalUrl); + const mainDocument = NetworkAnalyzer.findMainDocument(networkRecords, finalUrl); /** @type {LH.Artifacts['LinkElements']} */ const linkElements = []; @@ -131,13 +138,13 @@ class LinkElements extends Gatherer { } /** - * @param {LH.Gatherer.PassContext} passContext - * @param {LH.Gatherer.LoadData} loadData + * @param {LH.Gatherer.CompatibilityContext} passContext + * @param {LH.Artifacts.NetworkRequest[]} networkRecords * @return {Promise} */ - async afterPass(passContext, loadData) { + async _getArtifact(passContext, networkRecords) { const fromDOM = await LinkElements.getLinkElementsInDOM(passContext); - const fromHeaders = LinkElements.getLinkElementsInHeaders(passContext, loadData); + const fromHeaders = await LinkElements.getLinkElementsInHeaders(passContext, networkRecords); const linkElements = fromDOM.concat(fromHeaders); for (const link of linkElements) { @@ -147,6 +154,29 @@ class LinkElements extends Gatherer { return linkElements; } + + /** + * @param {LH.Gatherer.PassContext} passContext + * @param {LH.Gatherer.LoadData} loadData + * @return {Promise} + */ + async afterPass(passContext, loadData) { + return await this._getArtifact(passContext, loadData.networkRecords); + } + + /** + * @param {LH.Gatherer.FRTransitionalContext<'DevtoolsLog'>} passContext + * @return {Promise} + */ + async getArtifact(passContext) { + const context = { + computedCache: passContext.computedCache, + settings: passContext.settings, + options: {}, + }; + const records = await NetworkRecords.request(passContext.dependencies.DevtoolsLog, context); + return await this._getArtifact(passContext, records); + } } module.exports = LinkElements; diff --git a/lighthouse-core/index.js b/lighthouse-core/index.js index 1b27136c8a60..4c0acf298610 100644 --- a/lighthouse-core/index.js +++ b/lighthouse-core/index.js @@ -41,7 +41,8 @@ async function lighthouse(url, flags = {}, configJSON, userConnection) { log.setLevel(flags.logLevel); const config = generateConfig(configJSON, flags); - const options = {url, config}; + const computedCache = new Map(); + const options = {url, config, computedCache}; const connection = userConnection || new ChromeProtocol(flags.port, flags.hostname); // kick off a lighthouse run diff --git a/lighthouse-core/runner.js b/lighthouse-core/runner.js index 1239345d61a2..62f5f00986fc 100644 --- a/lighthouse-core/runner.js +++ b/lighthouse-core/runner.js @@ -22,13 +22,14 @@ const generateReport = require('./report/report-generator.js').generateReport; const LHError = require('./lib/lh-error.js'); /** @typedef {import('./gather/connections/connection.js')} Connection */ +/** @typedef {import('./lib/arbitrary-equality-map.js')} ArbitraryEqualityMap */ /** @typedef {LH.Config.Config} Config */ class Runner { /** * @template {LH.Config.Config | LH.Config.FRConfig} TConfig * @param {(runnerData: {requestedUrl: string, config: TConfig, driverMock?: Driver}) => Promise} gatherFn - * @param {{config: TConfig, url?: string, driverMock?: Driver}} runOpts + * @param {{config: TConfig, computedCache: Map, url?: string, driverMock?: Driver}} runOpts * @return {Promise} */ static async run(gatherFn, runOpts) { @@ -100,7 +101,7 @@ class Runner { throw new Error('No audits to evaluate.'); } const auditResultsById = await Runner._runAudits(settings, runOpts.config.audits, artifacts, - lighthouseRunWarnings); + lighthouseRunWarnings, runOpts.computedCache); // LHR construction phase const resultsStatus = {msg: 'Generating results...', id: 'lh:runner:generate'}; @@ -217,7 +218,7 @@ class Runner { /** * Establish connection, load page and collect all required artifacts * @param {string} requestedUrl - * @param {{config: Config, driverMock?: Driver}} runnerOpts + * @param {{config: Config, computedCache: Map, driverMock?: Driver}} runnerOpts * @param {Connection} connection * @return {Promise} */ @@ -230,6 +231,7 @@ class Runner { driver, requestedUrl, settings: runnerOpts.config.settings, + computedCache: runnerOpts.computedCache, }; const artifacts = await GatherRunner.run(runnerOpts.config.passes, gatherOpts); return artifacts; @@ -241,9 +243,10 @@ class Runner { * @param {Array} audits * @param {LH.Artifacts} artifacts * @param {Array} runWarnings + * @param {Map} computedCache * @return {Promise>>} */ - static async _runAudits(settings, audits, artifacts, runWarnings) { + static async _runAudits(settings, audits, artifacts, runWarnings, computedCache) { const status = {msg: 'Analyzing and running audits...', id: 'lh:runner:auditing'}; log.time(status); @@ -267,7 +270,7 @@ class Runner { // Members of LH.Audit.Context that are shared across all audits. const sharedAuditContext = { settings, - computedCache: new Map(), + computedCache, }; // Run each audit sequentially diff --git a/types/gatherer.d.ts b/types/gatherer.d.ts index 65562391feea..b1a26a39c93c 100644 --- a/types/gatherer.d.ts +++ b/types/gatherer.d.ts @@ -10,6 +10,7 @@ import _Simulator = require('../lighthouse-core/lib/dependency-graph/simulator/s import Driver = require('../lighthouse-core/gather/driver'); import ExecutionContext = require('../lighthouse-core/gather/driver/execution-context'); import Fetcher = require('../lighthouse-core/gather/fetcher'); +import ArbitraryEqualityMap = require('../lighthouse-core/lib/arbitrary-equality-map'); declare global { module LH.Gatherer { @@ -41,6 +42,8 @@ declare global { gatherMode: GatherMode; /** The connection to the page being analyzed. */ driver: FRTransitionalDriver; + computedCache: Map; + settings: Config.Settings; /** The set of available dependencies requested by the current gatherer. */ dependencies: TDependencies extends DefaultDependenciesKey ? {} : @@ -54,11 +57,14 @@ declare global { driver: Driver; passConfig: Config.Pass settings: Config.Settings; + computedCache: Map /** Gatherers can push to this array to add top-level warnings to the LHR. */ LighthouseRunWarnings: Array; baseArtifacts: BaseArtifacts; } + export type CompatibilityContext = PassContext | FRTransitionalContext; + export interface LoadData { networkRecords: Array; devtoolsLog: DevtoolsLog; From 42e04ddcc8ab92d94d72693e0d47fb3ca3dd2772 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Fri, 30 Apr 2021 18:45:15 -0400 Subject: [PATCH 02/17] computed context --- lighthouse-core/audits/metrics.js | 2 +- lighthouse-core/audits/performance-budget.js | 3 ++- lighthouse-core/audits/resource-summary.js | 2 +- lighthouse-core/audits/timing-budget.js | 3 ++- lighthouse-core/computed/computed-artifact.js | 5 +++-- lighthouse-core/computed/metrics/metric.js | 6 +++--- .../computed/metrics/timing-summary.js | 15 ++++++++------- lighthouse-core/computed/resource-summary.js | 12 ++++++------ types/artifacts.d.ts | 1 + types/gatherer.d.ts | 4 ++++ 10 files changed, 31 insertions(+), 22 deletions(-) diff --git a/lighthouse-core/audits/metrics.js b/lighthouse-core/audits/metrics.js index fa839d300488..6f6942f093a6 100644 --- a/lighthouse-core/audits/metrics.js +++ b/lighthouse-core/audits/metrics.js @@ -44,7 +44,7 @@ class Metrics extends Audit { const trace = artifacts.traces[Audit.DEFAULT_PASS]; const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS]; const summary = await ComputedTimingSummary - .request({trace, devtoolsLog}, context); + .request({trace, devtoolsLog, settings: artifacts.settings}, context); const metrics = summary.metrics; const debugInfo = summary.debugInfo; diff --git a/lighthouse-core/audits/performance-budget.js b/lighthouse-core/audits/performance-budget.js index c8e68a4da46b..d41b874cdd28 100644 --- a/lighthouse-core/audits/performance-budget.js +++ b/lighthouse-core/audits/performance-budget.js @@ -120,7 +120,8 @@ class ResourceBudget extends Audit { */ static async audit(artifacts, context) { const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS]; - const summary = await ResourceSummary.request({devtoolsLog, URL: artifacts.URL}, context); + const data = {devtoolsLog, URL: artifacts.URL, settings: artifacts.settings}; + const summary = await ResourceSummary.request(data, context); const mainResource = await MainResource.request({URL: artifacts.URL, devtoolsLog}, context); const budget = Budget.getMatchingBudget(context.settings.budgets, mainResource.url); diff --git a/lighthouse-core/audits/resource-summary.js b/lighthouse-core/audits/resource-summary.js index e41da0885c96..9fc4d63ca643 100644 --- a/lighthouse-core/audits/resource-summary.js +++ b/lighthouse-core/audits/resource-summary.js @@ -45,7 +45,7 @@ class ResourceSummary extends Audit { static async audit(artifacts, context) { const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS]; const summary = await ComputedResourceSummary - .request({devtoolsLog, URL: artifacts.URL}, context); + .request({devtoolsLog, URL: artifacts.URL, settings: artifacts.settings}, context); /** @type {LH.Audit.Details.Table['headings']} */ const headings = [ diff --git a/lighthouse-core/audits/timing-budget.js b/lighthouse-core/audits/timing-budget.js index 950c648d5c5f..4be90b209142 100644 --- a/lighthouse-core/audits/timing-budget.js +++ b/lighthouse-core/audits/timing-budget.js @@ -143,7 +143,8 @@ class TimingBudget extends Audit { const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS]; const trace = artifacts.traces[Audit.DEFAULT_PASS]; const mainResource = await MainResource.request({URL: artifacts.URL, devtoolsLog}, context); - const summary = (await TimingSummary.request({trace, devtoolsLog}, context)).metrics; + const data = {trace, devtoolsLog, settings: artifacts.settings}; + const summary = (await TimingSummary.request(data, context)).metrics; const budget = Budget.getMatchingBudget(context.settings.budgets, mainResource.url); if (!budget) { diff --git a/lighthouse-core/computed/computed-artifact.js b/lighthouse-core/computed/computed-artifact.js index 268fee9d7157..233dcb231bec 100644 --- a/lighthouse-core/computed/computed-artifact.js +++ b/lighthouse-core/computed/computed-artifact.js @@ -8,10 +8,11 @@ const ArbitraryEqualityMap = require('../lib/arbitrary-equality-map.js'); const log = require('lighthouse-logger'); + /** * Decorate computableArtifact with a caching `request()` method which will * automatically call `computableArtifact.compute_()` under the hood. - * @template {{name: string, compute_(artifacts: unknown, context: LH.Audit.Context): Promise}} C + * @template {{name: string, compute_(artifacts: unknown, context: LH.Gatherer.ComputedContext): Promise}} C * @param {C} computableArtifact */ function makeComputedArtifact(computableArtifact) { @@ -21,7 +22,7 @@ function makeComputedArtifact(computableArtifact) { /** * Return an automatically cached result from the computed artifact. * @param {FirstParamType} artifacts - * @param {LH.Audit.Context} context + * @param {LH.Gatherer.ComputedContext} context * @return {ReturnType} */ const request = (artifacts, context) => { diff --git a/lighthouse-core/computed/metrics/metric.js b/lighthouse-core/computed/metrics/metric.js index f0ff896e908f..85a6115671b5 100644 --- a/lighthouse-core/computed/metrics/metric.js +++ b/lighthouse-core/computed/metrics/metric.js @@ -23,7 +23,7 @@ class ComputedMetric { /** * @param {LH.Artifacts.MetricComputationData} data - * @param {LH.Audit.Context} context + * @param {LH.Gatherer.ComputedContext} context * @return {Promise} */ static computeSimulatedMetric(data, context) { // eslint-disable-line no-unused-vars @@ -32,7 +32,7 @@ class ComputedMetric { /** * @param {LH.Artifacts.MetricComputationData} data - * @param {LH.Audit.Context} context + * @param {LH.Gatherer.ComputedContext} context * @return {Promise} */ static computeObservedMetric(data, context) { // eslint-disable-line no-unused-vars @@ -41,7 +41,7 @@ class ComputedMetric { /** * @param {LH.Artifacts.MetricComputationDataInput} data - * @param {LH.Audit.Context} context + * @param {LH.Gatherer.ComputedContext} context * @return {Promise} */ static async compute_(data, context) { diff --git a/lighthouse-core/computed/metrics/timing-summary.js b/lighthouse-core/computed/metrics/timing-summary.js index 3e90253e2deb..0cd390b1bab3 100644 --- a/lighthouse-core/computed/metrics/timing-summary.js +++ b/lighthouse-core/computed/metrics/timing-summary.js @@ -27,15 +27,16 @@ class TimingSummary { /** * @param {LH.Trace} trace * @param {LH.DevtoolsLog} devtoolsLog - * @param {LH.Audit.Context} context + * @param {LH.Config.Settings} settings + * @param {LH.Gatherer.ComputedContext} context * @return {Promise<{metrics: LH.Artifacts.TimingSummary, debugInfo: Record}>} */ - static async summarize(trace, devtoolsLog, context) { - const metricComputationData = {trace, devtoolsLog, settings: context.settings}; + static async summarize(trace, devtoolsLog, settings, context) { + const metricComputationData = {trace, devtoolsLog, settings}; /** * @template TArtifacts * @template TReturn - * @param {{request: (artifact: TArtifacts, context: LH.Audit.Context) => Promise}} Artifact + * @param {{request: (artifact: TArtifacts, context: LH.Gatherer.ComputedContext) => Promise}} Artifact * @param {TArtifacts} artifact * @return {Promise} */ @@ -141,12 +142,12 @@ class TimingSummary { return {metrics, debugInfo}; } /** - * @param {{trace: LH.Trace, devtoolsLog: LH.DevtoolsLog}} data - * @param {LH.Audit.Context} context + * @param {{trace: LH.Trace, devtoolsLog: LH.DevtoolsLog, settings: LH.Config.Settings}} data + * @param {LH.Gatherer.ComputedContext} context * @return {Promise<{metrics: LH.Artifacts.TimingSummary, debugInfo: Record}>} */ static async compute_(data, context) { - return TimingSummary.summarize(data.trace, data.devtoolsLog, context); + return TimingSummary.summarize(data.trace, data.devtoolsLog, data.settings, context); } } diff --git a/lighthouse-core/computed/resource-summary.js b/lighthouse-core/computed/resource-summary.js index bc3536ce8be0..81ee5dc9b854 100644 --- a/lighthouse-core/computed/resource-summary.js +++ b/lighthouse-core/computed/resource-summary.js @@ -37,10 +37,10 @@ class ResourceSummary { /** * @param {Array} networkRecords * @param {string} mainResourceURL - * @param {LH.Audit.Context} context + * @param {LH.Config.Settings} settings * @return {Record} */ - static summarize(networkRecords, mainResourceURL, context) { + static summarize(networkRecords, mainResourceURL, settings) { /** @type {Record} */ const resourceSummary = { 'stylesheet': {count: 0, resourceSize: 0, transferSize: 0}, @@ -53,7 +53,7 @@ class ResourceSummary { 'total': {count: 0, resourceSize: 0, transferSize: 0}, 'third-party': {count: 0, resourceSize: 0, transferSize: 0}, }; - const budget = Budget.getMatchingBudget(context.settings.budgets, mainResourceURL); + const budget = Budget.getMatchingBudget(settings.budgets, mainResourceURL); /** @type {ReadonlyArray} */ let firstPartyHosts = []; if (budget && budget.options && budget.options.firstPartyHostnames) { @@ -102,8 +102,8 @@ class ResourceSummary { } /** - * @param {{URL: LH.Artifacts['URL'], devtoolsLog: LH.DevtoolsLog}} data - * @param {LH.Audit.Context} context + * @param {{URL: LH.Artifacts['URL'], devtoolsLog: LH.DevtoolsLog, settings: LH.Config.Settings}} data + * @param {LH.Gatherer.ComputedContext} context * @return {Promise>} */ static async compute_(data, context) { @@ -111,7 +111,7 @@ class ResourceSummary { NetworkRecords.request(data.devtoolsLog, context), MainResource.request(data, context), ]); - return ResourceSummary.summarize(networkRecords, mainResource.url, context); + return ResourceSummary.summarize(networkRecords, mainResource.url, data.settings); } } diff --git a/types/artifacts.d.ts b/types/artifacts.d.ts index 073da753fe78..98ef599c0fa0 100644 --- a/types/artifacts.d.ts +++ b/types/artifacts.d.ts @@ -9,6 +9,7 @@ import _LanternSimulator = require('../lighthouse-core/lib/dependency-graph/simu import _NetworkRequest = require('../lighthouse-core/lib/network-request.js'); import speedline = require('speedline-core'); import TextSourceMap = require('../lighthouse-core/lib/cdt/generated/SourceMap.js'); +import ArbitraryEqualityMap = require('../lighthouse-core/lib/arbitrary-equality-map.js'); type _TaskNode = import('../lighthouse-core/lib/tracehouse/main-thread-tasks.js').TaskNode; diff --git a/types/gatherer.d.ts b/types/gatherer.d.ts index b1a26a39c93c..c8b0e45aa603 100644 --- a/types/gatherer.d.ts +++ b/types/gatherer.d.ts @@ -63,6 +63,10 @@ declare global { baseArtifacts: BaseArtifacts; } + export type ComputedContext = Immutable<{ + computedCache: Map; + }>; + export type CompatibilityContext = PassContext | FRTransitionalContext; export interface LoadData { From 6e2c770febbdb2ddcbd95bbe32e5a26184fe16f2 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Mon, 3 May 2021 14:48:58 -0400 Subject: [PATCH 03/17] Revert "computed context" This reverts commit 42e04ddcc8ab92d94d72693e0d47fb3ca3dd2772. --- lighthouse-core/audits/metrics.js | 2 +- lighthouse-core/audits/performance-budget.js | 3 +-- lighthouse-core/audits/resource-summary.js | 2 +- lighthouse-core/audits/timing-budget.js | 3 +-- lighthouse-core/computed/computed-artifact.js | 5 ++--- lighthouse-core/computed/metrics/metric.js | 6 +++--- .../computed/metrics/timing-summary.js | 15 +++++++-------- lighthouse-core/computed/resource-summary.js | 12 ++++++------ types/artifacts.d.ts | 1 - types/gatherer.d.ts | 4 ---- 10 files changed, 22 insertions(+), 31 deletions(-) diff --git a/lighthouse-core/audits/metrics.js b/lighthouse-core/audits/metrics.js index 6f6942f093a6..fa839d300488 100644 --- a/lighthouse-core/audits/metrics.js +++ b/lighthouse-core/audits/metrics.js @@ -44,7 +44,7 @@ class Metrics extends Audit { const trace = artifacts.traces[Audit.DEFAULT_PASS]; const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS]; const summary = await ComputedTimingSummary - .request({trace, devtoolsLog, settings: artifacts.settings}, context); + .request({trace, devtoolsLog}, context); const metrics = summary.metrics; const debugInfo = summary.debugInfo; diff --git a/lighthouse-core/audits/performance-budget.js b/lighthouse-core/audits/performance-budget.js index d41b874cdd28..c8e68a4da46b 100644 --- a/lighthouse-core/audits/performance-budget.js +++ b/lighthouse-core/audits/performance-budget.js @@ -120,8 +120,7 @@ class ResourceBudget extends Audit { */ static async audit(artifacts, context) { const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS]; - const data = {devtoolsLog, URL: artifacts.URL, settings: artifacts.settings}; - const summary = await ResourceSummary.request(data, context); + const summary = await ResourceSummary.request({devtoolsLog, URL: artifacts.URL}, context); const mainResource = await MainResource.request({URL: artifacts.URL, devtoolsLog}, context); const budget = Budget.getMatchingBudget(context.settings.budgets, mainResource.url); diff --git a/lighthouse-core/audits/resource-summary.js b/lighthouse-core/audits/resource-summary.js index 9fc4d63ca643..e41da0885c96 100644 --- a/lighthouse-core/audits/resource-summary.js +++ b/lighthouse-core/audits/resource-summary.js @@ -45,7 +45,7 @@ class ResourceSummary extends Audit { static async audit(artifacts, context) { const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS]; const summary = await ComputedResourceSummary - .request({devtoolsLog, URL: artifacts.URL, settings: artifacts.settings}, context); + .request({devtoolsLog, URL: artifacts.URL}, context); /** @type {LH.Audit.Details.Table['headings']} */ const headings = [ diff --git a/lighthouse-core/audits/timing-budget.js b/lighthouse-core/audits/timing-budget.js index 4be90b209142..950c648d5c5f 100644 --- a/lighthouse-core/audits/timing-budget.js +++ b/lighthouse-core/audits/timing-budget.js @@ -143,8 +143,7 @@ class TimingBudget extends Audit { const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS]; const trace = artifacts.traces[Audit.DEFAULT_PASS]; const mainResource = await MainResource.request({URL: artifacts.URL, devtoolsLog}, context); - const data = {trace, devtoolsLog, settings: artifacts.settings}; - const summary = (await TimingSummary.request(data, context)).metrics; + const summary = (await TimingSummary.request({trace, devtoolsLog}, context)).metrics; const budget = Budget.getMatchingBudget(context.settings.budgets, mainResource.url); if (!budget) { diff --git a/lighthouse-core/computed/computed-artifact.js b/lighthouse-core/computed/computed-artifact.js index 233dcb231bec..268fee9d7157 100644 --- a/lighthouse-core/computed/computed-artifact.js +++ b/lighthouse-core/computed/computed-artifact.js @@ -8,11 +8,10 @@ const ArbitraryEqualityMap = require('../lib/arbitrary-equality-map.js'); const log = require('lighthouse-logger'); - /** * Decorate computableArtifact with a caching `request()` method which will * automatically call `computableArtifact.compute_()` under the hood. - * @template {{name: string, compute_(artifacts: unknown, context: LH.Gatherer.ComputedContext): Promise}} C + * @template {{name: string, compute_(artifacts: unknown, context: LH.Audit.Context): Promise}} C * @param {C} computableArtifact */ function makeComputedArtifact(computableArtifact) { @@ -22,7 +21,7 @@ function makeComputedArtifact(computableArtifact) { /** * Return an automatically cached result from the computed artifact. * @param {FirstParamType} artifacts - * @param {LH.Gatherer.ComputedContext} context + * @param {LH.Audit.Context} context * @return {ReturnType} */ const request = (artifacts, context) => { diff --git a/lighthouse-core/computed/metrics/metric.js b/lighthouse-core/computed/metrics/metric.js index 85a6115671b5..f0ff896e908f 100644 --- a/lighthouse-core/computed/metrics/metric.js +++ b/lighthouse-core/computed/metrics/metric.js @@ -23,7 +23,7 @@ class ComputedMetric { /** * @param {LH.Artifacts.MetricComputationData} data - * @param {LH.Gatherer.ComputedContext} context + * @param {LH.Audit.Context} context * @return {Promise} */ static computeSimulatedMetric(data, context) { // eslint-disable-line no-unused-vars @@ -32,7 +32,7 @@ class ComputedMetric { /** * @param {LH.Artifacts.MetricComputationData} data - * @param {LH.Gatherer.ComputedContext} context + * @param {LH.Audit.Context} context * @return {Promise} */ static computeObservedMetric(data, context) { // eslint-disable-line no-unused-vars @@ -41,7 +41,7 @@ class ComputedMetric { /** * @param {LH.Artifacts.MetricComputationDataInput} data - * @param {LH.Gatherer.ComputedContext} context + * @param {LH.Audit.Context} context * @return {Promise} */ static async compute_(data, context) { diff --git a/lighthouse-core/computed/metrics/timing-summary.js b/lighthouse-core/computed/metrics/timing-summary.js index 0cd390b1bab3..3e90253e2deb 100644 --- a/lighthouse-core/computed/metrics/timing-summary.js +++ b/lighthouse-core/computed/metrics/timing-summary.js @@ -27,16 +27,15 @@ class TimingSummary { /** * @param {LH.Trace} trace * @param {LH.DevtoolsLog} devtoolsLog - * @param {LH.Config.Settings} settings - * @param {LH.Gatherer.ComputedContext} context + * @param {LH.Audit.Context} context * @return {Promise<{metrics: LH.Artifacts.TimingSummary, debugInfo: Record}>} */ - static async summarize(trace, devtoolsLog, settings, context) { - const metricComputationData = {trace, devtoolsLog, settings}; + static async summarize(trace, devtoolsLog, context) { + const metricComputationData = {trace, devtoolsLog, settings: context.settings}; /** * @template TArtifacts * @template TReturn - * @param {{request: (artifact: TArtifacts, context: LH.Gatherer.ComputedContext) => Promise}} Artifact + * @param {{request: (artifact: TArtifacts, context: LH.Audit.Context) => Promise}} Artifact * @param {TArtifacts} artifact * @return {Promise} */ @@ -142,12 +141,12 @@ class TimingSummary { return {metrics, debugInfo}; } /** - * @param {{trace: LH.Trace, devtoolsLog: LH.DevtoolsLog, settings: LH.Config.Settings}} data - * @param {LH.Gatherer.ComputedContext} context + * @param {{trace: LH.Trace, devtoolsLog: LH.DevtoolsLog}} data + * @param {LH.Audit.Context} context * @return {Promise<{metrics: LH.Artifacts.TimingSummary, debugInfo: Record}>} */ static async compute_(data, context) { - return TimingSummary.summarize(data.trace, data.devtoolsLog, data.settings, context); + return TimingSummary.summarize(data.trace, data.devtoolsLog, context); } } diff --git a/lighthouse-core/computed/resource-summary.js b/lighthouse-core/computed/resource-summary.js index 81ee5dc9b854..bc3536ce8be0 100644 --- a/lighthouse-core/computed/resource-summary.js +++ b/lighthouse-core/computed/resource-summary.js @@ -37,10 +37,10 @@ class ResourceSummary { /** * @param {Array} networkRecords * @param {string} mainResourceURL - * @param {LH.Config.Settings} settings + * @param {LH.Audit.Context} context * @return {Record} */ - static summarize(networkRecords, mainResourceURL, settings) { + static summarize(networkRecords, mainResourceURL, context) { /** @type {Record} */ const resourceSummary = { 'stylesheet': {count: 0, resourceSize: 0, transferSize: 0}, @@ -53,7 +53,7 @@ class ResourceSummary { 'total': {count: 0, resourceSize: 0, transferSize: 0}, 'third-party': {count: 0, resourceSize: 0, transferSize: 0}, }; - const budget = Budget.getMatchingBudget(settings.budgets, mainResourceURL); + const budget = Budget.getMatchingBudget(context.settings.budgets, mainResourceURL); /** @type {ReadonlyArray} */ let firstPartyHosts = []; if (budget && budget.options && budget.options.firstPartyHostnames) { @@ -102,8 +102,8 @@ class ResourceSummary { } /** - * @param {{URL: LH.Artifacts['URL'], devtoolsLog: LH.DevtoolsLog, settings: LH.Config.Settings}} data - * @param {LH.Gatherer.ComputedContext} context + * @param {{URL: LH.Artifacts['URL'], devtoolsLog: LH.DevtoolsLog}} data + * @param {LH.Audit.Context} context * @return {Promise>} */ static async compute_(data, context) { @@ -111,7 +111,7 @@ class ResourceSummary { NetworkRecords.request(data.devtoolsLog, context), MainResource.request(data, context), ]); - return ResourceSummary.summarize(networkRecords, mainResource.url, data.settings); + return ResourceSummary.summarize(networkRecords, mainResource.url, context); } } diff --git a/types/artifacts.d.ts b/types/artifacts.d.ts index 98ef599c0fa0..073da753fe78 100644 --- a/types/artifacts.d.ts +++ b/types/artifacts.d.ts @@ -9,7 +9,6 @@ import _LanternSimulator = require('../lighthouse-core/lib/dependency-graph/simu import _NetworkRequest = require('../lighthouse-core/lib/network-request.js'); import speedline = require('speedline-core'); import TextSourceMap = require('../lighthouse-core/lib/cdt/generated/SourceMap.js'); -import ArbitraryEqualityMap = require('../lighthouse-core/lib/arbitrary-equality-map.js'); type _TaskNode = import('../lighthouse-core/lib/tracehouse/main-thread-tasks.js').TaskNode; diff --git a/types/gatherer.d.ts b/types/gatherer.d.ts index c8b0e45aa603..b1a26a39c93c 100644 --- a/types/gatherer.d.ts +++ b/types/gatherer.d.ts @@ -63,10 +63,6 @@ declare global { baseArtifacts: BaseArtifacts; } - export type ComputedContext = Immutable<{ - computedCache: Map; - }>; - export type CompatibilityContext = PassContext | FRTransitionalContext; export interface LoadData { From b43616a99591272b4a0e400f7ed02ea7cbfd09c3 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Mon, 3 May 2021 16:48:47 -0400 Subject: [PATCH 04/17] resolve types --- lighthouse-core/fraggle-rock/gather/navigation-runner.js | 1 + lighthouse-core/fraggle-rock/gather/runner-helpers.js | 1 + lighthouse-core/fraggle-rock/gather/snapshot-runner.js | 1 + lighthouse-core/fraggle-rock/gather/timespan-runner.js | 1 + lighthouse-core/gather/gather-runner.js | 7 +------ lighthouse-core/gather/gatherers/link-elements.js | 7 +------ types/gatherer.d.ts | 2 +- 7 files changed, 7 insertions(+), 13 deletions(-) diff --git a/lighthouse-core/fraggle-rock/gather/navigation-runner.js b/lighthouse-core/fraggle-rock/gather/navigation-runner.js index 5609b5e9af34..93da919372b8 100644 --- a/lighthouse-core/fraggle-rock/gather/navigation-runner.js +++ b/lighthouse-core/fraggle-rock/gather/navigation-runner.js @@ -137,6 +137,7 @@ async function navigation(options) { { url: requestedUrl, config, + computedCache: new Map(), } ); } diff --git a/lighthouse-core/fraggle-rock/gather/runner-helpers.js b/lighthouse-core/fraggle-rock/gather/runner-helpers.js index 0d933bacccc1..f360f3a5843d 100644 --- a/lighthouse-core/fraggle-rock/gather/runner-helpers.js +++ b/lighthouse-core/fraggle-rock/gather/runner-helpers.js @@ -76,6 +76,7 @@ async function collectPhaseArtifacts(options) { gatherMode, driver, dependencies, + computedCache: new Map(), }); }); diff --git a/lighthouse-core/fraggle-rock/gather/snapshot-runner.js b/lighthouse-core/fraggle-rock/gather/snapshot-runner.js index b3fe26744cd2..30ac7dabf0fa 100644 --- a/lighthouse-core/fraggle-rock/gather/snapshot-runner.js +++ b/lighthouse-core/fraggle-rock/gather/snapshot-runner.js @@ -45,6 +45,7 @@ async function snapshot(options) { { url, config, + computedCache: new Map(), } ); } diff --git a/lighthouse-core/fraggle-rock/gather/timespan-runner.js b/lighthouse-core/fraggle-rock/gather/timespan-runner.js index bec25ba1cbb8..e36ea00c2152 100644 --- a/lighthouse-core/fraggle-rock/gather/timespan-runner.js +++ b/lighthouse-core/fraggle-rock/gather/timespan-runner.js @@ -51,6 +51,7 @@ async function startTimespan(options) { { url: finalUrl, config, + computedCache: new Map(), } ); }, diff --git a/lighthouse-core/gather/gather-runner.js b/lighthouse-core/gather/gather-runner.js index 11495771c80f..73c53cae12ef 100644 --- a/lighthouse-core/gather/gather-runner.js +++ b/lighthouse-core/gather/gather-runner.js @@ -478,12 +478,7 @@ class GatherRunner { }; log.time(status); const devtoolsLog = driver.endDevtoolsLog(); - const context = { - computedCache: passContext.computedCache, - settings: passContext.settings, - options: {}, - }; - const networkRecords = await NetworkRecords.request(devtoolsLog, context); + const networkRecords = await NetworkRecords.request(devtoolsLog, passContext); log.timeEnd(status); return { diff --git a/lighthouse-core/gather/gatherers/link-elements.js b/lighthouse-core/gather/gatherers/link-elements.js index 50f4a25ddc1c..f3732fff4a04 100644 --- a/lighthouse-core/gather/gatherers/link-elements.js +++ b/lighthouse-core/gather/gatherers/link-elements.js @@ -169,12 +169,7 @@ class LinkElements extends FRGatherer { * @return {Promise} */ async getArtifact(passContext) { - const context = { - computedCache: passContext.computedCache, - settings: passContext.settings, - options: {}, - }; - const records = await NetworkRecords.request(passContext.dependencies.DevtoolsLog, context); + const records = await NetworkRecords.request(passContext.dependencies.DevtoolsLog, passContext); return await this._getArtifact(passContext, records); } } diff --git a/types/gatherer.d.ts b/types/gatherer.d.ts index b1a26a39c93c..f712954074b1 100644 --- a/types/gatherer.d.ts +++ b/types/gatherer.d.ts @@ -42,8 +42,8 @@ declare global { gatherMode: GatherMode; /** The connection to the page being analyzed. */ driver: FRTransitionalDriver; + /** The cached results of computed artifacts. */ computedCache: Map; - settings: Config.Settings; /** The set of available dependencies requested by the current gatherer. */ dependencies: TDependencies extends DefaultDependenciesKey ? {} : From f3b0a19216784df56dd46d281be7471ad9f0a790 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Mon, 3 May 2021 17:13:06 -0400 Subject: [PATCH 05/17] rm compatibility context --- lighthouse-core/gather/gather-runner.js | 1 + lighthouse-core/gather/gatherers/link-elements.js | 8 ++++---- types/gatherer.d.ts | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lighthouse-core/gather/gather-runner.js b/lighthouse-core/gather/gather-runner.js index 73c53cae12ef..ea666b514390 100644 --- a/lighthouse-core/gather/gather-runner.js +++ b/lighthouse-core/gather/gather-runner.js @@ -740,6 +740,7 @@ class GatherRunner { baseArtifacts, computedCache: options.computedCache, LighthouseRunWarnings: baseArtifacts.LighthouseRunWarnings, + dependencies: {}, }; const passResults = await GatherRunner.runPass(passContext); Object.assign(artifacts, passResults.artifacts); diff --git a/lighthouse-core/gather/gatherers/link-elements.js b/lighthouse-core/gather/gatherers/link-elements.js index f3732fff4a04..b3110a6cca16 100644 --- a/lighthouse-core/gather/gatherers/link-elements.js +++ b/lighthouse-core/gather/gatherers/link-elements.js @@ -89,7 +89,7 @@ class LinkElements extends FRGatherer { } /** - * @param {LH.Gatherer.CompatibilityContext} passContext + * @param {LH.Gatherer.FRTransitionalContext} passContext * @return {Promise} */ static getLinkElementsInDOM(passContext) { @@ -106,7 +106,7 @@ class LinkElements extends FRGatherer { } /** - * @param {LH.Gatherer.CompatibilityContext} passContext + * @param {LH.Gatherer.FRTransitionalContext} passContext * @param {LH.Artifacts.NetworkRequest[]} networkRecords * @return {Promise} */ @@ -138,7 +138,7 @@ class LinkElements extends FRGatherer { } /** - * @param {LH.Gatherer.CompatibilityContext} passContext + * @param {LH.Gatherer.FRTransitionalContext} passContext * @param {LH.Artifacts.NetworkRequest[]} networkRecords * @return {Promise} */ @@ -156,7 +156,7 @@ class LinkElements extends FRGatherer { } /** - * @param {LH.Gatherer.PassContext} passContext + * @param {LH.Gatherer.FRTransitionalContext} passContext * @param {LH.Gatherer.LoadData} loadData * @return {Promise} */ diff --git a/types/gatherer.d.ts b/types/gatherer.d.ts index f712954074b1..ccb401347782 100644 --- a/types/gatherer.d.ts +++ b/types/gatherer.d.ts @@ -61,10 +61,9 @@ declare global { /** Gatherers can push to this array to add top-level warnings to the LHR. */ LighthouseRunWarnings: Array; baseArtifacts: BaseArtifacts; + dependencies: {}; } - export type CompatibilityContext = PassContext | FRTransitionalContext; - export interface LoadData { networkRecords: Array; devtoolsLog: DevtoolsLog; From cf076cfb8191d41bf1bb77568306b66b294715ec Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Mon, 3 May 2021 17:42:42 -0400 Subject: [PATCH 06/17] gather-runner-test --- .../test/gather/gather-runner-test.js | 39 +++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/lighthouse-core/test/gather/gather-runner-test.js b/lighthouse-core/test/gather/gather-runner-test.js index e42e47371048..564dfb14ef82 100644 --- a/lighthouse-core/test/gather/gather-runner-test.js +++ b/lighthouse-core/test/gather/gather-runner-test.js @@ -207,7 +207,7 @@ describe('GatherRunner', function() { const requestedUrl = 'https://example.com'; const driver = fakeDriver; const config = makeConfig({passes: []}); - const options = {requestedUrl, driver, settings: config.settings}; + const options = {requestedUrl, driver, settings: config.settings, computedCache: new Map()}; const results = await GatherRunner.run(config.passes, options); expect(Number.isFinite(results.BenchmarkIndex)).toBeTruthy(); @@ -217,7 +217,7 @@ describe('GatherRunner', function() { const requestedUrl = 'https://example.com'; const driver = fakeDriver; const config = makeConfig({passes: []}); - const options = {requestedUrl, driver, settings: config.settings}; + const options = {requestedUrl, driver, settings: config.settings, computedCache: new Map()}; const results = await GatherRunner.run(config.passes, options); expect(results.HostUserAgent).toEqual(fakeDriver.protocolGetVersionResponse.userAgent); @@ -228,7 +228,7 @@ describe('GatherRunner', function() { const requestedUrl = 'https://example.com'; const driver = fakeDriver; const config = makeConfig({passes: [{passName: 'defaultPass'}]}); - const options = {requestedUrl, driver, settings: config.settings}; + const options = {requestedUrl, driver, settings: config.settings, computedCache: new Map()}; const results = await GatherRunner.run(config.passes, options); expect(results.NetworkUserAgent).toContain('Mozilla'); @@ -243,7 +243,7 @@ describe('GatherRunner', function() { }, }); const config = makeConfig({passes: [{passName: 'defaultPass'}]}); - const options = {requestedUrl, driver, settings: config.settings}; + const options = {requestedUrl, driver, settings: config.settings, computedCache: new Map()}; return GatherRunner.run(config.passes, options).then(artifacts => { assert.deepStrictEqual(artifacts.URL, {requestedUrl, finalUrl}, @@ -270,7 +270,7 @@ describe('GatherRunner', function() { passes: [], settings: {}, }); - const options = {requestedUrl, driver, settings: config.settings}; + const options = {requestedUrl, driver, settings: config.settings, computedCache: new Map()}; const results = await GatherRunner.run(config.passes, options); expect(results.HostFormFactor).toBe(expectedValue); @@ -480,6 +480,7 @@ describe('GatherRunner', function() { passConfig, settings, baseArtifacts: await GatherRunner.initializeBaseArtifacts({driver, settings, requestedUrl}), + computedCache: new Map(), }; const storage = jest.requireMock('../../gather/driver/storage.js'); @@ -512,6 +513,7 @@ describe('GatherRunner', function() { driver, requestedUrl, settings: config.settings, + computedCache: new Map(), }; const artifacts = await GatherRunner.run(config.passes, options); @@ -546,6 +548,7 @@ describe('GatherRunner', function() { driver, requestedUrl, settings: config.settings, + computedCache: new Map(), }; const artifacts = await GatherRunner.run(config.passes, options); @@ -586,6 +589,7 @@ describe('GatherRunner', function() { driver, requestedUrl, settings: config.settings, + computedCache: new Map(), }; const artifacts = await GatherRunner.run(config.passes, options); @@ -744,7 +748,8 @@ describe('GatherRunner', function() { ], }; - return GatherRunner.endRecording({url, driver, passConfig}).then(passData => { + const passContext = {url, driver, passConfig, computedCache: new Map()}; + return GatherRunner.endRecording(passContext).then(passData => { assert.equal(calledTrace, true); assert.equal(passData.trace, fakeTraceData); }); @@ -769,7 +774,7 @@ describe('GatherRunner', function() { }; const settings = {}; - await GatherRunner.beginRecording({driver, passConfig, settings}); + await GatherRunner.beginRecording({driver, passConfig, settings, computedCache: new Map()}); assert.equal(calledDevtoolsLogCollect, true); }); @@ -793,7 +798,8 @@ describe('GatherRunner', function() { ], }; - return GatherRunner.endRecording({url, driver, passConfig}).then(passData => { + const passContext = {url, driver, passConfig, computedCache: new Map()}; + return GatherRunner.endRecording(passContext).then(passData => { assert.equal(calledDevtoolsLogCollect, true); assert.strictEqual(passData.devtoolsLog[0], fakeDevtoolsMessage); }); @@ -823,7 +829,8 @@ describe('GatherRunner', function() { const gathererResults = { TestGatherer: [], }; - await GatherRunner.afterPass({url, driver, passConfig}, {}, gathererResults); + const passContext = {url, driver, passConfig, computedCache: new Map()}; + await GatherRunner.afterPass(passContext, {}, gathererResults); // One time for the afterPass of ScrollMcScrolly, two times for the resets of the two gatherers. expect(scrollToSpy.mock.calls).toEqual([ [{x: 1000, y: 1000}], @@ -855,6 +862,7 @@ describe('GatherRunner', function() { driver: fakeDriver, requestedUrl: 'https://example.com', settings: config.settings, + computedCache: new Map(), }).then(_ => { assert.ok(t1.called); assert.ok(t2.called); @@ -877,6 +885,7 @@ describe('GatherRunner', function() { driver: fakeDriver, requestedUrl: 'https://example.com', settings: config.settings, + computedCache: new Map(), }; return GatherRunner.run(config.passes, options) @@ -904,7 +913,7 @@ describe('GatherRunner', function() { gatherers: [{instance: new TestGatherer()}], }], }); - const options = {driver, requestedUrl, settings: config.settings}; + const options = {driver, requestedUrl, settings: config.settings, computedCache: new Map()}; const artifacts = await GatherRunner.run(config.passes, options); expect(artifacts.PageLoadError).toMatchObject({code: 'NO_DOCUMENT_REQUEST'}); @@ -951,7 +960,7 @@ describe('GatherRunner', function() { }, online: true, }); - const options = {driver, requestedUrl, settings: config.settings}; + const options = {driver, requestedUrl, settings: config.settings, computedCache: new Map()}; const artifacts = await GatherRunner.run(config.passes, options); // t1.pass() and t2.pass() called; t3.pass(), after the error, was not. @@ -1444,6 +1453,7 @@ describe('GatherRunner', function() { driver: fakeDriver, requestedUrl: 'https://example.com', settings: config.settings, + computedCache: new Map(), }); // Ensure artifacts returned and not errors. @@ -1500,6 +1510,7 @@ describe('GatherRunner', function() { driver: fakeDriver, requestedUrl: 'https://example.com', settings: config.settings, + computedCache: new Map(), }).then(artifacts => { gathererNames.forEach(gathererName => { assert.strictEqual(artifacts[gathererName], gathererName); @@ -1578,6 +1589,7 @@ describe('GatherRunner', function() { driver: fakeDriver, requestedUrl: 'https://example.com', settings: config.settings, + computedCache: new Map(), }); assert.deepStrictEqual(artifacts.LighthouseRunWarnings, runWarnings); }); @@ -1633,6 +1645,7 @@ describe('GatherRunner', function() { driver: fakeDriver, requestedUrl: 'https://example.com', settings: config.settings, + computedCache: new Map(), }).then(artifacts => { gathererNames.forEach(gathererName => { const errorArtifact = artifacts[gathererName]; @@ -1657,6 +1670,7 @@ describe('GatherRunner', function() { driver: fakeDriver, requestedUrl: 'https://example.com', settings: config.settings, + computedCache: new Map(), }).then(_ => assert.ok(false), _ => assert.ok(true)); }); @@ -1685,6 +1699,7 @@ describe('GatherRunner', function() { driver: unresolvedDriver, requestedUrl, settings: config.settings, + computedCache: new Map(), }).then(artifacts => { assert.equal(artifacts.LighthouseRunWarnings.length, 1); expect(artifacts.LighthouseRunWarnings[0]) @@ -1713,6 +1728,7 @@ describe('GatherRunner', function() { driver: timedoutDriver, requestedUrl, settings: config.settings, + computedCache: new Map(), }).then(artifacts => { assert.equal(artifacts.LighthouseRunWarnings.length, 1); expect(artifacts.LighthouseRunWarnings[0]) @@ -1745,6 +1761,7 @@ describe('GatherRunner', function() { driver: unresolvedDriver, requestedUrl, settings: config.settings, + computedCache: new Map(), }) .then(_ => { assert.ok(true); From 240782fe5df6d8a6bbca97c22853bc2da0655823 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Mon, 3 May 2021 18:05:13 -0400 Subject: [PATCH 07/17] go back --- lighthouse-core/fraggle-rock/gather/base-gatherer.js | 2 ++ lighthouse-core/gather/gather-runner.js | 1 - lighthouse-core/gather/gatherers/link-elements.js | 4 ++-- types/gatherer.d.ts | 1 - 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lighthouse-core/fraggle-rock/gather/base-gatherer.js b/lighthouse-core/fraggle-rock/gather/base-gatherer.js index 852ee4227648..32ce86e72cfb 100644 --- a/lighthouse-core/fraggle-rock/gather/base-gatherer.js +++ b/lighthouse-core/fraggle-rock/gather/base-gatherer.js @@ -90,6 +90,8 @@ class FRGatherer { * @return {Promise} */ async afterPass(passContext, loadData) { + // @ts-ignore Default meta type does not include dependencies. + if (this.meta.dependencies) throw Error('Legacy gatherer should not have dependencies.'); await this.stopSensitiveInstrumentation({...passContext, dependencies: {}}); await this.stopInstrumentation({...passContext, dependencies: {}}); return this.getArtifact({...passContext, dependencies: {}}); diff --git a/lighthouse-core/gather/gather-runner.js b/lighthouse-core/gather/gather-runner.js index ea666b514390..73c53cae12ef 100644 --- a/lighthouse-core/gather/gather-runner.js +++ b/lighthouse-core/gather/gather-runner.js @@ -740,7 +740,6 @@ class GatherRunner { baseArtifacts, computedCache: options.computedCache, LighthouseRunWarnings: baseArtifacts.LighthouseRunWarnings, - dependencies: {}, }; const passResults = await GatherRunner.runPass(passContext); Object.assign(artifacts, passResults.artifacts); diff --git a/lighthouse-core/gather/gatherers/link-elements.js b/lighthouse-core/gather/gatherers/link-elements.js index b3110a6cca16..15dcbc1ad06e 100644 --- a/lighthouse-core/gather/gatherers/link-elements.js +++ b/lighthouse-core/gather/gatherers/link-elements.js @@ -156,12 +156,12 @@ class LinkElements extends FRGatherer { } /** - * @param {LH.Gatherer.FRTransitionalContext} passContext + * @param {LH.Gatherer.PassContext} passContext * @param {LH.Gatherer.LoadData} loadData * @return {Promise} */ async afterPass(passContext, loadData) { - return await this._getArtifact(passContext, loadData.networkRecords); + return await this._getArtifact({...passContext, dependencies: {}}, loadData.networkRecords); } /** diff --git a/types/gatherer.d.ts b/types/gatherer.d.ts index ccb401347782..f6bc087f5f69 100644 --- a/types/gatherer.d.ts +++ b/types/gatherer.d.ts @@ -61,7 +61,6 @@ declare global { /** Gatherers can push to this array to add top-level warnings to the LHR. */ LighthouseRunWarnings: Array; baseArtifacts: BaseArtifacts; - dependencies: {}; } export interface LoadData { From 664ba779f9dc23955362b83964fd1feefbf314f5 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Mon, 3 May 2021 18:27:21 -0400 Subject: [PATCH 08/17] runner test --- lighthouse-core/test/runner-test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lighthouse-core/test/runner-test.js b/lighthouse-core/test/runner-test.js index 49b8d30bfa2c..9fcf057c63ac 100644 --- a/lighthouse-core/test/runner-test.js +++ b/lighthouse-core/test/runner-test.js @@ -30,7 +30,7 @@ const i18n = require('../lib/i18n/i18n.js'); describe('Runner', () => { const defaultGatherFn = opts => Runner._gatherArtifactsFromBrowser( opts.requestedUrl, - opts, + {...opts, computedCache: new Map()}, null ); @@ -316,7 +316,7 @@ describe('Runner', () => { ], }); - return Runner.run({}, {config}).then(results => { + return Runner.run({}, {config, computedCache: new Map()}).then(results => { const audits = results.lhr.audits; assert.equal(audits['user-timings'].displayValue, '2 user timings'); assert.deepStrictEqual(audits['user-timings'].details.items.map(i => i.startTime), @@ -555,7 +555,7 @@ describe('Runner', () => { ], }); - return Runner.run({}, {config}).then(results => { + return Runner.run({}, {config, computedCache: new Map()}).then(results => { const audits = results.lhr.audits; assert.equal(audits['critical-request-chains'].displayValue, '5 chains found'); assert.equal(audits['critical-request-chains'].details.longestChain.transferSize, 2468); From bc43a9522917d333f31cdefe1f0a505f126c7798 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Tue, 4 May 2021 13:17:43 -0400 Subject: [PATCH 09/17] rn context --- .../gather/gatherers/link-elements.js | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lighthouse-core/gather/gatherers/link-elements.js b/lighthouse-core/gather/gatherers/link-elements.js index 15dcbc1ad06e..e7cae9f040d8 100644 --- a/lighthouse-core/gather/gatherers/link-elements.js +++ b/lighthouse-core/gather/gatherers/link-elements.js @@ -89,13 +89,13 @@ class LinkElements extends FRGatherer { } /** - * @param {LH.Gatherer.FRTransitionalContext} passContext + * @param {LH.Gatherer.FRTransitionalContext} context * @return {Promise} */ - static getLinkElementsInDOM(passContext) { + static getLinkElementsInDOM(context) { // We'll use evaluateAsync because the `node.getAttribute` method doesn't actually normalize // the values like access from JavaScript does. - return passContext.driver.executionContext.evaluate(getLinkElementsInDOM, { + return context.driver.executionContext.evaluate(getLinkElementsInDOM, { args: [], useIsolation: true, deps: [ @@ -106,12 +106,12 @@ class LinkElements extends FRGatherer { } /** - * @param {LH.Gatherer.FRTransitionalContext} passContext + * @param {LH.Gatherer.FRTransitionalContext} context * @param {LH.Artifacts.NetworkRequest[]} networkRecords * @return {Promise} */ - static async getLinkElementsInHeaders(passContext, networkRecords) { - const finalUrl = passContext.url; + static async getLinkElementsInHeaders(context, networkRecords) { + const finalUrl = context.url; const mainDocument = NetworkAnalyzer.findMainDocument(networkRecords, finalUrl); /** @type {LH.Artifacts['LinkElements']} */ @@ -138,13 +138,13 @@ class LinkElements extends FRGatherer { } /** - * @param {LH.Gatherer.FRTransitionalContext} passContext + * @param {LH.Gatherer.FRTransitionalContext} context * @param {LH.Artifacts.NetworkRequest[]} networkRecords * @return {Promise} */ - async _getArtifact(passContext, networkRecords) { - const fromDOM = await LinkElements.getLinkElementsInDOM(passContext); - const fromHeaders = await LinkElements.getLinkElementsInHeaders(passContext, networkRecords); + async _getArtifact(context, networkRecords) { + const fromDOM = await LinkElements.getLinkElementsInDOM(context); + const fromHeaders = await LinkElements.getLinkElementsInHeaders(context, networkRecords); const linkElements = fromDOM.concat(fromHeaders); for (const link of linkElements) { @@ -156,21 +156,21 @@ class LinkElements extends FRGatherer { } /** - * @param {LH.Gatherer.PassContext} passContext + * @param {LH.Gatherer.PassContext} context * @param {LH.Gatherer.LoadData} loadData * @return {Promise} */ - async afterPass(passContext, loadData) { - return await this._getArtifact({...passContext, dependencies: {}}, loadData.networkRecords); + async afterPass(context, loadData) { + return await this._getArtifact({...context, dependencies: {}}, loadData.networkRecords); } /** - * @param {LH.Gatherer.FRTransitionalContext<'DevtoolsLog'>} passContext + * @param {LH.Gatherer.FRTransitionalContext<'DevtoolsLog'>} context * @return {Promise} */ - async getArtifact(passContext) { - const records = await NetworkRecords.request(passContext.dependencies.DevtoolsLog, passContext); - return await this._getArtifact(passContext, records); + async getArtifact(context) { + const records = await NetworkRecords.request(context.dependencies.DevtoolsLog, context); + return await this._getArtifact(context, records); } } From be85784c5e5177536a82554e8392f1eebe16a30f Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Tue, 4 May 2021 13:24:43 -0400 Subject: [PATCH 10/17] rm async --- lighthouse-core/gather/gatherers/link-elements.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lighthouse-core/gather/gatherers/link-elements.js b/lighthouse-core/gather/gatherers/link-elements.js index e7cae9f040d8..e0ac7fcea950 100644 --- a/lighthouse-core/gather/gatherers/link-elements.js +++ b/lighthouse-core/gather/gatherers/link-elements.js @@ -108,9 +108,9 @@ class LinkElements extends FRGatherer { /** * @param {LH.Gatherer.FRTransitionalContext} context * @param {LH.Artifacts.NetworkRequest[]} networkRecords - * @return {Promise} + * @return {LH.Artifacts['LinkElements']} */ - static async getLinkElementsInHeaders(context, networkRecords) { + static getLinkElementsInHeaders(context, networkRecords) { const finalUrl = context.url; const mainDocument = NetworkAnalyzer.findMainDocument(networkRecords, finalUrl); @@ -144,7 +144,7 @@ class LinkElements extends FRGatherer { */ async _getArtifact(context, networkRecords) { const fromDOM = await LinkElements.getLinkElementsInDOM(context); - const fromHeaders = await LinkElements.getLinkElementsInHeaders(context, networkRecords); + const fromHeaders = LinkElements.getLinkElementsInHeaders(context, networkRecords); const linkElements = fromDOM.concat(fromHeaders); for (const link of linkElements) { From b384121ebeb1d182a07728bc69fe591006406621 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Tue, 4 May 2021 13:33:42 -0400 Subject: [PATCH 11/17] fix --- lighthouse-core/gather/gatherers/link-elements.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lighthouse-core/gather/gatherers/link-elements.js b/lighthouse-core/gather/gatherers/link-elements.js index e0ac7fcea950..dbb30c8ff48f 100644 --- a/lighthouse-core/gather/gatherers/link-elements.js +++ b/lighthouse-core/gather/gatherers/link-elements.js @@ -82,10 +82,13 @@ function getLinkElementsInDOM() { /* c8 ignore stop */ class LinkElements extends FRGatherer { - /** @type {LH.Gatherer.GathererMeta<'DevtoolsLog'>} */ - meta = { - supportedModes: ['timespan', 'navigation'], - dependencies: {DevtoolsLog: DevtoolsLog.symbol}, + constructor() { + super(); + /** @type {LH.Gatherer.GathererMeta<'DevtoolsLog'>} */ + this.meta = { + supportedModes: ['timespan', 'navigation'], + dependencies: {DevtoolsLog: DevtoolsLog.symbol}, + }; } /** From 94595270c3a0f298706094b97368d9f869c711f1 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Tue, 4 May 2021 13:53:29 -0400 Subject: [PATCH 12/17] update dt --- .../lighthouse/lighthouse-successful-run-expected.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt index ad9396418743..d14e079d6599 100644 --- a/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt +++ b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt @@ -89,6 +89,7 @@ Gathering in-page: SourceMaps Gathering in-page: FullPageScreenshot Gathering trace Gathering devtoolsLog & network records +Computing artifact: NetworkRecords Running afterPass methods Gathering: CSSUsage Gathering: JsUsage @@ -132,6 +133,7 @@ Loading page & waiting for onload Running pass methods Gathering in-page: ServiceWorker Gathering devtoolsLog & network records +Computing artifact: NetworkRecords Running afterPass methods Gathering: ServiceWorker Running redirectPass pass @@ -144,12 +146,12 @@ Loading page & waiting for onload Running pass methods Gathering in-page: HTTPRedirect Gathering devtoolsLog & network records +Computing artifact: NetworkRecords Running afterPass methods Gathering: HTTPRedirect Disconnecting from browser... Analyzing and running audits... Auditing: Uses HTTPS -Computing artifact: NetworkRecords Auditing: Redirects HTTP traffic to HTTPS Auditing: Registers a service worker that controls page and `start_url` Auditing: Has a `` tag with `width` or `initial-scale` From 36ebf93907cfa240d76714cdd8df4cffecb28af9 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Tue, 4 May 2021 14:00:19 -0400 Subject: [PATCH 13/17] rephrase error --- lighthouse-core/fraggle-rock/gather/base-gatherer.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lighthouse-core/fraggle-rock/gather/base-gatherer.js b/lighthouse-core/fraggle-rock/gather/base-gatherer.js index 32ce86e72cfb..901192beb9f9 100644 --- a/lighthouse-core/fraggle-rock/gather/base-gatherer.js +++ b/lighthouse-core/fraggle-rock/gather/base-gatherer.js @@ -90,8 +90,9 @@ class FRGatherer { * @return {Promise} */ async afterPass(passContext, loadData) { - // @ts-ignore Default meta type does not include dependencies. - if (this.meta.dependencies) throw Error('Legacy gatherer should not have dependencies.'); + if ('dependencies' in this.meta) { + throw Error('Gatherer with dependencies should override afterPass'); + } await this.stopSensitiveInstrumentation({...passContext, dependencies: {}}); await this.stopInstrumentation({...passContext, dependencies: {}}); return this.getArtifact({...passContext, dependencies: {}}); From 87ba41f8f8c945cbdb25818d7f9c12f9d7e9a2ae Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Tue, 4 May 2021 15:04:14 -0400 Subject: [PATCH 14/17] test cases --- .../fraggle-rock/gather/base-gatherer-test.js | 15 +++++++ .../gather/gatherers/link-elements-test.js | 40 +++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/lighthouse-core/test/fraggle-rock/gather/base-gatherer-test.js b/lighthouse-core/test/fraggle-rock/gather/base-gatherer-test.js index 8ea364bb74ab..9462ad5dbb6c 100644 --- a/lighthouse-core/test/fraggle-rock/gather/base-gatherer-test.js +++ b/lighthouse-core/test/fraggle-rock/gather/base-gatherer-test.js @@ -68,5 +68,20 @@ describe('BaseGatherer', () => { expect(gatherer.stopInstrumentation).toHaveBeenCalled(); expect(gatherer.stopSensitiveInstrumentation).toHaveBeenCalled(); }); + + it('throws if no override and has dependencies', async () => { + class MyGatherer extends Gatherer { + /** @type {LH.Gatherer.GathererMeta<'Trace'>} */ + meta = {supportedModes: ['timespan'], dependencies: {Trace: Symbol('Trace')}}; + stopInstrumentation = jest.fn(); + stopSensitiveInstrumentation = jest.fn(); + } + + const gatherer = new MyGatherer(); + const afterPassPromise = gatherer.afterPass(fakeParam, fakeParam); + await expect(afterPassPromise).rejects.toThrowError(/Gatherer with dependencies/); + expect(gatherer.stopInstrumentation).not.toHaveBeenCalled(); + expect(gatherer.stopSensitiveInstrumentation).not.toHaveBeenCalled(); + }); }); }); diff --git a/lighthouse-core/test/gather/gatherers/link-elements-test.js b/lighthouse-core/test/gather/gatherers/link-elements-test.js index 8dce0f4d0f37..1c5354dca6bb 100644 --- a/lighthouse-core/test/gather/gatherers/link-elements-test.js +++ b/lighthouse-core/test/gather/gatherers/link-elements-test.js @@ -8,6 +8,9 @@ /* eslint-env jest */ const LinkElements = require('../../../gather/gatherers/link-elements.js'); +const NetworkRecords = require('../../../computed/network-records.js'); + +jest.mock('../../../computed/network-records.js'); describe('Link Elements gatherer', () => { /** @@ -91,3 +94,40 @@ describe('Link Elements gatherer', () => { ]); }); }); + +describe('FR compat', () => { + /** @type {LinkElements} */ + let gatherer; + /** @type {any[]} */ + let networkRecords; + /** @type {any[]} */ + let devtoolsLog; + + beforeEach(() => { + networkRecords = ['1', '2']; + devtoolsLog = ['3', '4']; + gatherer = new LinkElements(); + gatherer._getArtifact = jest.fn(); + NetworkRecords.request = jest.fn().mockReturnValue(Promise.resolve(networkRecords)); + }); + + it('uses loadData in legacy mode', async () => { + const context = { + computedCache: new Map(), + dependencies: {}, + }; + await gatherer.afterPass(context, {networkRecords, devtoolsLog}); + expect(gatherer._getArtifact).toHaveBeenCalledWith(context, networkRecords); + expect(NetworkRecords.request).not.toHaveBeenCalled(); + }); + + it('uses dependency in FR', async () => { + const context = { + computedCache: new Map(), + dependencies: {DevtoolsLog: devtoolsLog}, + }; + await gatherer.getArtifact(context); + expect(gatherer._getArtifact).toHaveBeenCalledWith(context, networkRecords); + expect(NetworkRecords.request).toHaveBeenCalledWith(devtoolsLog, context); + }); +}); From b5ab80572322590729c07b81d95e224a293e7773 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Tue, 4 May 2021 15:06:20 -0400 Subject: [PATCH 15/17] comments --- lighthouse-core/gather/gatherers/link-elements.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lighthouse-core/gather/gatherers/link-elements.js b/lighthouse-core/gather/gatherers/link-elements.js index dbb30c8ff48f..a2561adaefcd 100644 --- a/lighthouse-core/gather/gatherers/link-elements.js +++ b/lighthouse-core/gather/gatherers/link-elements.js @@ -84,7 +84,11 @@ function getLinkElementsInDOM() { class LinkElements extends FRGatherer { constructor() { super(); - /** @type {LH.Gatherer.GathererMeta<'DevtoolsLog'>} */ + /** + * This needs to be in the constructor. + * https://github.com/GoogleChrome/lighthouse/issues/12134 + * @type {LH.Gatherer.GathererMeta<'DevtoolsLog'>} + */ this.meta = { supportedModes: ['timespan', 'navigation'], dependencies: {DevtoolsLog: DevtoolsLog.symbol}, @@ -164,7 +168,7 @@ class LinkElements extends FRGatherer { * @return {Promise} */ async afterPass(context, loadData) { - return await this._getArtifact({...context, dependencies: {}}, loadData.networkRecords); + return this._getArtifact({...context, dependencies: {}}, loadData.networkRecords); } /** @@ -173,7 +177,7 @@ class LinkElements extends FRGatherer { */ async getArtifact(context) { const records = await NetworkRecords.request(context.dependencies.DevtoolsLog, context); - return await this._getArtifact(context, records); + return this._getArtifact(context, records); } } From 0feb8f109ad5e026f05ad68aff48cd99ec4be67e Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Tue, 4 May 2021 15:12:25 -0400 Subject: [PATCH 16/17] add to fr config --- lighthouse-core/fraggle-rock/config/default-config.js | 3 +++ lighthouse-core/test/fraggle-rock/api-test-pptr.js | 4 ++-- types/artifacts.d.ts | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lighthouse-core/fraggle-rock/config/default-config.js b/lighthouse-core/fraggle-rock/config/default-config.js index 519b4f7d8c66..0e25922e7ae5 100644 --- a/lighthouse-core/fraggle-rock/config/default-config.js +++ b/lighthouse-core/fraggle-rock/config/default-config.js @@ -24,6 +24,7 @@ const artifacts = { GlobalListeners: '', IFrameElements: '', InstallabilityErrors: '', + LinkElements: '', MetaElements: '', NetworkUserAgent: '', PasswordInputsWithPreventedPaste: '', @@ -60,6 +61,7 @@ const defaultConfig = { {id: artifacts.GlobalListeners, gatherer: 'global-listeners'}, {id: artifacts.IFrameElements, gatherer: 'iframe-elements'}, {id: artifacts.InstallabilityErrors, gatherer: 'installability-errors'}, + {id: artifacts.LinkElements, gatherer: 'link-elements'}, {id: artifacts.MetaElements, gatherer: 'meta-elements'}, {id: artifacts.NetworkUserAgent, gatherer: 'network-user-agent'}, {id: artifacts.PasswordInputsWithPreventedPaste, gatherer: 'dobetterweb/password-inputs-with-prevented-paste'}, @@ -94,6 +96,7 @@ const defaultConfig = { artifacts.GlobalListeners, artifacts.IFrameElements, artifacts.InstallabilityErrors, + artifacts.LinkElements, artifacts.MetaElements, artifacts.NetworkUserAgent, artifacts.PasswordInputsWithPreventedPaste, diff --git a/lighthouse-core/test/fraggle-rock/api-test-pptr.js b/lighthouse-core/test/fraggle-rock/api-test-pptr.js index 0a74df8518ce..22e5a65bddac 100644 --- a/lighthouse-core/test/fraggle-rock/api-test-pptr.js +++ b/lighthouse-core/test/fraggle-rock/api-test-pptr.js @@ -121,7 +121,7 @@ describe('Fraggle Rock API', () => { const {auditResults, erroredAudits, failedAudits} = getAuditsBreakdown(lhr); // TODO(FR-COMPAT): This assertion can be removed when full compatibility is reached. - expect(auditResults.length).toMatchInlineSnapshot(`24`); + expect(auditResults.length).toMatchInlineSnapshot(`25`); expect(erroredAudits).toHaveLength(0); expect(failedAudits.map(audit => audit.id)).toContain('errors-in-console'); @@ -159,7 +159,7 @@ describe('Fraggle Rock API', () => { const {lhr} = result; const {auditResults, failedAudits, erroredAudits} = getAuditsBreakdown(lhr); // TODO(FR-COMPAT): This assertion can be removed when full compatibility is reached. - expect(auditResults.length).toMatchInlineSnapshot(`102`); + expect(auditResults.length).toMatchInlineSnapshot(`103`); expect(erroredAudits).toHaveLength(0); const failedAuditIds = failedAudits.map(audit => audit.id); diff --git a/types/artifacts.d.ts b/types/artifacts.d.ts index 8275fd809708..0b67cb9b9e67 100644 --- a/types/artifacts.d.ts +++ b/types/artifacts.d.ts @@ -28,7 +28,6 @@ declare global { | 'ImageElements' | 'InspectorIssues' | 'JsUsage' - | 'LinkElements' | 'MainDocumentContent' | 'Manifest' | 'MixedContent' From 5e4c5aab0a01afdde997aa97fe4b419b8ef1c5c9 Mon Sep 17 00:00:00 2001 From: Adam Raine Date: Tue, 11 May 2021 14:36:43 -0400 Subject: [PATCH 17/17] type --- lighthouse-core/test/gather/gatherers/css-usage-test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lighthouse-core/test/gather/gatherers/css-usage-test.js b/lighthouse-core/test/gather/gatherers/css-usage-test.js index b52c60dc7794..bc2a4f40eb6e 100644 --- a/lighthouse-core/test/gather/gatherers/css-usage-test.js +++ b/lighthouse-core/test/gather/gatherers/css-usage-test.js @@ -36,6 +36,7 @@ describe('.getArtifact', () => { driver: driver.asDriver(), url: 'https://example.com', gatherMode: 'snapshot', + computedCache: new Map(), dependencies: {}, }; const gatherer = new CSSUsage(); @@ -89,6 +90,7 @@ describe('.getArtifact', () => { driver: driver.asDriver(), url: 'https://example.com', gatherMode: 'snapshot', + computedCache: new Map(), dependencies: {}, }; const gatherer = new CSSUsage();