lighthouse 9.5.0-dev.20221116 → 9.5.0-dev.20221118
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/core/index.js +2 -0
- package/core/util.cjs +9 -2
- package/dist/report/bundle.esm.js +22 -7
- package/dist/report/flow.js +3 -3
- package/dist/report/standalone.js +6 -6
- package/flow-report/src/sidebar/sidebar.tsx +4 -1
- package/flow-report/test/sidebar/sidebar-test.tsx +8 -1
- package/package.json +1 -1
- package/report/renderer/report-renderer.js +13 -5
- package/report/renderer/util.js +9 -2
- package/report/test/renderer/report-renderer-test.js +1 -0
- package/report/test/renderer/util-test.js +12 -2
- package/shared/localization/locales/en-US.json +3 -0
- package/shared/localization/locales/en-XL.json +3 -0
|
@@ -35,6 +35,9 @@ const SidebarRuntimeSettings: FunctionComponent<{settings: LH.ConfigSettings}> =
|
|
|
35
35
|
({settings}) => {
|
|
36
36
|
const strings = useLocalizedStrings();
|
|
37
37
|
const env = Util.getEmulationDescriptions(settings);
|
|
38
|
+
const deviceEmulationString = env.screenEmulation ?
|
|
39
|
+
`${env.deviceEmulation} - ${env.screenEmulation}` :
|
|
40
|
+
env.deviceEmulation;
|
|
38
41
|
|
|
39
42
|
return (
|
|
40
43
|
<div className="SidebarRuntimeSettings">
|
|
@@ -43,7 +46,7 @@ const SidebarRuntimeSettings: FunctionComponent<{settings: LH.ConfigSettings}> =
|
|
|
43
46
|
<EnvIcon/>
|
|
44
47
|
</div>
|
|
45
48
|
{
|
|
46
|
-
|
|
49
|
+
deviceEmulationString
|
|
47
50
|
}
|
|
48
51
|
</div>
|
|
49
52
|
<div
|
|
@@ -58,10 +58,12 @@ describe('SidebarRuntimeSettings', () => {
|
|
|
58
58
|
throughputKbps: 1.6 * 1024,
|
|
59
59
|
rttMs: 150,
|
|
60
60
|
},
|
|
61
|
+
screenEmulation: {disabled: true},
|
|
61
62
|
} as any;
|
|
62
63
|
const root = render(<SidebarRuntimeSettings settings={settings}/>, {wrapper});
|
|
63
64
|
|
|
64
65
|
expect(root.getByText('Emulated Moto G4')).toBeTruthy();
|
|
66
|
+
expect(root.queryByText('Emulated Moto G4 -')).toBeFalsy();
|
|
65
67
|
expect(root.getByText('Slow 4G throttling')).toBeTruthy();
|
|
66
68
|
expect(root.getByText('4x slowdown'));
|
|
67
69
|
});
|
|
@@ -78,10 +80,15 @@ describe('SidebarRuntimeSettings', () => {
|
|
|
78
80
|
throughputKbps: 1,
|
|
79
81
|
rttMs: 1,
|
|
80
82
|
},
|
|
83
|
+
screenEmulation: {
|
|
84
|
+
width: 100,
|
|
85
|
+
height: 100,
|
|
86
|
+
deviceScaleFactor: 2,
|
|
87
|
+
},
|
|
81
88
|
} as any;
|
|
82
89
|
const root = render(<SidebarRuntimeSettings settings={settings}/>, {wrapper});
|
|
83
90
|
|
|
84
|
-
expect(root.getByText('Emulated Desktop')).toBeTruthy();
|
|
91
|
+
expect(root.getByText('Emulated Desktop - 100x100, DPR 2')).toBeTruthy();
|
|
85
92
|
expect(root.getByText('Custom throttling')).toBeTruthy();
|
|
86
93
|
expect(root.getByText('1x slowdown'));
|
|
87
94
|
});
|
package/package.json
CHANGED
|
@@ -119,8 +119,6 @@ export class ReportRenderer {
|
|
|
119
119
|
*/
|
|
120
120
|
_renderMetaBlock(report, footer) {
|
|
121
121
|
const envValues = Util.getEmulationDescriptions(report.configSettings || {});
|
|
122
|
-
|
|
123
|
-
|
|
124
122
|
const match = report.userAgent.match(/(\w*Chrome\/[\d.]+)/); // \w* to include 'HeadlessChrome'
|
|
125
123
|
const chromeVer = Array.isArray(match)
|
|
126
124
|
? match[1].replace('/', ' ').replace('Chrome', 'Chromium')
|
|
@@ -129,15 +127,25 @@ export class ReportRenderer {
|
|
|
129
127
|
const benchmarkIndex = report.environment.benchmarkIndex.toFixed(0);
|
|
130
128
|
const axeVersion = report.environment.credits?.['axe-core'];
|
|
131
129
|
|
|
130
|
+
const devicesTooltipTextLines = [
|
|
131
|
+
`${Util.i18n.strings.runtimeSettingsBenchmark}: ${benchmarkIndex}`,
|
|
132
|
+
`${Util.i18n.strings.runtimeSettingsCPUThrottling}: ${envValues.cpuThrottling}`,
|
|
133
|
+
];
|
|
134
|
+
if (envValues.screenEmulation) {
|
|
135
|
+
devicesTooltipTextLines.push(
|
|
136
|
+
`${Util.i18n.strings.runtimeSettingsScreenEmulation}: ${envValues.screenEmulation}`);
|
|
137
|
+
}
|
|
138
|
+
if (axeVersion) {
|
|
139
|
+
devicesTooltipTextLines.push(`${Util.i18n.strings.runtimeSettingsAxeVersion}: ${axeVersion}`);
|
|
140
|
+
}
|
|
141
|
+
|
|
132
142
|
// [CSS icon class, textContent, tooltipText]
|
|
133
143
|
const metaItems = [
|
|
134
144
|
['date',
|
|
135
145
|
`Captured at ${Util.i18n.formatDateTime(report.fetchTime)}`],
|
|
136
146
|
['devices',
|
|
137
147
|
`${envValues.deviceEmulation} with Lighthouse ${report.lighthouseVersion}`,
|
|
138
|
-
|
|
139
|
-
`\n${Util.i18n.strings.runtimeSettingsCPUThrottling}: ${envValues.cpuThrottling}` +
|
|
140
|
-
(axeVersion ? `\n${Util.i18n.strings.runtimeSettingsAxeVersion}: ${axeVersion}` : '')],
|
|
148
|
+
devicesTooltipTextLines.join('\n')],
|
|
141
149
|
['samples-one',
|
|
142
150
|
Util.i18n.strings.runtimeSingleLoad,
|
|
143
151
|
Util.i18n.strings.runtimeSingleLoadTooltip],
|
package/report/renderer/util.js
CHANGED
|
@@ -466,7 +466,7 @@ class Util {
|
|
|
466
466
|
|
|
467
467
|
/**
|
|
468
468
|
* @param {LH.Result['configSettings']} settings
|
|
469
|
-
* @return {!{deviceEmulation: string, networkThrottling: string, cpuThrottling: string, summary: string}}
|
|
469
|
+
* @return {!{deviceEmulation: string, screenEmulation?: string, networkThrottling: string, cpuThrottling: string, summary: string}}
|
|
470
470
|
*/
|
|
471
471
|
static getEmulationDescriptions(settings) {
|
|
472
472
|
let cpuThrottling;
|
|
@@ -512,14 +512,19 @@ class Util {
|
|
|
512
512
|
summary = cpuThrottling = networkThrottling = Util.i18n.strings.runtimeUnknown;
|
|
513
513
|
}
|
|
514
514
|
|
|
515
|
-
// TODO(paulirish): revise Runtime Settings strings: https://github.com/GoogleChrome/lighthouse/pull/11796
|
|
516
515
|
const deviceEmulation = {
|
|
517
516
|
mobile: Util.i18n.strings.runtimeMobileEmulation,
|
|
518
517
|
desktop: Util.i18n.strings.runtimeDesktopEmulation,
|
|
519
518
|
}[settings.formFactor] || Util.i18n.strings.runtimeNoEmulation;
|
|
520
519
|
|
|
520
|
+
const screenEmulation = settings.screenEmulation.disabled ?
|
|
521
|
+
undefined :
|
|
522
|
+
// eslint-disable-next-line max-len
|
|
523
|
+
`${settings.screenEmulation.width}x${settings.screenEmulation.height}, DPR ${settings.screenEmulation.deviceScaleFactor}`;
|
|
524
|
+
|
|
521
525
|
return {
|
|
522
526
|
deviceEmulation,
|
|
527
|
+
screenEmulation,
|
|
523
528
|
cpuThrottling,
|
|
524
529
|
networkThrottling,
|
|
525
530
|
summary,
|
|
@@ -717,6 +722,8 @@ const UIStrings = {
|
|
|
717
722
|
runtimeSettingsBenchmark: 'CPU/Memory Power',
|
|
718
723
|
/** Label for a row in a table that shows the version of the Axe library used. Example row values: 2.1.0, 3.2.3 */
|
|
719
724
|
runtimeSettingsAxeVersion: 'Axe version',
|
|
725
|
+
/** Label for a row in a table that shows the screen resolution and DPR that was emulated for the Lighthouse run. Example values: '800x600, DPR: 3' */
|
|
726
|
+
runtimeSettingsScreenEmulation: 'Screen emulation',
|
|
720
727
|
|
|
721
728
|
/** Label for button to create an issue against the Lighthouse GitHub project. */
|
|
722
729
|
footerIssue: 'File an issue',
|
|
@@ -221,6 +221,7 @@ describe('ReportRenderer', () => {
|
|
|
221
221
|
expect(itemsTxt).toContain('RTT');
|
|
222
222
|
expect(itemsTxt).toMatch(/\dx/);
|
|
223
223
|
expect(itemsTxt).toContain(sampleResults.environment.networkUserAgent);
|
|
224
|
+
expect(itemsTxt).toMatch('360x640, DPR 2.625');
|
|
224
225
|
});
|
|
225
226
|
});
|
|
226
227
|
|
|
@@ -33,15 +33,22 @@ describe('util helpers', () => {
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
it('builds device emulation string', () => {
|
|
36
|
-
const get = opts => Util.getEmulationDescriptions(
|
|
36
|
+
const get = opts => Util.getEmulationDescriptions({
|
|
37
|
+
...opts,
|
|
38
|
+
screenEmulation: {disabled: true},
|
|
39
|
+
}).deviceEmulation;
|
|
37
40
|
assert.equal(get({formFactor: 'mobile'}), 'Emulated Moto G4');
|
|
38
41
|
assert.equal(get({formFactor: 'desktop'}), 'Emulated Desktop');
|
|
39
42
|
});
|
|
40
43
|
|
|
41
44
|
it('builds throttling strings when provided', () => {
|
|
42
|
-
const descriptions = Util.getEmulationDescriptions({
|
|
45
|
+
const descriptions = Util.getEmulationDescriptions({
|
|
46
|
+
throttlingMethod: 'provided',
|
|
47
|
+
screenEmulation: {disabled: true},
|
|
48
|
+
});
|
|
43
49
|
assert.equal(descriptions.cpuThrottling, 'Provided by environment');
|
|
44
50
|
assert.equal(descriptions.networkThrottling, 'Provided by environment');
|
|
51
|
+
assert.equal(descriptions.screenEmulation, undefined);
|
|
45
52
|
});
|
|
46
53
|
|
|
47
54
|
it('builds throttling strings when devtools', () => {
|
|
@@ -53,6 +60,7 @@ describe('util helpers', () => {
|
|
|
53
60
|
downloadThroughputKbps: 1400.00000000001,
|
|
54
61
|
uploadThroughputKbps: 600,
|
|
55
62
|
},
|
|
63
|
+
screenEmulation: {disabled: true},
|
|
56
64
|
});
|
|
57
65
|
|
|
58
66
|
// eslint-disable-next-line max-len
|
|
@@ -68,11 +76,13 @@ describe('util helpers', () => {
|
|
|
68
76
|
rttMs: 150,
|
|
69
77
|
throughputKbps: 1600,
|
|
70
78
|
},
|
|
79
|
+
screenEmulation: {width: 100, height: 100, deviceScaleFactor: 2},
|
|
71
80
|
});
|
|
72
81
|
|
|
73
82
|
// eslint-disable-next-line max-len
|
|
74
83
|
assert.equal(descriptions.networkThrottling, '150\xa0ms TCP RTT, 1,600\xa0kb/s throughput (Simulated)');
|
|
75
84
|
assert.equal(descriptions.cpuThrottling, '2x slowdown (Simulated)');
|
|
85
|
+
assert.equal(descriptions.screenEmulation, '100x100, DPR 2');
|
|
76
86
|
});
|
|
77
87
|
|
|
78
88
|
describe('#prepareReportResult', () => {
|
|
@@ -3026,6 +3026,9 @@
|
|
|
3026
3026
|
"report/renderer/util.js | runtimeSettingsNetworkThrottling": {
|
|
3027
3027
|
"message": "Network throttling"
|
|
3028
3028
|
},
|
|
3029
|
+
"report/renderer/util.js | runtimeSettingsScreenEmulation": {
|
|
3030
|
+
"message": "Screen emulation"
|
|
3031
|
+
},
|
|
3029
3032
|
"report/renderer/util.js | runtimeSettingsUANetwork": {
|
|
3030
3033
|
"message": "User agent (network)"
|
|
3031
3034
|
},
|
|
@@ -3026,6 +3026,9 @@
|
|
|
3026
3026
|
"report/renderer/util.js | runtimeSettingsNetworkThrottling": {
|
|
3027
3027
|
"message": "N̂ét̂ẃôŕk̂ t́ĥŕôt́t̂ĺîńĝ"
|
|
3028
3028
|
},
|
|
3029
|
+
"report/renderer/util.js | runtimeSettingsScreenEmulation": {
|
|
3030
|
+
"message": "Ŝćr̂éêń êḿûĺât́îón̂"
|
|
3031
|
+
},
|
|
3029
3032
|
"report/renderer/util.js | runtimeSettingsUANetwork": {
|
|
3030
3033
|
"message": "Ûśêŕ âǵêńt̂ (ńêt́ŵór̂ḱ)"
|
|
3031
3034
|
},
|