lighthouse 9.5.0-dev.20220517 → 9.5.0-dev.20220520
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/lighthouse-core/gather/driver/execution-context.js +1 -0
- package/lighthouse-core/gather/driver/navigation.js +4 -1
- package/lighthouse-core/gather/gatherers/iframe-elements.js +4 -1
- package/lighthouse-core/gather/gatherers/image-elements.js +2 -0
- package/lighthouse-core/lib/page-functions.js +3 -1
- package/package.json +1 -1
- package/types/externs.d.ts +1 -0
|
@@ -215,6 +215,7 @@ class ExecutionContext {
|
|
|
215
215
|
window.__nativePerformance = window.performance;
|
|
216
216
|
window.__nativeFetch = window.fetch;
|
|
217
217
|
window.__ElementMatches = window.Element.prototype.matches;
|
|
218
|
+
window.__HTMLElementBoundingClientRect = window.HTMLElement.prototype.getBoundingClientRect;
|
|
218
219
|
// Ensure the native `performance.now` is not overwritable.
|
|
219
220
|
const performance = window.performance;
|
|
220
221
|
const performanceNow = window.performance.now;
|
|
@@ -131,7 +131,10 @@ async function gotoURL(driver, requestor, options) {
|
|
|
131
131
|
let requestedUrl = navigationUrls.requestedUrl;
|
|
132
132
|
if (typeof requestor === 'string') {
|
|
133
133
|
if (requestedUrl && !URL.equalWithExcludedFragments(requestor, requestedUrl)) {
|
|
134
|
-
log.error(
|
|
134
|
+
log.error(
|
|
135
|
+
'Navigation',
|
|
136
|
+
`Provided URL (${requestor}) did not match initial navigation URL (${requestedUrl})`
|
|
137
|
+
);
|
|
135
138
|
}
|
|
136
139
|
requestedUrl = requestor;
|
|
137
140
|
}
|
|
@@ -17,10 +17,13 @@ const pageFunctions = require('../../lib/page-functions.js');
|
|
|
17
17
|
*/
|
|
18
18
|
/* c8 ignore start */
|
|
19
19
|
function collectIFrameElements() {
|
|
20
|
+
const realBoundingClientRect = window.__HTMLElementBoundingClientRect ||
|
|
21
|
+
window.HTMLElement.prototype.getBoundingClientRect;
|
|
22
|
+
|
|
20
23
|
// @ts-expect-error - put into scope via stringification
|
|
21
24
|
const iFrameElements = getElementsInDocument('iframe'); // eslint-disable-line no-undef
|
|
22
25
|
return iFrameElements.map(/** @param {HTMLIFrameElement} node */ (node) => {
|
|
23
|
-
const clientRect =
|
|
26
|
+
const clientRect = realBoundingClientRect.call(node);
|
|
24
27
|
const {top, bottom, left, right, width, height} = clientRect;
|
|
25
28
|
return {
|
|
26
29
|
id: node.id,
|
|
@@ -258,6 +258,7 @@ class ImageElements extends FRGatherer {
|
|
|
258
258
|
driver.defaultSession.setNextProtocolTimeout(250);
|
|
259
259
|
size = await driver.executionContext.evaluate(determineNaturalSize, {
|
|
260
260
|
args: [url],
|
|
261
|
+
useIsolation: true,
|
|
261
262
|
});
|
|
262
263
|
this._naturalSizeCache.set(url, size);
|
|
263
264
|
} catch (_) {
|
|
@@ -340,6 +341,7 @@ class ImageElements extends FRGatherer {
|
|
|
340
341
|
|
|
341
342
|
const elements = await executionContext.evaluate(collectImageElementInfo, {
|
|
342
343
|
args: [],
|
|
344
|
+
useIsolation: true,
|
|
343
345
|
deps: [
|
|
344
346
|
pageFunctions.getElementsInDocumentString,
|
|
345
347
|
pageFunctions.getBoundingClientRectString,
|
|
@@ -434,8 +434,10 @@ function getNodeLabel(element) {
|
|
|
434
434
|
* @return {LH.Artifacts.Rect}
|
|
435
435
|
*/
|
|
436
436
|
function getBoundingClientRect(element) {
|
|
437
|
+
const realBoundingClientRect = window.__HTMLElementBoundingClientRect ||
|
|
438
|
+
window.HTMLElement.prototype.getBoundingClientRect;
|
|
437
439
|
// The protocol does not serialize getters, so extract the values explicitly.
|
|
438
|
-
const rect =
|
|
440
|
+
const rect = realBoundingClientRect.call(element);
|
|
439
441
|
return {
|
|
440
442
|
top: Math.round(rect.top),
|
|
441
443
|
bottom: Math.round(rect.bottom),
|
package/package.json
CHANGED
package/types/externs.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ declare global {
|
|
|
23
23
|
__nativeFetch: typeof fetch,
|
|
24
24
|
__nativeURL: typeof URL;
|
|
25
25
|
__ElementMatches: Element['matches'];
|
|
26
|
+
__HTMLElementBoundingClientRect: HTMLElement['getBoundingClientRect'];
|
|
26
27
|
|
|
27
28
|
/** Used for monitoring long tasks in the test page. */
|
|
28
29
|
____lastLongTask?: number;
|