diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/base/content/test/popups/browser_popup_new_window_resize.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | browser/base/content/test/popups/browser_popup_new_window_resize.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/browser/base/content/test/popups/browser_popup_new_window_resize.js b/browser/base/content/test/popups/browser_popup_new_window_resize.js new file mode 100644 index 0000000000..81d3cf5a9a --- /dev/null +++ b/browser/base/content/test/popups/browser_popup_new_window_resize.js @@ -0,0 +1,51 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +add_task(async function test_new_window_resize() { + let tab = await BrowserTestUtils.openNewForegroundTab( + window.gBrowser, + "https://example.net" + ); + + await SpecialPowers.spawn(tab.linkedBrowser, [], async () => { + info("Opening popup."); + let win = this.content.open( + "https://example.net", + "", + "width=200,height=200" + ); + + await ContentTaskUtils.waitForEvent(win, "load"); + + let { outerWidth: initialWidth, outerHeight: initialHeight } = win; + let targetWidth = initialWidth + 100; + let targetHeight = initialHeight + 100; + + let observedOurResizeEvent = false; + let resizeListener = () => { + let { outerWidth: currentWidth, outerHeight: currentHeight } = win; + info(`Resize event for ${currentWidth}x${currentHeight}.`); + if (currentWidth == targetWidth && currentHeight == targetHeight) { + ok(!observedOurResizeEvent, "First time we receive our resize event."); + observedOurResizeEvent = true; + } + }; + win.addEventListener("resize", resizeListener); + win.resizeTo(targetWidth, targetHeight); + + await ContentTaskUtils.waitForCondition( + () => observedOurResizeEvent, + `Waiting for our resize event (${targetWidth}x${targetHeight}).` + ); + + info("Waiting for potentially incoming resize events."); + for (let i = 0; i < 10; i++) { + await new Promise(r => win.requestAnimationFrame(r)); + } + win.removeEventListener("resize", resizeListener); + info("Closing popup."); + win.close(); + }); + + await BrowserTestUtils.removeTab(tab); +}); |