lighthouse 9.3.1-dev.20220210 → 9.3.1-dev.20220211
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 +13 -0
- package/dist/report/flow.js +2 -2
- package/dist/report/standalone.js +7 -7
- package/lighthouse-core/util-commonjs.js +4 -0
- package/package.json +1 -1
- package/report/renderer/report-ui-features.js +9 -0
- package/report/renderer/util.js +4 -0
- package/report/test/renderer/__snapshots__/report-renderer-axe-test.js.snap +107 -0
- package/report/test/renderer/report-renderer-axe-test.js +38 -17
- package/report/types/report-renderer.d.ts +7 -0
- package/shared/localization/locales/en-US.json +6 -0
- package/shared/localization/locales/en-XL.json +6 -0
|
@@ -630,6 +630,10 @@ const UIStrings = {
|
|
|
630
630
|
thirdPartyResourcesLabel: 'Show 3rd-party resources',
|
|
631
631
|
/** This label is for a button that opens a new tab to a webapp called "Treemap", which is a nested visual representation of a heierarchy of data related to the reports (script bytes and coverage, resource breakdown, etc.) */
|
|
632
632
|
viewTreemapLabel: 'View Treemap',
|
|
633
|
+
/** This label is for a button that will show the user a trace of the page. */
|
|
634
|
+
viewTraceLabel: 'View Trace',
|
|
635
|
+
/** This label is for a button that will show the user a trace of the page. */
|
|
636
|
+
viewOriginalTraceLabel: 'View Original Trace',
|
|
633
637
|
|
|
634
638
|
/** Option in a dropdown menu that opens a small, summary report in a print dialog. */
|
|
635
639
|
dropdownPrintSummary: 'Print Summary',
|
package/package.json
CHANGED
|
@@ -112,6 +112,15 @@ export class ReportUIFeatures {
|
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
if (this._opts.onViewTrace) {
|
|
116
|
+
this.addButton({
|
|
117
|
+
text: lhr.configSettings.throttlingMethod === 'simulate' ?
|
|
118
|
+
Util.i18n.strings.viewOriginalTraceLabel :
|
|
119
|
+
Util.i18n.strings.viewTraceLabel,
|
|
120
|
+
onClick: () => this._opts.onViewTrace?.(),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
115
124
|
if (this._opts.getStandaloneReportHTML) {
|
|
116
125
|
this._dom.find('a[data-action="save-html"]', this._dom.rootEl).classList.remove('lh-hidden');
|
|
117
126
|
}
|
package/report/renderer/util.js
CHANGED
|
@@ -627,6 +627,10 @@ const UIStrings = {
|
|
|
627
627
|
thirdPartyResourcesLabel: 'Show 3rd-party resources',
|
|
628
628
|
/** This label is for a button that opens a new tab to a webapp called "Treemap", which is a nested visual representation of a heierarchy of data related to the reports (script bytes and coverage, resource breakdown, etc.) */
|
|
629
629
|
viewTreemapLabel: 'View Treemap',
|
|
630
|
+
/** This label is for a button that will show the user a trace of the page. */
|
|
631
|
+
viewTraceLabel: 'View Trace',
|
|
632
|
+
/** This label is for a button that will show the user a trace of the page. */
|
|
633
|
+
viewOriginalTraceLabel: 'View Original Trace',
|
|
630
634
|
|
|
631
635
|
/** Option in a dropdown menu that opens a small, summary report in a print dialog. */
|
|
632
636
|
dropdownPrintSummary: 'Print Summary',
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ReportRendererAxe with aXe renders without axe violations 2`] = `
|
|
4
|
+
Array [
|
|
5
|
+
Object {
|
|
6
|
+
"description": "Ensures every id attribute value is unique",
|
|
7
|
+
"help": "id attribute value must be unique",
|
|
8
|
+
"helpUrl": "https://dequeuniversity.com/rules/axe/4.3/duplicate-id?application=axeAPI",
|
|
9
|
+
"id": "duplicate-id",
|
|
10
|
+
"impact": "minor",
|
|
11
|
+
"nodes": Array [
|
|
12
|
+
Object {
|
|
13
|
+
"all": Array [],
|
|
14
|
+
"any": Array [
|
|
15
|
+
Object {
|
|
16
|
+
"data": "viewport",
|
|
17
|
+
"id": "duplicate-id",
|
|
18
|
+
"impact": "minor",
|
|
19
|
+
"message": "Document has multiple static elements with the same id attribute: viewport",
|
|
20
|
+
"relatedNodes": Array [
|
|
21
|
+
Object {
|
|
22
|
+
"html": "<div class=\\"lh-audit lh-audit--binary lh-audit--pass\\" id=\\"viewport\\">",
|
|
23
|
+
"target": Array [
|
|
24
|
+
"#seo > .lh-audit-group:nth-child(4) > .lh-clump--passed.lh-clump > .lh-audit--binary.lh-audit--pass.lh-audit:nth-child(2)",
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
Object {
|
|
28
|
+
"html": "<div class=\\"lh-audit lh-audit--binary lh-audit--pass\\" id=\\"viewport\\">",
|
|
29
|
+
"target": Array [
|
|
30
|
+
".lh-audit-group--pwa-optimized > .lh-audit--binary.lh-audit--pass.lh-audit:nth-child(6)",
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
"failureSummary": "Fix any of the following:
|
|
37
|
+
Document has multiple static elements with the same id attribute: viewport",
|
|
38
|
+
"html": "<div class=\\"lh-audit lh-audit--binary lh-audit--pass\\" id=\\"viewport\\">",
|
|
39
|
+
"impact": "minor",
|
|
40
|
+
"none": Array [],
|
|
41
|
+
"target": Array [
|
|
42
|
+
".lh-audit--binary.lh-audit--pass.lh-audit:nth-child(20)",
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
Object {
|
|
46
|
+
"all": Array [],
|
|
47
|
+
"any": Array [
|
|
48
|
+
Object {
|
|
49
|
+
"data": "image-alt",
|
|
50
|
+
"id": "duplicate-id",
|
|
51
|
+
"impact": "minor",
|
|
52
|
+
"message": "Document has multiple static elements with the same id attribute: image-alt",
|
|
53
|
+
"relatedNodes": Array [
|
|
54
|
+
Object {
|
|
55
|
+
"html": "<div class=\\"lh-audit lh-audit--binary lh-audit--fail\\" id=\\"image-alt\\">",
|
|
56
|
+
"target": Array [
|
|
57
|
+
".lh-audit-group--seo-content > .lh-audit--fail.lh-audit--binary.lh-audit:nth-child(3)",
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
"failureSummary": "Fix any of the following:
|
|
64
|
+
Document has multiple static elements with the same id attribute: image-alt",
|
|
65
|
+
"html": "<div class=\\"lh-audit lh-audit--binary lh-audit--fail\\" id=\\"image-alt\\">",
|
|
66
|
+
"impact": "minor",
|
|
67
|
+
"none": Array [],
|
|
68
|
+
"target": Array [
|
|
69
|
+
".lh-audit-group--a11y-names-labels > .lh-audit--fail.lh-audit--binary.lh-audit:nth-child(2)",
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
Object {
|
|
73
|
+
"all": Array [],
|
|
74
|
+
"any": Array [
|
|
75
|
+
Object {
|
|
76
|
+
"data": "document-title",
|
|
77
|
+
"id": "duplicate-id",
|
|
78
|
+
"impact": "minor",
|
|
79
|
+
"message": "Document has multiple static elements with the same id attribute: document-title",
|
|
80
|
+
"relatedNodes": Array [
|
|
81
|
+
Object {
|
|
82
|
+
"html": "<div class=\\"lh-audit lh-audit--binary lh-audit--pass\\" id=\\"document-title\\">",
|
|
83
|
+
"target": Array [
|
|
84
|
+
"#seo > .lh-audit-group:nth-child(4) > .lh-clump--passed.lh-clump > .lh-audit--binary.lh-audit--pass.lh-audit:nth-child(3)",
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
"failureSummary": "Fix any of the following:
|
|
91
|
+
Document has multiple static elements with the same id attribute: document-title",
|
|
92
|
+
"html": "<div class=\\"lh-audit lh-audit--binary lh-audit--pass\\" id=\\"document-title\\">",
|
|
93
|
+
"impact": "minor",
|
|
94
|
+
"none": Array [],
|
|
95
|
+
"target": Array [
|
|
96
|
+
".lh-audit--binary.lh-audit--pass.lh-audit:nth-child(13)",
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
"tags": Array [
|
|
101
|
+
"cat.parsing",
|
|
102
|
+
"wcag2a",
|
|
103
|
+
"wcag411",
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
]
|
|
107
|
+
`;
|
|
@@ -53,23 +53,44 @@ describe('ReportRendererAxe', () => {
|
|
|
53
53
|
// eslint-disable-next-line no-undef
|
|
54
54
|
const axeResults = await page.evaluate(config => axe.run(config), config);
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
56
|
+
// Color contrast failure only pops up if this pptr is run headfully.
|
|
57
|
+
// There are currently 27 problematic nodes, primarily audit display text and explanations.
|
|
58
|
+
// TODO: fix these failures, regardless.
|
|
59
|
+
// {
|
|
60
|
+
// id: 'color-contrast',
|
|
61
|
+
// },
|
|
62
|
+
|
|
63
|
+
expect(axeResults.violations.find(v => v.id === 'duplicate-id')).toMatchObject({
|
|
64
|
+
id: 'duplicate-id',
|
|
65
|
+
nodes: [
|
|
66
|
+
// We use these audits in multiple categories. Makes sense.
|
|
67
|
+
{html: '<div class="lh-audit lh-audit--binary lh-audit--pass" id="viewport">'},
|
|
68
|
+
{html: '<div class="lh-audit lh-audit--binary lh-audit--fail" id="image-alt">'},
|
|
69
|
+
{html: '<div class="lh-audit lh-audit--binary lh-audit--pass" id="document-title">'},
|
|
70
|
+
],
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const axeSummary = axeResults.violations.map((v) => {
|
|
74
|
+
return {
|
|
75
|
+
id: v.id,
|
|
76
|
+
message: v.nodes.map((n) => n.failureSummary).join('\n'),
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
expect(axeSummary).toMatchInlineSnapshot(`
|
|
80
|
+
Array [
|
|
81
|
+
Object {
|
|
82
|
+
"id": "duplicate-id",
|
|
83
|
+
"message": "Fix any of the following:
|
|
84
|
+
Document has multiple static elements with the same id attribute: viewport
|
|
85
|
+
Fix any of the following:
|
|
86
|
+
Document has multiple static elements with the same id attribute: image-alt
|
|
87
|
+
Fix any of the following:
|
|
88
|
+
Document has multiple static elements with the same id attribute: document-title",
|
|
89
|
+
},
|
|
90
|
+
]
|
|
91
|
+
`);
|
|
92
|
+
|
|
93
|
+
expect(axeResults.violations).toMatchSnapshot();
|
|
73
94
|
},
|
|
74
95
|
// This test takes 10s on fast hardware, but can take longer in CI.
|
|
75
96
|
// https://github.com/dequelabs/axe-core/tree/b573b1c1/doc/examples/jest_react#timeout-issues
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Result as AuditResult } from "../../types/lhr/audit-result";
|
|
8
|
+
import { ReportUIFeatures } from "../renderer/report-ui-features.js";
|
|
8
9
|
|
|
9
10
|
declare module Renderer {
|
|
10
11
|
function renderReport(lhr: AuditResult, options?: Options): HTMLElement;
|
|
@@ -26,6 +27,12 @@ declare module Renderer {
|
|
|
26
27
|
onPageAnchorRendered?: (link: HTMLAnchorElement) => void;
|
|
27
28
|
/** If defined, `Save as HTML` option is shown in dropdown menu. */
|
|
28
29
|
getStandaloneReportHTML?: () => string;
|
|
30
|
+
/**
|
|
31
|
+
* If defined, adds a `View Trace` button to the report, and calls this callback when clicked.
|
|
32
|
+
* The callback should do something to present the user with a visualization of the trace
|
|
33
|
+
* data, which can be gotten from the artifacts.
|
|
34
|
+
*/
|
|
35
|
+
onViewTrace?: () => void;
|
|
29
36
|
}
|
|
30
37
|
}
|
|
31
38
|
|
|
@@ -2543,6 +2543,12 @@
|
|
|
2543
2543
|
"report/renderer/util.js | varianceDisclaimer": {
|
|
2544
2544
|
"message": "Values are estimated and may vary. The [performance score is calculated](https://web.dev/performance-scoring/) directly from these metrics."
|
|
2545
2545
|
},
|
|
2546
|
+
"report/renderer/util.js | viewOriginalTraceLabel": {
|
|
2547
|
+
"message": "View Original Trace"
|
|
2548
|
+
},
|
|
2549
|
+
"report/renderer/util.js | viewTraceLabel": {
|
|
2550
|
+
"message": "View Trace"
|
|
2551
|
+
},
|
|
2546
2552
|
"report/renderer/util.js | viewTreemapLabel": {
|
|
2547
2553
|
"message": "View Treemap"
|
|
2548
2554
|
},
|
|
@@ -2543,6 +2543,12 @@
|
|
|
2543
2543
|
"report/renderer/util.js | varianceDisclaimer": {
|
|
2544
2544
|
"message": "V̂ál̂úêś âŕê éŝt́îḿât́êd́ âńd̂ ḿâý v̂ár̂ý. T̂h́ê [ṕêŕf̂ór̂ḿâńĉé ŝćôŕê íŝ ćâĺĉúl̂át̂éd̂](https://web.dev/performance-scoring/) d́îŕêćt̂ĺŷ f́r̂óm̂ t́ĥéŝé m̂ét̂ŕîćŝ."
|
|
2545
2545
|
},
|
|
2546
|
+
"report/renderer/util.js | viewOriginalTraceLabel": {
|
|
2547
|
+
"message": "V̂íêẃ Ôŕîǵîńâĺ T̂ŕâćê"
|
|
2548
|
+
},
|
|
2549
|
+
"report/renderer/util.js | viewTraceLabel": {
|
|
2550
|
+
"message": "V̂íêẃ T̂ŕâćê"
|
|
2551
|
+
},
|
|
2546
2552
|
"report/renderer/util.js | viewTreemapLabel": {
|
|
2547
2553
|
"message": "V̂íêẃ T̂ŕêém̂áp̂"
|
|
2548
2554
|
},
|