diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /browser/base/content/test/general/browser_minimize.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base/content/test/general/browser_minimize.js')
-rw-r--r-- | browser/base/content/test/general/browser_minimize.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/browser/base/content/test/general/browser_minimize.js b/browser/base/content/test/general/browser_minimize.js new file mode 100644 index 0000000000..2b6db5c0d1 --- /dev/null +++ b/browser/base/content/test/general/browser_minimize.js @@ -0,0 +1,49 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +add_task(async function() { + registerCleanupFunction(function() { + window.restore(); + }); + function isActive() { + return gBrowser.selectedTab.linkedBrowser.docShellIsActive; + } + + ok(isActive(), "Docshell should be active when starting the test"); + ok(!document.hidden, "Top level window should be visible"); + + info("Calling window.minimize"); + let promiseSizeModeChange = BrowserTestUtils.waitForEvent( + window, + "sizemodechange" + ); + window.minimize(); + await promiseSizeModeChange; + ok(!isActive(), "Docshell should be Inactive"); + ok(document.hidden, "Top level window should be hidden"); + + info("Calling window.restore"); + promiseSizeModeChange = BrowserTestUtils.waitForEvent( + window, + "sizemodechange" + ); + window.restore(); + // On Ubuntu `window.restore` doesn't seem to work, use a timer to make the + // test fail faster and more cleanly than with a test timeout. + await Promise.race([ + promiseSizeModeChange, + new Promise((resolve, reject) => + // eslint-disable-next-line mozilla/no-arbitrary-setTimeout + setTimeout(() => { + reject("timed out waiting for sizemodechange event"); + }, 5000) + ), + ]); + // The sizemodechange event can sometimes be fired before the + // occlusionstatechange event, especially in chaos mode. + if (window.isFullyOccluded) { + await BrowserTestUtils.waitForEvent(window, "occlusionstatechange"); + } + ok(isActive(), "Docshell should be active again"); + ok(!document.hidden, "Top level window should be visible"); +}); |