lighthouse 8.6.0 → 9.0.0
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/bundle.esm.js +5994 -0
- package/dist/report/flow.js +30 -13
- package/dist/report/standalone.js +41 -35
- package/flow-report/.eslintrc.cjs +2 -0
- package/flow-report/assets/standalone-flow-template.html +3 -2
- package/flow-report/assets/styles.css +108 -31
- package/flow-report/src/app.tsx +18 -18
- package/flow-report/src/common.tsx +28 -15
- package/flow-report/src/header.tsx +12 -13
- package/flow-report/src/help-dialog.tsx +3 -4
- package/flow-report/src/i18n/i18n.tsx +57 -16
- package/flow-report/src/i18n/ui-strings.js +50 -0
- package/flow-report/src/icons.tsx +36 -8
- package/flow-report/src/sidebar/flow.tsx +3 -3
- package/flow-report/src/sidebar/sidebar.tsx +35 -14
- package/flow-report/src/summary/category.tsx +97 -24
- package/flow-report/src/summary/summary.tsx +21 -14
- package/flow-report/src/topbar.tsx +9 -5
- package/flow-report/src/util.ts +33 -26
- package/flow-report/src/wrappers/category-score.tsx +0 -3
- package/flow-report/src/wrappers/markdown.tsx +27 -0
- package/flow-report/src/wrappers/report-renderer.tsx +10 -3
- package/flow-report/src/wrappers/report.tsx +27 -6
- package/flow-report/standalone-flow.tsx +4 -3
- package/flow-report/test/common-test.tsx +32 -17
- package/flow-report/test/flow-report-pptr-test.ts +46 -0
- package/flow-report/test/header-test.tsx +6 -6
- package/flow-report/test/setup/env-setup.ts +1 -1
- package/flow-report/test/sidebar/sidebar-test.tsx +43 -1
- package/flow-report/test/summary/category-test.tsx +120 -24
- package/flow-report/test/summary/summary-test.tsx +1 -1
- package/flow-report/test/topbar-test.tsx +1 -0
- package/flow-report/test/util-test.tsx +32 -11
- package/flow-report/test/wrappers/category-score-test.tsx +87 -0
- package/flow-report/test/wrappers/markdown-test.tsx +29 -0
- package/flow-report/tsconfig.json +1 -0
- package/jest.config.js +4 -2
- package/lighthouse-cli/.eslintrc.cjs +2 -0
- package/lighthouse-cli/cli-flags.js +1 -1
- package/lighthouse-cli/run.js +1 -1
- package/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +0 -0
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/bundle.js +4 -2
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js +1 -1
- package/lighthouse-cli/test/smokehouse/smokehouse.js +1 -1
- package/lighthouse-core/audits/accessibility/axe-audit.js +7 -1
- package/lighthouse-core/audits/audit.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +2 -0
- package/lighthouse-core/audits/byte-efficiency/modern-image-formats.js +4 -2
- package/lighthouse-core/audits/byte-efficiency/offscreen-images.js +11 -10
- package/lighthouse-core/audits/byte-efficiency/uses-optimized-images.js +5 -3
- package/lighthouse-core/audits/byte-efficiency/uses-responsive-images-snapshot.js +2 -1
- package/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +2 -1
- package/lighthouse-core/audits/deprecations.js +33 -11
- package/lighthouse-core/audits/dobetterweb/uses-http2.js +27 -11
- package/lighthouse-core/audits/errors-in-console.js +0 -2
- package/lighthouse-core/audits/image-aspect-ratio.js +5 -5
- package/lighthouse-core/audits/image-size-responsive.js +6 -6
- package/lighthouse-core/audits/installable-manifest.js +5 -3
- package/lighthouse-core/audits/preload-lcp-image.js +7 -5
- package/lighthouse-core/audits/script-treemap-data.js +1 -1
- package/lighthouse-core/audits/unsized-images.js +2 -3
- package/lighthouse-core/computed/image-records.js +4 -3
- package/lighthouse-core/computed/metrics/lantern-total-blocking-time.js +3 -4
- package/lighthouse-core/computed/metrics/tbt-utils.js +57 -0
- package/lighthouse-core/computed/metrics/total-blocking-time.js +3 -53
- package/lighthouse-core/computed/resource-summary.js +1 -1
- package/lighthouse-core/config/config-helpers.js +21 -10
- package/lighthouse-core/config/constants.js +3 -4
- package/lighthouse-core/config/default-config.js +61 -71
- package/lighthouse-core/fraggle-rock/config/config.js +1 -1
- package/lighthouse-core/fraggle-rock/config/default-config.js +4 -5
- package/lighthouse-core/fraggle-rock/gather/base-gatherer.js +6 -1
- package/lighthouse-core/fraggle-rock/gather/session.js +3 -4
- package/lighthouse-core/gather/connections/cri.js +1 -1
- package/lighthouse-core/gather/driver/storage.js +0 -1
- package/lighthouse-core/gather/driver.js +3 -7
- package/lighthouse-core/gather/fetcher.js +4 -7
- package/lighthouse-core/gather/gather-runner.js +29 -6
- package/lighthouse-core/gather/gatherers/accessibility.js +27 -0
- package/lighthouse-core/gather/gatherers/dobetterweb/response-compression.js +1 -0
- package/lighthouse-core/gather/gatherers/image-elements.js +0 -3
- package/lighthouse-core/gather/gatherers/inspector-issues.js +5 -0
- package/lighthouse-core/lib/asset-saver.js +7 -4
- package/lighthouse-core/lib/emulation.js +45 -1
- package/lighthouse-core/lib/i18n/i18n.js +19 -8
- package/lighthouse-core/lib/lh-env.js +2 -0
- package/lighthouse-core/lib/proto-preprocessor.js +14 -2
- package/lighthouse-core/lib/tappable-rects.js +8 -15
- package/lighthouse-core/lib/url-shim.js +1 -1
- package/lighthouse-core/runner.js +1 -1
- package/lighthouse-core/util-commonjs.js +65 -46
- package/package.json +27 -17
- package/readme.md +3 -3
- package/report/.eslintrc.cjs +2 -0
- package/report/README.md +1 -1
- package/report/assets/standalone-template.html +2 -3
- package/report/assets/styles.css +360 -254
- package/report/assets/templates.html +21 -76
- package/report/clients/bundle.js +1 -0
- package/report/clients/standalone.js +6 -15
- package/report/generator/README.md +1 -1
- package/report/renderer/api.js +32 -0
- package/report/renderer/category-renderer.js +59 -19
- package/report/renderer/components.js +59 -110
- package/report/renderer/crc-details-renderer.js +15 -12
- package/report/renderer/dom.js +16 -1
- package/report/renderer/drop-down-menu.js +2 -2
- package/report/renderer/element-screenshot-renderer.js +8 -8
- package/report/renderer/features-util.js +1 -1
- package/report/renderer/open-tab.js +9 -3
- package/report/renderer/performance-category-renderer.js +55 -34
- package/report/renderer/pwa-category-renderer.js +0 -10
- package/report/renderer/report-renderer.js +91 -44
- package/report/renderer/report-ui-features.js +36 -33
- package/report/renderer/swap-locale-feature.js +3 -3
- package/report/renderer/topbar-features.js +53 -48
- package/report/renderer/util.js +66 -46
- package/report/test/clients/bundle-test.js +70 -0
- package/report/test/renderer/category-renderer-test.js +48 -3
- package/report/test/renderer/i18n-test.js +0 -7
- package/report/test/renderer/performance-category-renderer-test.js +51 -14
- package/report/test/renderer/pwa-category-renderer-test.js +6 -6
- package/report/test/renderer/report-renderer-axe-test.js +10 -12
- package/report/test/renderer/report-renderer-test.js +23 -22
- package/report/test/renderer/report-ui-features-test.js +20 -10
- package/report/test/renderer/text-encoding-test.js +1 -1
- package/report/test/renderer/util-test.js +35 -31
- package/report/test-assets/faux-psi-template.html +3 -11
- package/report/test-assets/faux-psi.js +26 -22
- package/report/types/html-renderer.d.ts +2 -0
- package/report/types/report-renderer.d.ts +23 -0
- package/shared/localization/format.js +64 -30
- package/shared/localization/locales/ar-XB.json +72 -75
- package/shared/localization/locales/ar.json +72 -75
- package/shared/localization/locales/bg.json +72 -75
- package/shared/localization/locales/ca.json +72 -75
- package/shared/localization/locales/cs.json +89 -92
- package/shared/localization/locales/da.json +72 -75
- package/shared/localization/locales/de.json +89 -92
- package/shared/localization/locales/el.json +72 -75
- package/shared/localization/locales/en-GB.json +72 -75
- package/shared/localization/locales/en-US.json +75 -75
- package/shared/localization/locales/en-XA.json +72 -75
- package/shared/localization/locales/en-XL.json +75 -75
- package/shared/localization/locales/es-419.json +90 -93
- package/shared/localization/locales/es.json +90 -93
- package/shared/localization/locales/fi.json +72 -75
- package/shared/localization/locales/fil.json +72 -75
- package/shared/localization/locales/fr.json +89 -92
- package/shared/localization/locales/he.json +73 -76
- package/shared/localization/locales/hi.json +72 -75
- package/shared/localization/locales/hr.json +72 -75
- package/shared/localization/locales/hu.json +89 -92
- package/shared/localization/locales/id.json +89 -92
- package/shared/localization/locales/it.json +89 -92
- package/shared/localization/locales/ja.json +89 -92
- package/shared/localization/locales/ko.json +89 -92
- package/shared/localization/locales/lt.json +89 -92
- package/shared/localization/locales/lv.json +95 -98
- package/shared/localization/locales/nl.json +89 -92
- package/shared/localization/locales/no.json +72 -75
- package/shared/localization/locales/pl.json +72 -75
- package/shared/localization/locales/pt-PT.json +72 -75
- package/shared/localization/locales/pt.json +89 -92
- package/shared/localization/locales/ro.json +90 -93
- package/shared/localization/locales/ru.json +89 -92
- package/shared/localization/locales/sk.json +89 -92
- package/shared/localization/locales/sl.json +89 -92
- package/shared/localization/locales/sr-Latn.json +89 -92
- package/shared/localization/locales/sr.json +89 -92
- package/shared/localization/locales/sv.json +72 -75
- package/shared/localization/locales/ta.json +89 -92
- package/shared/localization/locales/te.json +89 -92
- package/shared/localization/locales/th.json +89 -92
- package/shared/localization/locales/tr.json +89 -92
- package/shared/localization/locales/uk.json +92 -95
- package/shared/localization/locales/vi.json +89 -92
- package/shared/localization/locales/zh-HK.json +89 -92
- package/shared/localization/locales/zh-TW.json +89 -92
- package/shared/localization/locales/zh.json +89 -92
- package/shared/localization/locales.js +6 -0
- package/shared/test/localization/format-test.js +45 -9
- package/shared/test/localization/swap-locale-test.js +0 -12
- package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +19 -11
- package/third-party/chromium-synchronization/installability-errors-test.js +2 -0
- package/third-party/download-content-shell/download-content-shell.js +2 -2
- package/third-party/download-content-shell/utils.js +0 -24
- package/tsconfig-all.json +2 -2
- package/tsconfig.json +0 -1
- package/types/artifacts.d.ts +7 -7
- package/types/enquirer.d.ts +3 -1
- package/types/lhr/audit-details.d.ts +6 -5
- package/types/lhr/flow.d.ts +3 -2
- package/types/lhr/lhr.d.ts +1 -1
- package/types/node.d.ts +5 -5
- package/types/rollup-plugin-postprocess.d.ts +10 -0
- package/changelog.md +0 -5490
- package/lighthouse-core/audits/dobetterweb/appcache-manifest.js +0 -67
- package/lighthouse-core/audits/dobetterweb/external-anchors-use-rel-noopener.js +0 -96
- package/lighthouse-core/audits/redirects-http.js +0 -59
- package/lighthouse-core/gather/gatherers/dobetterweb/appcache.js +0 -34
- package/lighthouse-core/gather/gatherers/http-redirect.js +0 -46
- package/lighthouse-core/lib/i18n/locales/en-US.ctc.json +0 -6699
- package/lighthouse-core/lib/i18n/locales/en-XL.ctc.json +0 -6672
- package/lighthouse-core/scripts/package.json +0 -4
- package/report/clients/psi.js +0 -158
- package/report/test/clients/psi-test.js +0 -143
- package/shared/localization/locales/en-US.ctc.json +0 -6877
- package/shared/localization/locales/en-XL.ctc.json +0 -6852
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright 2016 The Lighthouse Authors. All Rights Reserved.
|
|
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
|
-
* 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
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @fileoverview Audit a page to ensure it is not using the Application Cache API.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
const Audit = require('../audit.js');
|
|
14
|
-
const i18n = require('../../lib/i18n/i18n.js');
|
|
15
|
-
|
|
16
|
-
const UIStrings = {
|
|
17
|
-
/** Title of a Lighthouse audit that provides detail on the use of the Application Cache API. This descriptive title is shown to users when they do not use the Application Cache API. */
|
|
18
|
-
title: 'Avoids Application Cache',
|
|
19
|
-
/** Title of a Lighthouse audit that provides detail on the use of the Application Cache API. This descriptive title is shown to users when they do use the Application Cache API, which is considered bad practice. */
|
|
20
|
-
failureTitle: 'Uses Application Cache',
|
|
21
|
-
/** Description of a Lighthouse audit that tells the user why they should not use the Application Cache API. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
|
|
22
|
-
description: 'Application Cache is deprecated. ' +
|
|
23
|
-
'[Learn more](https://web.dev/appcache-manifest/).',
|
|
24
|
-
/**
|
|
25
|
-
* @description Label for the audit identifying uses of the Application Cache.
|
|
26
|
-
* @example {clock.appcache} AppCacheManifest
|
|
27
|
-
*/
|
|
28
|
-
displayValue: 'Found "{AppCacheManifest}"',
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
|
|
32
|
-
|
|
33
|
-
class AppCacheManifestAttr extends Audit {
|
|
34
|
-
/**
|
|
35
|
-
* @return {LH.Audit.Meta}
|
|
36
|
-
*/
|
|
37
|
-
static get meta() {
|
|
38
|
-
return {
|
|
39
|
-
id: 'appcache-manifest',
|
|
40
|
-
title: str_(UIStrings.title),
|
|
41
|
-
failureTitle: str_(UIStrings.failureTitle),
|
|
42
|
-
description: str_(UIStrings.description),
|
|
43
|
-
requiredArtifacts: ['AppCacheManifest'],
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @param {LH.Artifacts} artifacts
|
|
49
|
-
* @return {LH.Audit.Product}
|
|
50
|
-
*/
|
|
51
|
-
static audit(artifacts) {
|
|
52
|
-
// Fails if an AppCacheManifest was found.
|
|
53
|
-
if (artifacts.AppCacheManifest !== null) {
|
|
54
|
-
return {
|
|
55
|
-
score: 0,
|
|
56
|
-
displayValue: str_(UIStrings.displayValue, {AppCacheManifest: artifacts.AppCacheManifest}),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
score: 1,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
module.exports = AppCacheManifestAttr;
|
|
67
|
-
module.exports.UIStrings = UIStrings;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright 2016 The Lighthouse Authors. All Rights Reserved.
|
|
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
|
-
* 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
|
-
*/
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
const URL = require('../../lib/url-shim.js');
|
|
9
|
-
const Audit = require('../audit.js');
|
|
10
|
-
const i18n = require('../../lib/i18n/i18n.js');
|
|
11
|
-
|
|
12
|
-
const UIStrings = {
|
|
13
|
-
/** Title of a Lighthouse audit that provides detail on the cross-origin links that the web page contains, and whether the links can be considered safe. This descriptive title is shown to users when all links are safe. */
|
|
14
|
-
title: 'Links to cross-origin destinations are safe',
|
|
15
|
-
/** Title of a Lighthouse audit that provides detail on the cross-origin links that the web page contains, and whether the links can be considered safe. This descriptive title is shown to users when not all links can be considered safe. */
|
|
16
|
-
failureTitle: 'Links to cross-origin destinations are unsafe',
|
|
17
|
-
/** Description of a Lighthouse audit that tells the user why and how they should secure cross-origin links. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
|
|
18
|
-
description: 'Add `rel="noopener"` or `rel="noreferrer"` to any external links to improve ' +
|
|
19
|
-
'performance and prevent security vulnerabilities. ' +
|
|
20
|
-
'[Learn more](https://web.dev/external-anchors-use-rel-noopener/).',
|
|
21
|
-
/**
|
|
22
|
-
* @description Warning that some links' destinations cannot be determined and therefore the audit cannot evaluate the link's safety.
|
|
23
|
-
* @example {<a target="_blank">} anchorHTML
|
|
24
|
-
*/
|
|
25
|
-
warning: 'Unable to determine the destination for anchor ({anchorHTML}). ' +
|
|
26
|
-
'If not used as a hyperlink, consider removing target=_blank.',
|
|
27
|
-
/** Label for a column in a data table; entries will be the HTML elements that failed the audit. Anchors are DOM elements that are links. */
|
|
28
|
-
columnFailingAnchors: 'Failing Anchors',
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
|
|
32
|
-
|
|
33
|
-
class ExternalAnchorsUseRelNoopenerAudit extends Audit {
|
|
34
|
-
/**
|
|
35
|
-
* @return {LH.Audit.Meta}
|
|
36
|
-
*/
|
|
37
|
-
static get meta() {
|
|
38
|
-
return {
|
|
39
|
-
id: 'external-anchors-use-rel-noopener',
|
|
40
|
-
title: str_(UIStrings.title),
|
|
41
|
-
failureTitle: str_(UIStrings.failureTitle),
|
|
42
|
-
description: str_(UIStrings.description),
|
|
43
|
-
requiredArtifacts: ['URL', 'AnchorElements'],
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @param {LH.Artifacts} artifacts
|
|
49
|
-
* @return {LH.Audit.Product}
|
|
50
|
-
*/
|
|
51
|
-
static audit(artifacts) {
|
|
52
|
-
/** @type {LH.IcuMessage[]} */
|
|
53
|
-
const warnings = [];
|
|
54
|
-
const pageHost = new URL(artifacts.URL.finalUrl).host;
|
|
55
|
-
const failingAnchors = artifacts.AnchorElements
|
|
56
|
-
.filter(anchor => anchor.target === '_blank' && !anchor.rel.includes('noopener') &&
|
|
57
|
-
!anchor.rel.includes('noreferrer'))
|
|
58
|
-
// Filter usages to exclude anchors that are same origin
|
|
59
|
-
.filter(anchor => {
|
|
60
|
-
try {
|
|
61
|
-
return new URL(anchor.href).host !== pageHost;
|
|
62
|
-
} catch (err) {
|
|
63
|
-
warnings.push(str_(UIStrings.warning, {anchorHTML: anchor.node.snippet}));
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
.filter(anchor => {
|
|
68
|
-
return !anchor.href || anchor.href.toLowerCase().startsWith('http');
|
|
69
|
-
})
|
|
70
|
-
.map(anchor => {
|
|
71
|
-
return {
|
|
72
|
-
node: Audit.makeNodeItem(anchor.node),
|
|
73
|
-
href: anchor.href || 'Unknown',
|
|
74
|
-
target: anchor.target || '',
|
|
75
|
-
rel: anchor.rel || '',
|
|
76
|
-
outerHTML: anchor.node.snippet || '',
|
|
77
|
-
};
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
/** @type {LH.Audit.Details.Table['headings']} */
|
|
81
|
-
const headings = [
|
|
82
|
-
{key: 'node', itemType: 'node', text: str_(UIStrings.columnFailingAnchors)},
|
|
83
|
-
];
|
|
84
|
-
|
|
85
|
-
const details = Audit.makeTableDetails(headings, failingAnchors);
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
score: Number(failingAnchors.length === 0),
|
|
89
|
-
details,
|
|
90
|
-
warnings,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
module.exports = ExternalAnchorsUseRelNoopenerAudit;
|
|
96
|
-
module.exports.UIStrings = UIStrings;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright 2016 The Lighthouse Authors. All Rights Reserved.
|
|
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
|
-
* 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
|
-
*/
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
const Audit = require('./audit.js');
|
|
9
|
-
const i18n = require('../lib/i18n/i18n.js');
|
|
10
|
-
const URL = require('../lib/url-shim.js');
|
|
11
|
-
|
|
12
|
-
const UIStrings = {
|
|
13
|
-
/** Title of a Lighthouse audit that provides detail on HTTP to HTTPS redirects. This descriptive title is shown to users when HTTP traffic is redirected to HTTPS. */
|
|
14
|
-
title: 'Redirects HTTP traffic to HTTPS',
|
|
15
|
-
/** Title of a Lighthouse audit that provides detail on HTTP to HTTPS redirects. This descriptive title is shown to users when HTTP traffic is not redirected to HTTPS. */
|
|
16
|
-
failureTitle: 'Does not redirect HTTP traffic to HTTPS',
|
|
17
|
-
/** Description of a Lighthouse audit that tells the user why they should direct HTTP traffic to HTTPS. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
|
|
18
|
-
description: 'If you\'ve already set up HTTPS, make sure that you redirect all HTTP ' +
|
|
19
|
-
'traffic to HTTPS in order to enable secure web features for all your users. [Learn more](https://web.dev/redirects-http/).',
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
|
|
23
|
-
|
|
24
|
-
class RedirectsHTTP extends Audit {
|
|
25
|
-
/**
|
|
26
|
-
* @return {LH.Audit.Meta}
|
|
27
|
-
*/
|
|
28
|
-
static get meta() {
|
|
29
|
-
return {
|
|
30
|
-
id: 'redirects-http',
|
|
31
|
-
title: str_(UIStrings.title),
|
|
32
|
-
failureTitle: str_(UIStrings.failureTitle),
|
|
33
|
-
description: str_(UIStrings.description),
|
|
34
|
-
requiredArtifacts: ['HTTPRedirect', 'URL'],
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @param {LH.Artifacts} artifacts
|
|
40
|
-
* @return {LH.Audit.Product}
|
|
41
|
-
*/
|
|
42
|
-
static audit(artifacts) {
|
|
43
|
-
// Redirecting HTTP to HTTPS makes no sense on localhost
|
|
44
|
-
const url = new URL(artifacts.URL.finalUrl);
|
|
45
|
-
if (URL.isLikeLocalhost(url.hostname)) {
|
|
46
|
-
return {
|
|
47
|
-
score: 1,
|
|
48
|
-
notApplicable: true,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
score: Number(artifacts.HTTPRedirect.value),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
module.exports = RedirectsHTTP;
|
|
59
|
-
module.exports.UIStrings = UIStrings;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright 2016 The Lighthouse Authors. All Rights Reserved.
|
|
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
|
-
* 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
|
-
*/
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
const FRGatherer = require('../../../fraggle-rock/gather/base-gatherer.js');
|
|
9
|
-
|
|
10
|
-
/* global document */
|
|
11
|
-
|
|
12
|
-
class AppCacheManifest extends FRGatherer {
|
|
13
|
-
/** @type {LH.Gatherer.GathererMeta} */
|
|
14
|
-
meta = {
|
|
15
|
-
supportedModes: ['snapshot', 'navigation'],
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @param {LH.Gatherer.FRTransitionalContext} passContext
|
|
20
|
-
* @return {Promise<LH.Artifacts['AppCacheManifest']>}
|
|
21
|
-
*/
|
|
22
|
-
getArtifact(passContext) {
|
|
23
|
-
const driver = passContext.driver;
|
|
24
|
-
|
|
25
|
-
return driver.executionContext.evaluate(() => {
|
|
26
|
-
return document.documentElement && document.documentElement.getAttribute('manifest');
|
|
27
|
-
}, {
|
|
28
|
-
args: [],
|
|
29
|
-
useIsolation: true,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
module.exports = AppCacheManifest;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright 2016 The Lighthouse Authors. All Rights Reserved.
|
|
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
|
-
* 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
|
-
*/
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
const Gatherer = require('./gatherer.js');
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* This gatherer changes the options.url so that its pass loads the http page.
|
|
12
|
-
* After load it detects if its on a crypographic scheme.
|
|
13
|
-
* TODO: Instead of abusing a loadPage pass for this test, it could likely just do an XHR instead
|
|
14
|
-
*/
|
|
15
|
-
class HTTPRedirect extends Gatherer {
|
|
16
|
-
constructor() {
|
|
17
|
-
super();
|
|
18
|
-
this._preRedirectURL = '';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @param {LH.Gatherer.PassContext} passContext
|
|
23
|
-
*/
|
|
24
|
-
beforePass(passContext) {
|
|
25
|
-
this._preRedirectURL = passContext.url;
|
|
26
|
-
passContext.url = this._preRedirectURL.replace(/^https/, 'http');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @param {LH.Gatherer.PassContext} passContext
|
|
31
|
-
* @return {Promise<LH.Artifacts['HTTPRedirect']>}
|
|
32
|
-
*/
|
|
33
|
-
async afterPass(passContext) {
|
|
34
|
-
// Reset the options.
|
|
35
|
-
passContext.url = this._preRedirectURL;
|
|
36
|
-
|
|
37
|
-
const executionContext = passContext.driver.executionContext;
|
|
38
|
-
const expression = `new URL(window.location).protocol === 'https:'`;
|
|
39
|
-
const isHttps = await executionContext.evaluateAsync(expression, {useIsolation: true});
|
|
40
|
-
return {
|
|
41
|
-
value: isHttps,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
module.exports = HTTPRedirect;
|