lighthouse 9.5.0-dev.20220519 → 9.5.0-dev.20220522
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.
|
@@ -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;
|
|
@@ -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,
|
|
@@ -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;
|