lighthouse 11.6.0-dev.20240307 → 11.6.0-dev.20240308
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.
|
@@ -17,6 +17,7 @@ import formsAutoComplete from './test-definitions/forms-autocomplete.js';
|
|
|
17
17
|
import fpsMax from './test-definitions/fps-max.js';
|
|
18
18
|
import fpsMaxPassive from './test-definitions/fps-max-passive.js';
|
|
19
19
|
import fpsScaled from './test-definitions/fps-scaled.js';
|
|
20
|
+
import fpsOverflowX from './test-definitions/fps-overflow-x.js';
|
|
20
21
|
import issuesMixedContent from './test-definitions/issues-mixed-content.js';
|
|
21
22
|
import lanternFetch from './test-definitions/lantern-fetch.js';
|
|
22
23
|
import lanternIdleCallbackLong from './test-definitions/lantern-idle-callback-long.js';
|
|
@@ -80,6 +81,7 @@ const smokeTests = [
|
|
|
80
81
|
formsAutoComplete,
|
|
81
82
|
fpsMax,
|
|
82
83
|
fpsMaxPassive,
|
|
84
|
+
fpsOverflowX,
|
|
83
85
|
fpsScaled,
|
|
84
86
|
issuesMixedContent,
|
|
85
87
|
lanternFetch,
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export default FullPageScreenshot;
|
|
2
2
|
declare class FullPageScreenshot extends BaseGatherer {
|
|
3
|
+
/**
|
|
4
|
+
* @param {LH.Gatherer.Context} context
|
|
5
|
+
*/
|
|
6
|
+
waitForNetworkIdle(context: LH.Gatherer.Context): import("../driver/wait-for-condition.js").CancellableWait<void>;
|
|
3
7
|
/**
|
|
4
8
|
* @param {LH.Gatherer.Context} context
|
|
5
9
|
* @param {{height: number, width: number, mobile: boolean}} deviceMetrics
|
|
@@ -13,7 +13,10 @@ import {waitForNetworkIdle} from '../driver/wait-for-condition.js';
|
|
|
13
13
|
// JPEG quality setting
|
|
14
14
|
// Exploration and examples of reports using different quality settings: https://docs.google.com/document/d/1ZSffucIca9XDW2eEwfoevrk-OTl7WQFeMf0CgeJAA8M/edit#
|
|
15
15
|
// Note: this analysis was done for JPEG, but now we use WEBP.
|
|
16
|
-
const FULL_PAGE_SCREENSHOT_QUALITY = 30;
|
|
16
|
+
const FULL_PAGE_SCREENSHOT_QUALITY = process.env.LH_FPS_TEST ? 100 : 30;
|
|
17
|
+
// webp currently cant do lossless encoding, so to help tests switch to png
|
|
18
|
+
// Remove when this is resolved: https://bugs.chromium.org/p/chromium/issues/detail?id=1469183
|
|
19
|
+
const FULL_PAGE_SCREENSHOT_FORMAT = process.env.LH_FPS_TEST ? 'png' : 'webp';
|
|
17
20
|
|
|
18
21
|
// https://developers.google.com/speed/webp/faq#what_is_the_maximum_size_a_webp_image_can_be
|
|
19
22
|
const MAX_WEBP_SIZE = 16383;
|
|
@@ -44,17 +47,6 @@ function getObservedDeviceMetrics() {
|
|
|
44
47
|
};
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
/**
|
|
48
|
-
* The screenshot dimensions are sized to `window.outerHeight` / `window.outerWidth`,
|
|
49
|
-
* however the bounding boxes of the elements are relative to `window.innerHeight` / `window.innerWidth`.
|
|
50
|
-
*/
|
|
51
|
-
function getScreenshotAreaSize() {
|
|
52
|
-
return {
|
|
53
|
-
width: window.innerWidth,
|
|
54
|
-
height: window.innerHeight,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
50
|
function waitForDoubleRaf() {
|
|
59
51
|
return new Promise((resolve) => {
|
|
60
52
|
requestAnimationFrame(() => requestAnimationFrame(resolve));
|
|
@@ -69,6 +61,21 @@ class FullPageScreenshot extends BaseGatherer {
|
|
|
69
61
|
supportedModes: ['snapshot', 'timespan', 'navigation'],
|
|
70
62
|
};
|
|
71
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @param {LH.Gatherer.Context} context
|
|
66
|
+
*/
|
|
67
|
+
waitForNetworkIdle(context) {
|
|
68
|
+
const session = context.driver.defaultSession;
|
|
69
|
+
const networkMonitor = context.driver.networkMonitor;
|
|
70
|
+
return waitForNetworkIdle(session, networkMonitor, {
|
|
71
|
+
pretendDCLAlreadyFired: true,
|
|
72
|
+
networkQuietThresholdMs: 1000,
|
|
73
|
+
busyEvent: 'network-critical-busy',
|
|
74
|
+
idleEvent: 'network-critical-idle',
|
|
75
|
+
isIdle: recorder => recorder.isCriticalIdle(),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
72
79
|
/**
|
|
73
80
|
* @param {LH.Gatherer.Context} context
|
|
74
81
|
* @param {{height: number, width: number, mobile: boolean}} deviceMetrics
|
|
@@ -86,15 +93,7 @@ class FullPageScreenshot extends BaseGatherer {
|
|
|
86
93
|
);
|
|
87
94
|
const height = Math.min(fullHeight, MAX_WEBP_SIZE);
|
|
88
95
|
|
|
89
|
-
|
|
90
|
-
const networkMonitor = context.driver.networkMonitor;
|
|
91
|
-
const waitForNetworkIdleResult = waitForNetworkIdle(session, networkMonitor, {
|
|
92
|
-
pretendDCLAlreadyFired: true,
|
|
93
|
-
networkQuietThresholdMs: 1000,
|
|
94
|
-
busyEvent: 'network-critical-busy',
|
|
95
|
-
idleEvent: 'network-critical-idle',
|
|
96
|
-
isIdle: recorder => recorder.isCriticalIdle(),
|
|
97
|
-
});
|
|
96
|
+
const waitForNetworkIdleResult = this.waitForNetworkIdle(context);
|
|
98
97
|
|
|
99
98
|
await session.sendCommand('Emulation.setDeviceMetricsOverride', {
|
|
100
99
|
mobile: deviceMetrics.mobile,
|
|
@@ -120,22 +119,17 @@ class FullPageScreenshot extends BaseGatherer {
|
|
|
120
119
|
* @return {Promise<LH.Result.FullPageScreenshot['screenshot']>}
|
|
121
120
|
*/
|
|
122
121
|
async _takeScreenshot(context) {
|
|
122
|
+
const metrics = await context.driver.defaultSession.sendCommand('Page.getLayoutMetrics');
|
|
123
123
|
const result = await context.driver.defaultSession.sendCommand('Page.captureScreenshot', {
|
|
124
|
-
format:
|
|
124
|
+
format: FULL_PAGE_SCREENSHOT_FORMAT,
|
|
125
125
|
quality: FULL_PAGE_SCREENSHOT_QUALITY,
|
|
126
126
|
});
|
|
127
|
-
const data =
|
|
128
|
-
|
|
129
|
-
const screenshotAreaSize =
|
|
130
|
-
await context.driver.executionContext.evaluate(getScreenshotAreaSize, {
|
|
131
|
-
args: [],
|
|
132
|
-
useIsolation: true,
|
|
133
|
-
});
|
|
127
|
+
const data = `data:image/${FULL_PAGE_SCREENSHOT_FORMAT};base64,` + result.data;
|
|
134
128
|
|
|
135
129
|
return {
|
|
136
130
|
data,
|
|
137
|
-
width:
|
|
138
|
-
height:
|
|
131
|
+
width: metrics.cssVisualViewport.clientWidth,
|
|
132
|
+
height: metrics.cssVisualViewport.clientHeight,
|
|
139
133
|
};
|
|
140
134
|
}
|
|
141
135
|
|
|
@@ -159,7 +153,7 @@ class FullPageScreenshot extends BaseGatherer {
|
|
|
159
153
|
for (const [node, id] of lhIdToElements.entries()) {
|
|
160
154
|
// @ts-expect-error - getBoundingClientRect put into scope via stringification
|
|
161
155
|
const rect = getBoundingClientRect(node);
|
|
162
|
-
nodes[id] = rect;
|
|
156
|
+
nodes[id] = {id: node.id, ...rect};
|
|
163
157
|
}
|
|
164
158
|
|
|
165
159
|
return nodes;
|
package/package.json
CHANGED