From 195daa2f1754d209f4a317dee8a1a67df9e9dfb0 Mon Sep 17 00:00:00 2001 From: Iulian Moraru Date: Fri, 2 Feb 2024 21:23:59 +0200 Subject: [PATCH] Backed out changeset 4726abbc0c2c (bug 1874026) for causing multiple frequent bc failures. CLOSED TREE --- .../ScreenshotsOverlayChild.sys.mjs | 84 ++++++--- .../screenshots/overlay/overlay.css | 6 - .../components/screenshots/overlayHelpers.mjs | 6 +- .../screenshots/tests/browser/browser.toml | 3 - .../browser_screenshots_drag_scroll_test.js | 50 +++-- .../browser_screenshots_short_page_test.js | 40 +++- .../browser_screenshots_test_toggle_pref.js | 2 - .../tests/browser/browser_test_resize.js | 99 ---------- .../screenshots/tests/browser/head.js | 176 +++--------------- .../tests/browser/test-page-resize.html | 25 --- 10 files changed, 151 insertions(+), 340 deletions(-) delete mode 100644 browser/components/screenshots/tests/browser/browser_test_resize.js delete mode 100644 browser/components/screenshots/tests/browser/test-page-resize.html diff --git a/browser/components/screenshots/ScreenshotsOverlayChild.sys.mjs b/browser/components/screenshots/ScreenshotsOverlayChild.sys.mjs index a98354ae874af..89814c215b574 100644 --- a/browser/components/screenshots/ScreenshotsOverlayChild.sys.mjs +++ b/browser/components/screenshots/ScreenshotsOverlayChild.sys.mjs @@ -203,7 +203,7 @@ export class ScreenshotsOverlay { this.#content.root.appendChild(this.fragment); this.initializeElements(); - await this.updateWindowDimensions(); + this.updateWindowDimensions(); this.#setState(STATES.CROSSHAIRS); @@ -1451,13 +1451,13 @@ export class ScreenshotsOverlay { * container size so we don't draw outside the page bounds. * @param {String} eventType will be "scroll" or "resize" */ - async updateScreenshotsOverlayDimensions(eventType) { - let updateWindowDimensionsPromise = this.updateWindowDimensions(); + updateScreenshotsOverlayDimensions(eventType) { + this.updateWindowDimensions(); if (this.#state === STATES.CROSSHAIRS) { if (eventType === "resize") { this.hideHoverElementContainer(); - this.#cachedEle = null; + this.updatePreviewContainer(); } else if (eventType === "scroll") { if (this.#lastClientX && this.#lastClientY) { this.#cachedEle = null; @@ -1465,9 +1465,6 @@ export class ScreenshotsOverlay { } } } else if (this.#state === STATES.SELECTED) { - await updateWindowDimensionsPromise; - this.selectionRegion.shift(); - this.drawSelectionContainer(); this.drawButtonsContainer(); this.updateSelectionSizeText(); } @@ -1530,21 +1527,13 @@ export class ScreenshotsOverlay { } /** - * We have to be careful not to draw the overlay larger than the document - * because the overlay is absolutely position and within the document so we - * can cause the document to overflow when it shouldn't. To mitigate this, - * we will temporarily position the overlay to position fixed with width and - * height 100% so the overlay is within the document bounds. Then we will get - * the dimensions of the document to correctly draw the overlay. + * Update the screenshots container because the window has changed size of + * scrolled. The screenshots-overlay-container doesn't shrink with the page + * when the window is resized so we have to manually find the width and + * height of the page and make sure we aren't drawing outside the actual page + * dimensions. */ - async updateWindowDimensions() { - // Setting the screenshots container attribute "resizing" will make the - // overlay fixed position with width and height of 100% percent so it - // does not draw outside the actual document. - this.screenshotsContainer.toggleAttribute("resizing", true); - - await new Promise(r => this.window.requestAnimationFrame(r)); - + updateWindowDimensions() { let { clientWidth, clientHeight, @@ -1555,7 +1544,49 @@ export class ScreenshotsOverlay { scrollMinX, scrollMinY, } = this.getDimensionsFromWindow(); - this.screenshotsContainer.toggleAttribute("resizing", false); + + let shouldUpdate = true; + + if ( + clientHeight < this.windowDimensions.clientHeight || + clientWidth < this.windowDimensions.clientWidth + ) { + let widthDiff = this.windowDimensions.clientWidth - clientWidth; + let heightDiff = this.windowDimensions.clientHeight - clientHeight; + + this.windowDimensions.dimensions = { + scrollWidth: scrollWidth - Math.max(widthDiff, 0), + scrollHeight: scrollHeight - Math.max(heightDiff, 0), + clientWidth, + clientHeight, + }; + + if (this.#state === STATES.SELECTED) { + let didShift = this.selectionRegion.shift(); + if (didShift) { + this.drawSelectionContainer(); + this.drawButtonsContainer(); + } + } else if (this.#state === STATES.CROSSHAIRS) { + this.updatePreviewContainer(); + } + this.updateScreenshotsOverlayContainer(); + // We just updated the screenshots container so we check if the window + // dimensions are still accurate + let { scrollWidth: updatedWidth, scrollHeight: updatedHeight } = + this.getDimensionsFromWindow(); + + // If the width and height are the same then we don't need to draw the overlay again + if (updatedWidth === scrollWidth && updatedHeight === scrollHeight) { + shouldUpdate = false; + } + + scrollWidth = updatedWidth; + scrollHeight = updatedHeight; + } + + setMaxDetectHeight(Math.max(clientHeight + 100, 700)); + setMaxDetectWidth(Math.max(clientWidth + 100, 1000)); this.windowDimensions.dimensions = { clientWidth, @@ -1569,10 +1600,9 @@ export class ScreenshotsOverlay { devicePixelRatio: this.window.devicePixelRatio, }; - this.updatePreviewContainer(); - this.updateScreenshotsOverlayContainer(); - - setMaxDetectHeight(Math.max(clientHeight + 100, 700)); - setMaxDetectWidth(Math.max(clientWidth + 100, 1000)); + if (shouldUpdate) { + this.updatePreviewContainer(); + this.updateScreenshotsOverlayContainer(); + } } } diff --git a/browser/components/screenshots/overlay/overlay.css b/browser/components/screenshots/overlay/overlay.css index 6eeda8b44c728..5c58eef912c40 100644 --- a/browser/components/screenshots/overlay/overlay.css +++ b/browser/components/screenshots/overlay/overlay.css @@ -24,12 +24,6 @@ &[dragging] { cursor: grabbing; } - - &[resizing] { - position: fixed; - width: 100% !important; - height: 100% !important; - } } #selection-container { diff --git a/browser/components/screenshots/overlayHelpers.mjs b/browser/components/screenshots/overlayHelpers.mjs index 4c58014895681..46ef7a3cf8c3c 100644 --- a/browser/components/screenshots/overlayHelpers.mjs +++ b/browser/components/screenshots/overlayHelpers.mjs @@ -248,16 +248,18 @@ export class Region { let didShift = false; let xDiff = this.right - this.#windowDimensions.scrollWidth; if (xDiff > 0) { - this.left -= xDiff; this.right -= xDiff; + this.left -= xDiff; didShift = true; } let yDiff = this.bottom - this.#windowDimensions.scrollHeight; if (yDiff > 0) { - this.top -= yDiff; + let curHeight = this.height; + this.bottom -= yDiff; + this.top = this.bottom - curHeight; didShift = true; } diff --git a/browser/components/screenshots/tests/browser/browser.toml b/browser/components/screenshots/tests/browser/browser.toml index 4d77727819cde..27e49f349af51 100644 --- a/browser/components/screenshots/tests/browser/browser.toml +++ b/browser/components/screenshots/tests/browser/browser.toml @@ -4,7 +4,6 @@ support-files = [ "test-page.html", "short-test-page.html", "large-test-page.html", - "test-page-resize.html", ] prefs = [ @@ -46,5 +45,3 @@ skip-if = ["!crashreporter"] ["browser_screenshots_test_visible.js"] ["browser_test_element_picker.js"] - -["browser_test_resize.js"] diff --git a/browser/components/screenshots/tests/browser/browser_screenshots_drag_scroll_test.js b/browser/components/screenshots/tests/browser/browser_screenshots_drag_scroll_test.js index 7fdb084ca61c3..a8e074b78b285 100644 --- a/browser/components/screenshots/tests/browser/browser_screenshots_drag_scroll_test.js +++ b/browser/components/screenshots/tests/browser/browser_screenshots_drag_scroll_test.js @@ -227,7 +227,7 @@ add_task(async function test_scrollingScreenshotsOpen() { is(dimensions.height, endY - startY, "The box height is now 90"); // reset screenshots box - await helper.escapeKeyInContent(); + mouse.click(scrollX + startX, scrollY + endY); await helper.assertStateChange("crosshairs"); await helper.dragOverlay( @@ -247,7 +247,7 @@ add_task(async function test_scrollingScreenshotsOpen() { is(dimensions.height, endY - startY, "The box height is now 90"); // reset screenshots box - await helper.escapeKeyInContent(); + mouse.click(10, 10); await helper.assertStateChange("crosshairs"); await helper.dragOverlay( @@ -380,7 +380,11 @@ add_task(async function test_scrollIfByEdge() { contentInfo )}\n` ); - await helper.dragOverlay(startX, startY, endX, endY, "selected"); + mouse.down(startX, startY); + await helper.assertStateChange("resizing"); + mouse.move(endX, endY); + mouse.up(endX, endY); + await helper.assertStateChange("selected"); windowX = 1000; windowY = 1000; @@ -419,12 +423,20 @@ add_task(async function test_scrollIfByEdgeWithKeyboard() { await helper.dragOverlay(1020, 1020, 1120, 1120); - await helper.moveOverlayViaKeyboard("highlight", [ - { key: "ArrowLeft", options: { shiftKey: true } }, - { key: "ArrowLeft", options: {} }, - { key: "ArrowUp", options: { shiftKey: true } }, - { key: "ArrowUp", options: {} }, - ]); + await SpecialPowers.spawn(browser, [], async () => { + let screenshotsChild = content.windowGlobalChild.getActor( + "ScreenshotsComponent" + ); + + // Test moving each corner of the region + screenshotsChild.overlay.highlightEl.focus(); + + EventUtils.synthesizeKey("ArrowLeft", { shiftKey: true }, content); + EventUtils.synthesizeKey("ArrowLeft", {}, content); + + EventUtils.synthesizeKey("ArrowUp", { shiftKey: true }, content); + EventUtils.synthesizeKey("ArrowUp", {}, content); + }); windowX = 989; windowY = 989; @@ -445,12 +457,20 @@ add_task(async function test_scrollIfByEdgeWithKeyboard() { scrollY + clientHeight - 20 ); - await helper.moveOverlayViaKeyboard("highlight", [ - { key: "ArrowRight", options: { shiftKey: true } }, - { key: "ArrowRight", options: {} }, - { key: "ArrowDown", options: { shiftKey: true } }, - { key: "ArrowDown", options: {} }, - ]); + await SpecialPowers.spawn(browser, [], async () => { + let screenshotsChild = content.windowGlobalChild.getActor( + "ScreenshotsComponent" + ); + + // Test moving each corner of the region + screenshotsChild.overlay.highlightEl.focus(); + + EventUtils.synthesizeKey("ArrowRight", { shiftKey: true }, content); + EventUtils.synthesizeKey("ArrowRight", {}, content); + + EventUtils.synthesizeKey("ArrowDown", { shiftKey: true }, content); + EventUtils.synthesizeKey("ArrowDown", {}, content); + }); windowX = 1000; windowY = 1000; diff --git a/browser/components/screenshots/tests/browser/browser_screenshots_short_page_test.js b/browser/components/screenshots/tests/browser/browser_screenshots_short_page_test.js index bebc70e915c32..4cbba923958b9 100644 --- a/browser/components/screenshots/tests/browser/browser_screenshots_short_page_test.js +++ b/browser/components/screenshots/tests/browser/browser_screenshots_short_page_test.js @@ -58,7 +58,20 @@ add_task(async function test_window_resize() { const BIG_WINDOW_SIZE = 920; const SMALL_WINDOW_SIZE = 620; - await helper.resizeContentWindow(SMALL_WINDOW_SIZE, SMALL_WINDOW_SIZE); + window.resizeTo(SMALL_WINDOW_SIZE, SMALL_WINDOW_SIZE); + await TestUtils.waitForCondition(() => { + info( + `Got ${window.outerWidth}x${ + window.outerHeight + }. Expecting ${SMALL_WINDOW_SIZE}. ${ + window.outerHeight === SMALL_WINDOW_SIZE + } ${window.outerWidth === SMALL_WINDOW_SIZE}` + ); + return ( + window.outerHeight === SMALL_WINDOW_SIZE && + window.outerWidth === SMALL_WINDOW_SIZE + ); + }, "Waiting for window to resize"); helper.triggerUIFromToolbar(); await helper.waitForOverlay(); @@ -68,7 +81,13 @@ add_task(async function test_window_resize() { let oldWidth = dimensions.scrollWidth; let oldHeight = dimensions.scrollHeight; - await helper.resizeContentWindow(BIG_WINDOW_SIZE, BIG_WINDOW_SIZE); + window.resizeTo(BIG_WINDOW_SIZE, BIG_WINDOW_SIZE); + await TestUtils.waitForCondition( + () => + window.outerHeight === BIG_WINDOW_SIZE && + window.outerWidth === BIG_WINDOW_SIZE, + "Waiting for window to resize" + ); await helper.waitForSelectionLayerDimensionChange(oldWidth, oldHeight); contentInfo = await helper.getContentDimensions(); @@ -87,7 +106,13 @@ add_task(async function test_window_resize() { oldWidth = dimensions.scrollWidth; oldHeight = dimensions.scrollHeight; - await helper.resizeContentWindow(SMALL_WINDOW_SIZE, SMALL_WINDOW_SIZE); + window.resizeTo(SMALL_WINDOW_SIZE, SMALL_WINDOW_SIZE); + await TestUtils.waitForCondition( + () => + window.outerHeight === SMALL_WINDOW_SIZE && + window.outerWidth === SMALL_WINDOW_SIZE, + "Waiting for window to resize" + ); await helper.waitForSelectionLayerDimensionChange(oldWidth, oldHeight); contentInfo = await helper.getContentDimensions(); @@ -114,9 +139,12 @@ add_task(async function test_window_resize() { "Screenshots overlay is smaller than the big window height" ); - await helper.resizeContentWindow( - originalWindowWidth, - originalWindowHeight + window.resizeTo(originalWindowWidth, originalWindowHeight); + await TestUtils.waitForCondition( + () => + window.outerHeight === originalWindowHeight && + window.outerWidth === originalWindowWidth, + "Waiting for window to resize" ); } ); diff --git a/browser/components/screenshots/tests/browser/browser_screenshots_test_toggle_pref.js b/browser/components/screenshots/tests/browser/browser_screenshots_test_toggle_pref.js index 0aafba8fb3a8f..3e5ce429f85e7 100644 --- a/browser/components/screenshots/tests/browser/browser_screenshots_test_toggle_pref.js +++ b/browser/components/screenshots/tests/browser/browser_screenshots_test_toggle_pref.js @@ -284,6 +284,4 @@ add_task(async function test() { observerStub.restore(); notifierStub.restore(); - - await SpecialPowers.popPrefEnv(); }); diff --git a/browser/components/screenshots/tests/browser/browser_test_resize.js b/browser/components/screenshots/tests/browser/browser_test_resize.js deleted file mode 100644 index 84e05b49b1478..0000000000000 --- a/browser/components/screenshots/tests/browser/browser_test_resize.js +++ /dev/null @@ -1,99 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -const windowWidth = 768; -const windowHeight = 1024; - -add_task(async function test_window_resize() { - await BrowserTestUtils.withNewTab( - { - gBrowser, - url: RESIZE_TEST_PAGE, - }, - async browser => { - let helper = new ScreenshotsHelper(browser); - await helper.resizeContentWindow(windowWidth, windowHeight); - const originalContentDimensions = await helper.getContentDimensions(); - info(JSON.stringify(originalContentDimensions, null, 2)); - await helper.zoomBrowser(1.5); - - helper.triggerUIFromToolbar(); - await helper.waitForOverlay(); - - await helper.scrollContentWindow(windowWidth, windowHeight); - - await helper.clickTestPageElement("hello"); - - await helper.zoomBrowser(1); - - await helper.waitForOverlaySizeChangeTo( - originalContentDimensions.scrollWidth, - originalContentDimensions.scrollHeight - ); - - let contentDims = await helper.getContentDimensions(); - info(JSON.stringify(contentDims, null, 2)); - - is( - contentDims.scrollWidth, - originalContentDimensions.scrollWidth, - "Width of page is back to original" - ); - is( - contentDims.scrollHeight, - originalContentDimensions.scrollHeight, - "Height of page is back to original" - ); - } - ); -}); - -add_task(async function test_window_resize_vertical_writing_mode() { - await BrowserTestUtils.withNewTab( - { - gBrowser, - url: RESIZE_TEST_PAGE, - }, - async browser => { - await SpecialPowers.spawn(browser, [], () => { - content.document.documentElement.style = "writing-mode: vertical-lr;"; - }); - - let helper = new ScreenshotsHelper(browser); - await helper.resizeContentWindow(windowWidth, windowHeight); - const originalContentDimensions = await helper.getContentDimensions(); - info(JSON.stringify(originalContentDimensions, null, 2)); - await helper.zoomBrowser(1.5); - - helper.triggerUIFromToolbar(); - await helper.waitForOverlay(); - - await helper.scrollContentWindow(windowWidth, windowHeight); - - await helper.clickTestPageElement("hello"); - - await helper.zoomBrowser(1); - - await helper.waitForOverlaySizeChangeTo( - originalContentDimensions.scrollWidth, - originalContentDimensions.scrollHeight - ); - - let contentDims = await helper.getContentDimensions(); - info(JSON.stringify(contentDims, null, 2)); - - is( - contentDims.scrollWidth, - originalContentDimensions.scrollWidth, - "Width of page is back to original" - ); - is( - contentDims.scrollHeight, - originalContentDimensions.scrollHeight, - "Height of page is back to original" - ); - } - ); -}); diff --git a/browser/components/screenshots/tests/browser/head.js b/browser/components/screenshots/tests/browser/head.js index 62d3cfdd15e8e..7268f608a1d96 100644 --- a/browser/components/screenshots/tests/browser/head.js +++ b/browser/components/screenshots/tests/browser/head.js @@ -18,7 +18,6 @@ const TEST_ROOT = getRootDirectory(gTestPath).replace( const TEST_PAGE = TEST_ROOT + "test-page.html"; const SHORT_TEST_PAGE = TEST_ROOT + "short-test-page.html"; const LARGE_TEST_PAGE = TEST_ROOT + "large-test-page.html"; -const RESIZE_TEST_PAGE = TEST_ROOT + "test-page-resize.html"; const { MAX_CAPTURE_DIMENSION, MAX_CAPTURE_AREA } = ChromeUtils.importESModule( "resource:///modules/ScreenshotsUtils.sys.mjs" @@ -152,21 +151,22 @@ class ScreenshotsHelper { }); } - waitForStateChange(newState) { - return SpecialPowers.spawn(this.browser, [newState], async state => { + async getOverlayState() { + return ContentTask.spawn(this.browser, null, async () => { let screenshotsChild = content.windowGlobalChild.getActor( "ScreenshotsComponent" ); - - await ContentTaskUtils.waitForCondition( - () => screenshotsChild.overlay.state === state, - `Wait for overlay state to be ${state}` - ); - return screenshotsChild.overlay.state; }); } + async waitForStateChange(newState) { + return BrowserTestUtils.waitForCondition(async () => { + let state = await this.getOverlayState(); + return state === newState ? state : ""; + }, `Waiting for state change to ${newState}`); + } + async assertStateChange(newState) { let currentState = await this.waitForStateChange(newState); @@ -273,85 +273,14 @@ class ScreenshotsHelper { this.endY = endY; } - async moveOverlayViaKeyboard(mover, events) { - await SpecialPowers.spawn( - this.browser, - [mover, events], - async (moverToFocus, eventsArr) => { - let screenshotsChild = content.windowGlobalChild.getActor( - "ScreenshotsComponent" - ); - - let overlay = screenshotsChild.overlay; - - switch (moverToFocus) { - case "highlight": - overlay.highlightEl.focus({ focusVisible: true }); - break; - case "mover-bottomLeft": - overlay.bottomLeftMover.focus({ focusVisible: true }); - break; - case "mover-bottomRight": - overlay.bottomRightMover.focus({ focusVisible: true }); - break; - case "mover-topLeft": - overlay.topLeftMover.focus({ focusVisible: true }); - break; - case "mover-topRight": - overlay.topRightMover.focus({ focusVisible: true }); - break; - } - screenshotsChild.overlay.highlightEl.focus(); - - for (let event of eventsArr) { - EventUtils.synthesizeKey( - event.key, - { type: "keydown", ...event.options }, - content - ); - - await ContentTaskUtils.waitForCondition( - () => overlay.state === "resizing", - "Wait for overlay state to be resizing" - ); - - EventUtils.synthesizeKey( - event.key, - { type: "keyup", ...event.options }, - content - ); - - await ContentTaskUtils.waitForCondition( - () => overlay.state === "selected", - "Wait for overlay state to be selected" - ); - } - } - ); - } - async scrollContentWindow(x, y) { let promise = BrowserTestUtils.waitForContentEvent(this.browser, "scroll"); await ContentTask.spawn(this.browser, [x, y], async ([xPos, yPos]) => { content.window.scroll(xPos, yPos); await ContentTaskUtils.waitForCondition(() => { - function isCloseEnough(a, b, diff) { - return Math.abs(a - b) <= diff; - } - - info( - `got: ${content.window.scrollX}, ${content.window.scrollY}, ${content.window.scrollMaxX}, ${content.window.scrollMaxY}` - ); return ( - (content.window.scrollX === xPos || - isCloseEnough( - content.window.scrollX, - content.window.scrollMaxX, - 1 - )) && - (content.window.scrollY === yPos || - isCloseEnough(content.window.scrollY, content.window.scrollMaxY, 1)) + content.window.scrollX === xPos && content.window.scrollY === yPos ); }, `Waiting for window to scroll to ${xPos}, ${yPos}`); }); @@ -371,14 +300,6 @@ class ScreenshotsHelper { }); } - async resizeContentWindow(width, height) { - this.browser.ownerGlobal.resizeTo(width, height); - await TestUtils.waitForCondition( - () => window.outerHeight === height && window.outerWidth === width, - "Waiting for window to resize" - ); - } - async clickDownloadButton() { let { centerX: x, centerY: y } = await ContentTask.spawn( this.browser, @@ -459,25 +380,18 @@ class ScreenshotsHelper { mouse.click(x, y); } - escapeKeyInContent() { - return SpecialPowers.spawn(this.browser, [], () => { - EventUtils.synthesizeKey("KEY_Escape", {}, content); - }); - } - - getTestPageElementRect(elementId = "testPageElement") { - return ContentTask.spawn(this.browser, [elementId], async id => { - let ele = content.document.getElementById(id); + getTestPageElementRect() { + return ContentTask.spawn(this.browser, [], async () => { + let ele = content.document.getElementById("testPageElement"); return ele.getBoundingClientRect(); }); } - async clickTestPageElement(elementId = "testPageElement") { - let rect = await this.getTestPageElementRect(elementId); - let dims = await this.getContentDimensions(); + async clickTestPageElement() { + let rect = await this.getTestPageElementRect(); - let x = Math.floor(rect.x + dims.scrollX + rect.width / 2); - let y = Math.floor(rect.y + dims.scrollY + rect.height / 2); + let x = Math.floor(rect.x + rect.width / 2); + let y = Math.floor(rect.y + rect.height / 2); mouse.move(x, y); await this.waitForHoverElementRect(); @@ -488,14 +402,12 @@ class ScreenshotsHelper { } async zoomBrowser(zoom) { - let promise = BrowserTestUtils.waitForContentEvent(this.browser, "resize"); await SpecialPowers.spawn(this.browser, [zoom], zoomLevel => { const { Layout } = ChromeUtils.importESModule( "chrome://mochitests/content/browser/accessible/tests/browser/Layout.sys.mjs" ); Layout.zoomDocument(content.document, zoomLevel); }); - await promise; } /** @@ -604,28 +516,17 @@ class ScreenshotsHelper { }); } - async getScreenshotsOverlayDimensions() { + getScreenshotsOverlayDimensions() { return ContentTask.spawn(this.browser, null, async () => { let screenshotsChild = content.windowGlobalChild.getActor( "ScreenshotsComponent" ); Assert.ok(screenshotsChild.overlay.initialized, "The overlay exists"); - let screenshotsContainer = screenshotsChild.overlay.screenshotsContainer; - - await ContentTaskUtils.waitForCondition(() => { - return !screenshotsContainer.hasAttribute("resizing"); - }, "Waiting for overlay to be done resizing"); - - info( - `${screenshotsContainer.style.width} ${ - screenshotsContainer.style.height - } ${screenshotsContainer.hasAttribute("resizing")}` - ); - return { - scrollWidth: screenshotsContainer.scrollWidth, - scrollHeight: screenshotsContainer.scrollHeight, + scrollWidth: screenshotsChild.overlay.screenshotsContainer.scrollWidth, + scrollHeight: + screenshotsChild.overlay.screenshotsContainer.scrollHeight, }; }); } @@ -654,41 +555,6 @@ class ScreenshotsHelper { ); } - waitForOverlaySizeChangeTo(width, height) { - return ContentTask.spawn( - this.browser, - [width, height], - async ([newWidth, newHeight]) => { - await ContentTaskUtils.waitForCondition(() => { - let { - innerHeight, - innerWidth, - scrollMaxY, - scrollMaxX, - scrollMinY, - scrollMinX, - } = content.window; - let scrollWidth = innerWidth + scrollMaxX - scrollMinX; - let scrollHeight = innerHeight + scrollMaxY - scrollMinY; - - const scrollbarHeight = {}; - const scrollbarWidth = {}; - content.window.windowUtils.getScrollbarSize( - false, - scrollbarWidth, - scrollbarHeight - ); - scrollWidth -= scrollbarWidth.value; - scrollHeight -= scrollbarHeight.value; - info( - `${scrollHeight}, ${newHeight}, ${scrollWidth}, ${newWidth}, ${content.window.scrollMaxX}` - ); - return scrollHeight === newHeight && scrollWidth === newWidth; - }, "Wait for document size change"); - } - ); - } - getSelectionRegionDimensions() { return ContentTask.spawn(this.browser, null, async () => { let screenshotsChild = content.windowGlobalChild.getActor( diff --git a/browser/components/screenshots/tests/browser/test-page-resize.html b/browser/components/screenshots/tests/browser/test-page-resize.html deleted file mode 100644 index dea57909b4f96..0000000000000 --- a/browser/components/screenshots/tests/browser/test-page-resize.html +++ /dev/null @@ -1,25 +0,0 @@ - - - Screenshots - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -