diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /browser/base/content/test/general/browser_minimize.js | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
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 | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/browser/base/content/test/general/browser_minimize.js b/browser/base/content/test/general/browser_minimize.js index a57fea079c..3919cd7d77 100644 --- a/browser/base/content/test/general/browser_minimize.js +++ b/browser/base/content/test/general/browser_minimize.js @@ -12,26 +12,57 @@ add_task(async function () { ok(isActive(), "Docshell should be active when starting the test"); ok(!document.hidden, "Top level window should be visible"); + // When we show or hide the window (including by minimization), + // there are 2 signifiers that the process is complete: the + // sizemodechange event, and the browsing context becoming active + // or inactive. There is another signifier, the + // occlusionstatechange event, but whether or not that event + // is sent is platform-dependent, so it's not very useful. The + // safest way to check for stable state is to build promises + // around sizemodechange and browsing context active and then + // wait for them all to complete, and that's what we do here. info("Calling window.minimize"); let promiseSizeModeChange = BrowserTestUtils.waitForEvent( window, "sizemodechange" + ).then( + () => ok(true, "Got sizemodechange."), + () => ok(false, "Rejected sizemodechange.") + ); + let promiseBrowserInactive = BrowserTestUtils.waitForCondition( + () => !isActive(), + "Docshell should be inactive." + ).then( + () => ok(true, "Got inactive."), + () => ok(false, "Rejected inactive.") ); window.minimize(); - await promiseSizeModeChange; - ok(!isActive(), "Docshell should be Inactive"); + await Promise.all([promiseSizeModeChange, promiseBrowserInactive]); ok(document.hidden, "Top level window should be hidden"); + // When we restore the window from minimization, we have the + // same concerns as above, so prepare our promises. info("Calling window.restore"); promiseSizeModeChange = BrowserTestUtils.waitForEvent( window, "sizemodechange" + ).then( + () => ok(true, "Got sizemodechange."), + () => ok(false, "Rejected sizemodechange.") + ); + let promiseBrowserActive = BrowserTestUtils.waitForCondition( + () => isActive(), + "Docshell should be active." + ).then( + () => ok(true, "Got active."), + () => ok(false, "Rejected active.") ); 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, + Promise.all([promiseSizeModeChange, promiseBrowserActive]), new Promise((resolve, reject) => // eslint-disable-next-line mozilla/no-arbitrary-setTimeout setTimeout(() => { @@ -39,11 +70,5 @@ add_task(async function () { }, 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"); }); |