lighthouse 8.5.1-dev.20211012 → 8.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/report/flow.js +149 -0
- package/dist/report/standalone.js +228 -0
- package/flow-report/assets/styles.css +9 -272
- package/flow-report/jest.config.js +1 -1
- package/flow-report/src/app.tsx +9 -31
- package/flow-report/src/common.tsx +7 -86
- package/flow-report/src/icons.tsx +3 -20
- package/flow-report/src/sidebar/sidebar.tsx +16 -11
- package/flow-report/src/summary/category.tsx +24 -42
- package/flow-report/src/summary/summary.tsx +29 -32
- package/flow-report/src/topbar.tsx +4 -54
- package/flow-report/src/util.ts +1 -26
- package/flow-report/src/wrappers/report-renderer.tsx +1 -1
- package/flow-report/src/wrappers/report.tsx +21 -6
- package/flow-report/test/app-test.tsx +13 -17
- package/flow-report/test/setup/env-setup.ts +0 -1
- package/flow-report/test/sidebar/flow-test.tsx +12 -6
- package/flow-report/test/sidebar/sidebar-test.tsx +13 -7
- package/flow-report/test/summary/category-test.tsx +34 -79
- package/flow-report/test/summary/summary-test.tsx +17 -11
- package/flow-report/test/util-test.tsx +12 -1
- package/flow-report/tsconfig.json +0 -1
- package/flow-report/types/flow-report.d.ts +1 -2
- package/jest.config.js +15 -1
- package/lighthouse-cli/bin.js +0 -5
- package/lighthouse-cli/cli-flags.js +3 -10
- package/lighthouse-cli/commands/commands.js +0 -1
- package/lighthouse-cli/run.js +2 -2
- package/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +0 -0
- package/lighthouse-cli/test/smokehouse/report-assert.js +4 -20
- package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +1 -2
- package/lighthouse-core/audits/byte-efficiency/unused-javascript.js +1 -1
- package/lighthouse-core/audits/seo/crawlable-anchors.js +12 -10
- package/lighthouse-core/computed/js-bundles.js +2 -1
- package/lighthouse-core/computed/unused-javascript-summary.js +3 -3
- package/lighthouse-core/config/config.js +2 -2
- package/lighthouse-core/config/default-config.js +0 -5
- package/lighthouse-core/fraggle-rock/api.js +0 -10
- package/lighthouse-core/fraggle-rock/config/filters.js +3 -22
- package/lighthouse-core/fraggle-rock/gather/driver.js +0 -4
- package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +2 -2
- package/lighthouse-core/fraggle-rock/user-flow.js +6 -35
- package/lighthouse-core/gather/driver/navigation.js +0 -5
- package/lighthouse-core/gather/driver/prepare.js +0 -14
- package/lighthouse-core/gather/driver/storage.js +0 -5
- package/lighthouse-core/gather/gather-runner.js +2 -2
- package/lighthouse-core/gather/gatherers/dobetterweb/response-compression.js +1 -5
- package/lighthouse-core/gather/gatherers/full-page-screenshot.js +24 -30
- package/{shared/localization/i18n-module.js → lighthouse-core/lib/cdt/Common.js} +8 -3
- package/lighthouse-core/lib/cdt/SDK.js +123 -3
- package/lighthouse-core/lib/cdt/generated/SourceMap.js +312 -148
- package/lighthouse-core/lib/csp-evaluator.js +1 -2
- package/lighthouse-core/lib/i18n/README.md +6 -6
- package/lighthouse-core/lib/i18n/i18n.js +342 -9
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/ar-XB.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/ar.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/bg.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/ca.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/cs.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/da.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/de.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/el.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/en-GB.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/en-US.json +0 -111
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/en-XA.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/en-XL.json +0 -111
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/es-419.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/es.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/fi.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/fil.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/fr.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/he.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/hi.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/hr.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/hu.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/id.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/it.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/ja.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/ko.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/lt.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/lv.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/nl.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/no.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/pl.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/pt-PT.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/pt.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/ro.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/ru.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/sk.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/sl.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/sr-Latn.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/sr.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/sv.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/ta.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/te.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/th.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/tr.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/uk.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/vi.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/zh-HK.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/zh-TW.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales/zh.json +0 -0
- package/{shared/localization → lighthouse-core/lib/i18n}/locales.js +1 -2
- package/{shared/localization → lighthouse-core/lib/i18n}/swap-locale.js +7 -9
- package/lighthouse-core/lib/page-functions.js +4 -4
- package/lighthouse-core/lib/stack-packs.js +13 -1
- package/{shared → lighthouse-core/lib}/type-verifiers.js +0 -0
- package/lighthouse-core/runner.js +6 -6
- package/lighthouse-core/scripts/manual-chrome-launcher.js +1 -4
- package/lighthouse-core/util-commonjs.js +4 -20
- package/package.json +16 -19
- package/readme.md +1 -1
- package/report/assets/standalone-template.html +1 -0
- package/report/assets/styles.css +41 -16
- package/report/assets/templates.html +4 -42
- package/report/clients/psi.js +0 -1
- package/report/clients/standalone.js +2 -1
- package/report/generator/file-namer.js +8 -17
- package/report/generator/report-generator.js +1 -0
- package/report/renderer/category-renderer.js +16 -4
- package/report/renderer/components.js +71 -107
- package/report/renderer/dom.js +0 -19
- package/report/renderer/logger.js +2 -35
- package/report/renderer/performance-category-renderer.js +21 -23
- package/report/renderer/pwa-category-renderer.js +2 -1
- package/report/renderer/report-renderer.js +0 -21
- package/report/renderer/report-ui-features.js +19 -7
- package/report/renderer/util.js +4 -20
- package/report/test/clients/psi-test.js +4 -0
- package/report/test/generator/file-namer-test.js +2 -2
- package/report/test/renderer/category-renderer-test.js +1 -1
- package/report/test/renderer/performance-category-renderer-test.js +0 -12
- package/report/test/renderer/report-renderer-test.js +55 -0
- package/report/test/renderer/util-test.js +8 -68
- package/report/test-assets/faux-psi-template.html +1 -0
- package/report/tsconfig.json +1 -2
- package/report/types/html-renderer.d.ts +1 -2
- package/root.js +0 -18
- package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +3 -5
- package/third-party/chromium-synchronization/installability-errors-test.js +1 -2
- package/tsconfig-all.json +0 -1
- package/tsconfig-base.json +1 -1
- package/tsconfig.json +3 -2
- package/types/config.d.ts +0 -1
- package/types/externs.d.ts +0 -2
- package/types/lhr/flow.d.ts +0 -7
- package/types/lhr/i18n.d.ts +3 -0
- package/changelog.md +0 -5395
- package/flow-report/.eslintrc.cjs +0 -49
- package/flow-report/package.json +0 -4
- package/flow-report/src/header.tsx +0 -88
- package/flow-report/src/help-dialog.tsx +0 -120
- package/flow-report/src/i18n/i18n.tsx +0 -44
- package/flow-report/src/i18n/localized-strings.js +0 -11
- package/flow-report/src/i18n/ui-strings.js +0 -86
- package/flow-report/test/common-test.tsx +0 -89
- package/flow-report/test/header-test.tsx +0 -55
- package/flow-report/test/sample-flow.ts +0 -17
- package/flow-report/test/topbar-test.tsx +0 -68
- package/lighthouse-cli/commands/list-locales.js +0 -16
- package/lighthouse-core/lib/cdt/Platform.js +0 -55
- package/lighthouse-core/scripts/package.json +0 -4
- package/report/renderer/swap-locale-feature.js +0 -82
- package/report/test/renderer/report-renderer-axe-test.js +0 -86
- package/shared/localization/format.js +0 -422
- package/shared/localization/swap-flow-locale.js +0 -20
- package/shared/test/localization/format-test.js +0 -377
- package/shared/test/localization/locales-test.js +0 -47
- package/shared/test/localization/swap-locale-test.js +0 -140
- package/shared/tsconfig.json +0 -22
- package/shared/types/shared.d.ts +0 -24
- package/types/es-main.d.ts +0 -18
|
@@ -162,23 +162,6 @@ function filterAuditsByGatherMode(audits, mode) {
|
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
/**
|
|
166
|
-
* Optional `supportedModes` property can explicitly exclude a category even if some audits are available.
|
|
167
|
-
*
|
|
168
|
-
* @param {LH.Config.Config['categories']} categories
|
|
169
|
-
* @param {LH.Gatherer.GatherMode} mode
|
|
170
|
-
* @return {LH.Config.Config['categories']}
|
|
171
|
-
*/
|
|
172
|
-
function filterCategoriesByGatherMode(categories, mode) {
|
|
173
|
-
if (!categories) return null;
|
|
174
|
-
|
|
175
|
-
const categoriesToKeep = Object.entries(categories)
|
|
176
|
-
.filter(([_, category]) => {
|
|
177
|
-
return !category.supportedModes || category.supportedModes.includes(mode);
|
|
178
|
-
});
|
|
179
|
-
return Object.fromEntries(categoriesToKeep);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
165
|
/**
|
|
183
166
|
* Filters a categories object and their auditRefs down to the specified category ids.
|
|
184
167
|
*
|
|
@@ -242,10 +225,9 @@ function filterCategoriesByAvailableAudits(categories, availableAudits) {
|
|
|
242
225
|
*/
|
|
243
226
|
function filterConfigByGatherMode(config, mode) {
|
|
244
227
|
const artifacts = filterArtifactsByGatherMode(config.artifacts, mode);
|
|
245
|
-
const
|
|
246
|
-
const audits =
|
|
247
|
-
const
|
|
248
|
-
const categories = filterCategoriesByAvailableAudits(supportedCategories, audits || []);
|
|
228
|
+
const availableAudits = filterAuditsByAvailableArtifacts(config.audits, artifacts || []);
|
|
229
|
+
const audits = filterAuditsByGatherMode(availableAudits, mode);
|
|
230
|
+
const categories = filterCategoriesByAvailableAudits(config.categories, audits || []);
|
|
249
231
|
|
|
250
232
|
return {
|
|
251
233
|
...config,
|
|
@@ -309,5 +291,4 @@ module.exports = {
|
|
|
309
291
|
filterAuditsByGatherMode,
|
|
310
292
|
filterCategoriesByAvailableAudits,
|
|
311
293
|
filterCategoriesByExplicitFilters,
|
|
312
|
-
filterCategoriesByGatherMode,
|
|
313
294
|
};
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
const log = require('lighthouse-logger');
|
|
9
8
|
const ProtocolSession = require('./session.js');
|
|
10
9
|
const ExecutionContext = require('../../gather/driver/execution-context.js');
|
|
11
10
|
const Fetcher = require('../../gather/fetcher.js');
|
|
@@ -69,13 +68,10 @@ class Driver {
|
|
|
69
68
|
/** @return {Promise<void>} */
|
|
70
69
|
async connect() {
|
|
71
70
|
if (this._session) return;
|
|
72
|
-
const status = {msg: 'Connecting to browser', id: 'lh:driver:connect'};
|
|
73
|
-
log.time(status);
|
|
74
71
|
const session = await this._page.target().createCDPSession();
|
|
75
72
|
this._session = this.defaultSession = new ProtocolSession(session);
|
|
76
73
|
this._executionContext = new ExecutionContext(this._session);
|
|
77
74
|
this._fetcher = new Fetcher(this._session, this._executionContext);
|
|
78
|
-
log.timeEnd(status);
|
|
79
75
|
}
|
|
80
76
|
|
|
81
77
|
/** @return {Promise<void>} */
|
|
@@ -20,7 +20,7 @@ const emulation = require('../../lib/emulation.js');
|
|
|
20
20
|
const {defaultNavigationConfig} = require('../../config/constants.js');
|
|
21
21
|
const {initializeConfig} = require('../config/config.js');
|
|
22
22
|
const {getBaseArtifacts, finalizeArtifacts} = require('./base-artifacts.js');
|
|
23
|
-
const
|
|
23
|
+
const i18n = require('../../lib/i18n/i18n.js');
|
|
24
24
|
const LighthouseError = require('../../lib/lh-error.js');
|
|
25
25
|
const {getPageLoadError} = require('../../lib/navigation-error.js');
|
|
26
26
|
const Trace = require('../../gather/gatherers/trace.js');
|
|
@@ -165,7 +165,7 @@ async function _computeNavigationResult(
|
|
|
165
165
|
|
|
166
166
|
if (pageLoadError) {
|
|
167
167
|
const locale = navigationContext.config.settings.locale;
|
|
168
|
-
const localizedMessage =
|
|
168
|
+
const localizedMessage = i18n.getFormatted(pageLoadError.friendlyMessage, locale);
|
|
169
169
|
log.error('NavigationRunner', localizedMessage, navigationContext.requestedUrl);
|
|
170
170
|
|
|
171
171
|
/** @type {Partial<LH.GathererArtifacts>} */
|
|
@@ -6,13 +6,11 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const {generateFlowReportHtml} = require('../../report/generator/report-generator.js');
|
|
9
|
-
const {snapshot} = require('./
|
|
10
|
-
const {startTimespan} = require('./gather/timespan-runner.js');
|
|
11
|
-
const {navigation} = require('./gather/navigation-runner.js');
|
|
9
|
+
const {navigation, startTimespan, snapshot} = require('./api.js');
|
|
12
10
|
|
|
13
11
|
/** @typedef {Parameters<snapshot>[0]} FrOptions */
|
|
14
|
-
/** @typedef {Omit<FrOptions, 'page'>
|
|
15
|
-
/** @typedef {
|
|
12
|
+
/** @typedef {Omit<FrOptions, 'page'>} UserFlowOptions */
|
|
13
|
+
/** @typedef {UserFlowOptions & {stepName?: string}} StepOptions */
|
|
16
14
|
|
|
17
15
|
class UserFlow {
|
|
18
16
|
/**
|
|
@@ -22,8 +20,6 @@ class UserFlow {
|
|
|
22
20
|
constructor(page, options) {
|
|
23
21
|
/** @type {FrOptions} */
|
|
24
22
|
this.options = {page, ...options};
|
|
25
|
-
/** @type {string|undefined} */
|
|
26
|
-
this.name = options && options.name;
|
|
27
23
|
/** @type {LH.FlowResult.Step[]} */
|
|
28
24
|
this.steps = [];
|
|
29
25
|
}
|
|
@@ -53,29 +49,6 @@ class UserFlow {
|
|
|
53
49
|
}
|
|
54
50
|
}
|
|
55
51
|
|
|
56
|
-
/**
|
|
57
|
-
* @param {string} url
|
|
58
|
-
* @param {StepOptions=} stepOptions
|
|
59
|
-
*/
|
|
60
|
-
_getNextNavigationOptions(url, stepOptions) {
|
|
61
|
-
const options = {url, ...this.options, ...stepOptions};
|
|
62
|
-
|
|
63
|
-
// On repeat navigations, we want to disable storage reset by default (i.e. it's not a cold load).
|
|
64
|
-
const isSubsequentNavigation = this.steps.some(step => step.lhr.gatherMode === 'navigation');
|
|
65
|
-
if (isSubsequentNavigation) {
|
|
66
|
-
const configContext = {...options.configContext};
|
|
67
|
-
const settingsOverrides = {...configContext.settingsOverrides};
|
|
68
|
-
if (settingsOverrides.disableStorageReset === undefined) {
|
|
69
|
-
settingsOverrides.disableStorageReset = true;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
configContext.settingsOverrides = settingsOverrides;
|
|
73
|
-
options.configContext = configContext;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return options;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
52
|
/**
|
|
80
53
|
* @param {string} url
|
|
81
54
|
* @param {StepOptions=} stepOptions
|
|
@@ -83,7 +56,8 @@ class UserFlow {
|
|
|
83
56
|
async navigate(url, stepOptions) {
|
|
84
57
|
if (this.currentTimespan) throw Error('Timespan already in progress');
|
|
85
58
|
|
|
86
|
-
const
|
|
59
|
+
const options = {url, ...this.options, ...stepOptions};
|
|
60
|
+
const result = await navigation(options);
|
|
87
61
|
if (!result) throw Error('Navigation returned undefined');
|
|
88
62
|
|
|
89
63
|
const providedName = stepOptions && stepOptions.stepName;
|
|
@@ -146,10 +120,7 @@ class UserFlow {
|
|
|
146
120
|
* @return {LH.FlowResult}
|
|
147
121
|
*/
|
|
148
122
|
getFlowResult() {
|
|
149
|
-
|
|
150
|
-
const url = new URL(this.steps[0].lhr.finalUrl);
|
|
151
|
-
const name = this.name || `User flow (${url.hostname})`;
|
|
152
|
-
return {steps: this.steps, name};
|
|
123
|
+
return {steps: this.steps};
|
|
153
124
|
}
|
|
154
125
|
|
|
155
126
|
/**
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
const log = require('lighthouse-logger');
|
|
9
8
|
const NetworkMonitor = require('./network-monitor.js');
|
|
10
9
|
const {waitForFullyLoaded, waitForFrameNavigated, waitForUserToContinue} = require('./wait-for-condition.js'); // eslint-disable-line max-len
|
|
11
10
|
const constants = require('../../config/constants.js');
|
|
@@ -83,9 +82,6 @@ function resolveWaitForFullyLoadedOptions(options) {
|
|
|
83
82
|
* @return {Promise<{finalUrl: string, warnings: Array<LH.IcuMessage>}>}
|
|
84
83
|
*/
|
|
85
84
|
async function gotoURL(driver, url, options) {
|
|
86
|
-
const status = {msg: `Navigating to ${url}`, id: 'lh:driver:navigate'};
|
|
87
|
-
log.time(status);
|
|
88
|
-
|
|
89
85
|
const session = driver.defaultSession;
|
|
90
86
|
const networkMonitor = new NetworkMonitor(driver.defaultSession);
|
|
91
87
|
|
|
@@ -129,7 +125,6 @@ async function gotoURL(driver, url, options) {
|
|
|
129
125
|
await waitForUserToContinue(driver);
|
|
130
126
|
}
|
|
131
127
|
|
|
132
|
-
log.timeEnd(status);
|
|
133
128
|
return {
|
|
134
129
|
finalUrl,
|
|
135
130
|
warnings: getNavigationWarnings({timedOut, finalUrl, requestedUrl: url}),
|
|
@@ -142,16 +142,11 @@ async function prepareDeviceEmulationAndAsyncStacks(driver, settings) {
|
|
|
142
142
|
* @param {LH.Config.Settings} settings
|
|
143
143
|
*/
|
|
144
144
|
async function prepareTargetForTimespanMode(driver, settings) {
|
|
145
|
-
const status = {msg: 'Preparing target for timespan mode', id: 'lh:prepare:timespanMode'};
|
|
146
|
-
log.time(status);
|
|
147
|
-
|
|
148
145
|
await prepareDeviceEmulationAndAsyncStacks(driver, settings);
|
|
149
146
|
await prepareThrottlingAndNetwork(driver.defaultSession, settings, {
|
|
150
147
|
disableThrottling: false,
|
|
151
148
|
blockedUrlPatterns: undefined,
|
|
152
149
|
});
|
|
153
|
-
|
|
154
|
-
log.timeEnd(status);
|
|
155
150
|
}
|
|
156
151
|
|
|
157
152
|
/**
|
|
@@ -164,9 +159,6 @@ async function prepareTargetForTimespanMode(driver, settings) {
|
|
|
164
159
|
* @param {LH.Config.Settings} settings
|
|
165
160
|
*/
|
|
166
161
|
async function prepareTargetForNavigationMode(driver, settings) {
|
|
167
|
-
const status = {msg: 'Preparing target for navigation mode', id: 'lh:prepare:navigationMode'};
|
|
168
|
-
log.time(status);
|
|
169
|
-
|
|
170
162
|
await prepareDeviceEmulationAndAsyncStacks(driver, settings);
|
|
171
163
|
|
|
172
164
|
// Automatically handle any JavaScript dialogs to prevent a hung renderer.
|
|
@@ -179,8 +171,6 @@ async function prepareTargetForNavigationMode(driver, settings) {
|
|
|
179
171
|
if (settings.throttlingMethod === 'simulate') {
|
|
180
172
|
await shimRequestIdleCallbackOnNewDocument(driver, settings);
|
|
181
173
|
}
|
|
182
|
-
|
|
183
|
-
log.timeEnd(status);
|
|
184
174
|
}
|
|
185
175
|
|
|
186
176
|
/**
|
|
@@ -194,9 +184,6 @@ async function prepareTargetForNavigationMode(driver, settings) {
|
|
|
194
184
|
* @return {Promise<{warnings: Array<LH.IcuMessage>}>}
|
|
195
185
|
*/
|
|
196
186
|
async function prepareTargetForIndividualNavigation(session, settings, navigation) {
|
|
197
|
-
const status = {msg: 'Preparing target for navigation', id: 'lh:prepare:navigation'};
|
|
198
|
-
log.time(status);
|
|
199
|
-
|
|
200
187
|
/** @type {Array<LH.IcuMessage>} */
|
|
201
188
|
const warnings = [];
|
|
202
189
|
|
|
@@ -208,7 +195,6 @@ async function prepareTargetForIndividualNavigation(session, settings, navigatio
|
|
|
208
195
|
|
|
209
196
|
await prepareThrottlingAndNetwork(session, settings, navigation);
|
|
210
197
|
|
|
211
|
-
log.timeEnd(status);
|
|
212
198
|
return {warnings};
|
|
213
199
|
}
|
|
214
200
|
|
|
@@ -33,9 +33,6 @@ const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
|
|
|
33
33
|
* @return {Promise<void>}
|
|
34
34
|
*/
|
|
35
35
|
async function clearDataForOrigin(session, url) {
|
|
36
|
-
const status = {msg: 'Cleaning origin data', id: 'lh:storage:clearDataForOrigin'};
|
|
37
|
-
log.time(status);
|
|
38
|
-
|
|
39
36
|
const origin = new URL(url).origin;
|
|
40
37
|
|
|
41
38
|
// Clear some types of storage.
|
|
@@ -66,8 +63,6 @@ async function clearDataForOrigin(session, url) {
|
|
|
66
63
|
} else {
|
|
67
64
|
throw err;
|
|
68
65
|
}
|
|
69
|
-
} finally {
|
|
70
|
-
log.timeEnd(status);
|
|
71
66
|
}
|
|
72
67
|
}
|
|
73
68
|
|
|
@@ -10,7 +10,7 @@ const NetworkRecords = require('../computed/network-records.js');
|
|
|
10
10
|
const {getPageLoadError} = require('../lib/navigation-error.js');
|
|
11
11
|
const emulation = require('../lib/emulation.js');
|
|
12
12
|
const constants = require('../config/constants.js');
|
|
13
|
-
const
|
|
13
|
+
const i18n = require('../lib/i18n/i18n.js');
|
|
14
14
|
const {getBenchmarkIndex, getEnvironmentWarnings} = require('./driver/environment.js');
|
|
15
15
|
const prepare = require('./driver/prepare.js');
|
|
16
16
|
const storage = require('./driver/storage.js');
|
|
@@ -574,7 +574,7 @@ class GatherRunner {
|
|
|
574
574
|
networkRecords: loadData.networkRecords,
|
|
575
575
|
});
|
|
576
576
|
if (pageLoadError) {
|
|
577
|
-
const localizedMessage =
|
|
577
|
+
const localizedMessage = i18n.getFormatted(pageLoadError.friendlyMessage,
|
|
578
578
|
passContext.settings.locale);
|
|
579
579
|
log.error('GatherRunner', localizedMessage, passContext.url);
|
|
580
580
|
|
|
@@ -20,11 +20,7 @@ const {fetchResponseBodyFromCache} = require('../../driver/network.js');
|
|
|
20
20
|
const NetworkRecords = require('../../../computed/network-records.js');
|
|
21
21
|
|
|
22
22
|
const CHROME_EXTENSION_PROTOCOL = 'chrome-extension:';
|
|
23
|
-
const compressionHeaders = [
|
|
24
|
-
'content-encoding',
|
|
25
|
-
'x-original-content-encoding',
|
|
26
|
-
'x-content-encoding-over-network',
|
|
27
|
-
];
|
|
23
|
+
const compressionHeaders = ['content-encoding', 'x-original-content-encoding'];
|
|
28
24
|
const compressionTypes = ['gzip', 'br', 'deflate'];
|
|
29
25
|
const binaryMimeTypes = ['image', 'audio', 'video'];
|
|
30
26
|
/** @type {LH.Crdp.Network.ResourceType[]} */
|
|
@@ -22,26 +22,6 @@ function snakeCaseToCamelCase(str) {
|
|
|
22
22
|
return str.replace(/(-\w)/g, m => m[1].toUpperCase());
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/* c8 ignore start */
|
|
26
|
-
|
|
27
|
-
// eslint-disable-next-line no-inner-declarations
|
|
28
|
-
function getObservedDeviceMetrics() {
|
|
29
|
-
// Convert the Web API's snake case (landscape-primary) to camel case (landscapePrimary).
|
|
30
|
-
const screenOrientationType = /** @type {LH.Crdp.Emulation.ScreenOrientationType} */ (
|
|
31
|
-
snakeCaseToCamelCase(window.screen.orientation.type));
|
|
32
|
-
return {
|
|
33
|
-
width: document.documentElement.clientWidth,
|
|
34
|
-
height: document.documentElement.clientHeight,
|
|
35
|
-
screenOrientation: {
|
|
36
|
-
type: screenOrientationType,
|
|
37
|
-
angle: window.screen.orientation.angle,
|
|
38
|
-
},
|
|
39
|
-
deviceScaleFactor: window.devicePixelRatio,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/* c8 ignore stop */
|
|
44
|
-
|
|
45
25
|
class FullPageScreenshot extends FRGatherer {
|
|
46
26
|
/** @type {LH.Gatherer.GathererMeta} */
|
|
47
27
|
meta = {
|
|
@@ -160,17 +140,9 @@ class FullPageScreenshot extends FRGatherer {
|
|
|
160
140
|
const executionContext = context.driver.executionContext;
|
|
161
141
|
const settings = context.settings;
|
|
162
142
|
|
|
163
|
-
// In case some other program is controlling emulation, remember what the device looks
|
|
143
|
+
// In case some other program is controlling emulation, try to remember what the device looks
|
|
164
144
|
// like now and reset after gatherer is done.
|
|
165
|
-
let observedDeviceMetrics;
|
|
166
145
|
const lighthouseControlsEmulation = !settings.screenEmulation.disabled;
|
|
167
|
-
if (!lighthouseControlsEmulation) {
|
|
168
|
-
observedDeviceMetrics = await executionContext.evaluate(getObservedDeviceMetrics, {
|
|
169
|
-
args: [],
|
|
170
|
-
useIsolation: true,
|
|
171
|
-
deps: [snakeCaseToCamelCase],
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
146
|
|
|
175
147
|
try {
|
|
176
148
|
return {
|
|
@@ -181,7 +153,7 @@ class FullPageScreenshot extends FRGatherer {
|
|
|
181
153
|
// Revert resized page.
|
|
182
154
|
if (lighthouseControlsEmulation) {
|
|
183
155
|
await emulation.emulate(session, settings);
|
|
184
|
-
} else
|
|
156
|
+
} else {
|
|
185
157
|
// Best effort to reset emulation to what it was.
|
|
186
158
|
// https://github.com/GoogleChrome/lighthouse/pull/10716#discussion_r428970681
|
|
187
159
|
// TODO: seems like this would be brittle. Should at least work for devtools, but what
|
|
@@ -189,6 +161,28 @@ class FullPageScreenshot extends FRGatherer {
|
|
|
189
161
|
// in the LH runner api, which for ex. puppeteer consumers would setup puppeteer emulation,
|
|
190
162
|
// and then just call that to reset?
|
|
191
163
|
// https://github.com/GoogleChrome/lighthouse/issues/11122
|
|
164
|
+
|
|
165
|
+
// eslint-disable-next-line no-inner-declarations
|
|
166
|
+
function getObservedDeviceMetrics() {
|
|
167
|
+
// Convert the Web API's snake case (landscape-primary) to camel case (landscapePrimary).
|
|
168
|
+
const screenOrientationType = /** @type {LH.Crdp.Emulation.ScreenOrientationType} */ (
|
|
169
|
+
snakeCaseToCamelCase(window.screen.orientation.type));
|
|
170
|
+
return {
|
|
171
|
+
width: document.documentElement.clientWidth,
|
|
172
|
+
height: document.documentElement.clientHeight,
|
|
173
|
+
screenOrientation: {
|
|
174
|
+
type: screenOrientationType,
|
|
175
|
+
angle: window.screen.orientation.angle,
|
|
176
|
+
},
|
|
177
|
+
deviceScaleFactor: window.devicePixelRatio,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const observedDeviceMetrics = await executionContext.evaluate(getObservedDeviceMetrics, {
|
|
182
|
+
args: [],
|
|
183
|
+
useIsolation: true,
|
|
184
|
+
deps: [snakeCaseToCamelCase],
|
|
185
|
+
});
|
|
192
186
|
await session.sendCommand('Emulation.setDeviceMetricsOverride', {
|
|
193
187
|
mobile: settings.formFactor === 'mobile',
|
|
194
188
|
...observedDeviceMetrics,
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright
|
|
2
|
+
* @license Copyright 2020 The Lighthouse Authors. All Rights Reserved.
|
|
3
3
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
4
4
|
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
/** @fileoverview Needed for the generated/SourceMap.js file */
|
|
9
|
+
|
|
10
|
+
const Common = {
|
|
11
|
+
console,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
module.exports = Common;
|
|
@@ -4,25 +4,145 @@
|
|
|
4
4
|
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
|
+
|
|
7
8
|
const SDK = {
|
|
8
9
|
TextSourceMap: require('./generated/SourceMap.js'),
|
|
9
10
|
};
|
|
10
11
|
|
|
12
|
+
/**
|
|
13
|
+
* CDT pollutes Array.prototype w/ `lowerBound/upperBound`. SourceMap
|
|
14
|
+
* relies on this, but only for a couple method return values. To avoid global pollution,
|
|
15
|
+
* we explicitly set the extension functions on the return values.
|
|
16
|
+
*
|
|
17
|
+
* @param {unknown[]} array
|
|
18
|
+
*/
|
|
19
|
+
function extendArray(array) {
|
|
20
|
+
// @ts-expect-error
|
|
21
|
+
if (array.lowerBound) return;
|
|
22
|
+
|
|
23
|
+
// @ts-expect-error
|
|
24
|
+
array.lowerBound = lowerBound.bind(array);
|
|
25
|
+
// @ts-expect-error
|
|
26
|
+
array.upperBound = upperBound.bind(array);
|
|
27
|
+
|
|
28
|
+
array.slice = function(start, end) {
|
|
29
|
+
const retVal = Array.prototype.slice.call(array, start, end);
|
|
30
|
+
extendArray(retVal);
|
|
31
|
+
return retVal;
|
|
32
|
+
};
|
|
33
|
+
// @ts-expect-error
|
|
34
|
+
array.filter = function(fn) {
|
|
35
|
+
const retVal = Array.prototype.filter.call(array, fn);
|
|
36
|
+
extendArray(retVal);
|
|
37
|
+
return retVal;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const originalMappings = SDK.TextSourceMap.prototype.mappings;
|
|
42
|
+
SDK.TextSourceMap.prototype.mappings = function() {
|
|
43
|
+
const mappings = originalMappings.call(this);
|
|
44
|
+
extendArray(mappings);
|
|
45
|
+
return mappings;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const originalReversedMappings = SDK.TextSourceMap.prototype._reversedMappings;
|
|
49
|
+
/** @param {string} sourceURL */
|
|
50
|
+
SDK.TextSourceMap.prototype._reversedMappings = function(sourceURL) {
|
|
51
|
+
const mappings = originalReversedMappings.call(this, sourceURL);
|
|
52
|
+
extendArray(mappings);
|
|
53
|
+
return mappings;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* `upperBound` and `lowerBound` are copied from CDT utilities.js.
|
|
58
|
+
* These are the only methods needed from that file.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Return index of the leftmost element that is greater
|
|
63
|
+
* than the specimen object. If there's no such element (i.e. all
|
|
64
|
+
* elements are smaller or equal to the specimen) returns right bound.
|
|
65
|
+
* The function works for sorted array.
|
|
66
|
+
* When specified, |left| (inclusive) and |right| (exclusive) indices
|
|
67
|
+
* define the search window.
|
|
68
|
+
*
|
|
69
|
+
* @param {!T} object
|
|
70
|
+
* @param {function(!T,!S):number=} comparator
|
|
71
|
+
* @param {number=} left
|
|
72
|
+
* @param {number=} right
|
|
73
|
+
* @return {number}
|
|
74
|
+
* @this {Array.<!S>}
|
|
75
|
+
* @template T,S
|
|
76
|
+
*/
|
|
77
|
+
function upperBound(object, comparator, left, right) {
|
|
78
|
+
// @ts-expect-error
|
|
79
|
+
function defaultComparator(a, b) {
|
|
80
|
+
return a < b ? -1 : (a > b ? 1 : 0);
|
|
81
|
+
}
|
|
82
|
+
comparator = comparator || defaultComparator;
|
|
83
|
+
let l = left || 0;
|
|
84
|
+
let r = right !== undefined ? right : this.length;
|
|
85
|
+
while (l < r) {
|
|
86
|
+
const m = (l + r) >> 1;
|
|
87
|
+
if (comparator(object, this[m]) >= 0) {
|
|
88
|
+
l = m + 1;
|
|
89
|
+
} else {
|
|
90
|
+
r = m;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return r;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Return index of the leftmost element that is equal or greater
|
|
98
|
+
* than the specimen object. If there's no such element (i.e. all
|
|
99
|
+
* elements are smaller than the specimen) returns right bound.
|
|
100
|
+
* The function works for sorted array.
|
|
101
|
+
* When specified, |left| (inclusive) and |right| (exclusive) indices
|
|
102
|
+
* define the search window.
|
|
103
|
+
*
|
|
104
|
+
* @param {!T} object
|
|
105
|
+
* @param {function(!T,!S):number=} comparator
|
|
106
|
+
* @param {number=} left
|
|
107
|
+
* @param {number=} right
|
|
108
|
+
* @return {number}
|
|
109
|
+
* @this {Array.<!S>}
|
|
110
|
+
* @template T,S
|
|
111
|
+
*/
|
|
112
|
+
function lowerBound(object, comparator, left, right) {
|
|
113
|
+
// @ts-expect-error
|
|
114
|
+
function defaultComparator(a, b) {
|
|
115
|
+
return a < b ? -1 : (a > b ? 1 : 0);
|
|
116
|
+
}
|
|
117
|
+
comparator = comparator || defaultComparator;
|
|
118
|
+
let l = left || 0;
|
|
119
|
+
let r = right !== undefined ? right : this.length;
|
|
120
|
+
while (l < r) {
|
|
121
|
+
const m = (l + r) >> 1;
|
|
122
|
+
if (comparator(object, this[m]) > 0) {
|
|
123
|
+
l = m + 1;
|
|
124
|
+
} else {
|
|
125
|
+
r = m;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return r;
|
|
129
|
+
}
|
|
130
|
+
|
|
11
131
|
// Add `lastColumnNumber` to mappings. This will eventually be added to CDT.
|
|
12
132
|
// @ts-expect-error
|
|
13
133
|
SDK.TextSourceMap.prototype.computeLastGeneratedColumns = function() {
|
|
14
134
|
const mappings = this.mappings();
|
|
15
|
-
|
|
135
|
+
// @ts-expect-error: `lastColumnNumber` is not on types yet.
|
|
136
|
+
if (mappings.length && typeof mappings[0].lastColumnNumber !== 'undefined') return;
|
|
16
137
|
|
|
17
138
|
for (let i = 0; i < mappings.length - 1; i++) {
|
|
18
139
|
const mapping = mappings[i];
|
|
19
140
|
const nextMapping = mappings[i + 1];
|
|
20
141
|
if (mapping.lineNumber === nextMapping.lineNumber) {
|
|
142
|
+
// @ts-expect-error: `lastColumnNumber` is not on types yet.
|
|
21
143
|
mapping.lastColumnNumber = nextMapping.columnNumber;
|
|
22
144
|
}
|
|
23
145
|
}
|
|
24
|
-
|
|
25
|
-
// Now, all but the last mapping on each line will have 'lastColumnNumber' set to a number.
|
|
26
146
|
};
|
|
27
147
|
|
|
28
148
|
module.exports = SDK;
|