diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/base/content/test/performance/browser_windowclose.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | browser/base/content/test/performance/browser_windowclose.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/browser/base/content/test/performance/browser_windowclose.js b/browser/base/content/test/performance/browser_windowclose.js new file mode 100644 index 0000000000..26eecf9539 --- /dev/null +++ b/browser/base/content/test/performance/browser_windowclose.js @@ -0,0 +1,58 @@ +"use strict"; + +/** + * WHOA THERE: We should never be adding new things to EXPECTED_REFLOWS. + * Instead of adding reflows to the list, you should be modifying your code to + * avoid the reflow. + * + * See https://firefox-source-docs.mozilla.org/performance/bestpractices.html + * for tips on how to do that. + */ +const EXPECTED_REFLOWS = [ + /** + * Nothing here! Please don't add anything new! + */ +]; + +/** + * This test ensures that there are no unexpected + * uninterruptible reflows when closing windows. When the + * window is closed, the test waits until the original window + * has activated. + */ +add_task(async function () { + // Ensure that this browser window starts focused. This seems to be + // necessary to avoid intermittent failures when running this test + // on repeat. + await new Promise(resolve => { + waitForFocus(resolve, window); + }); + + let win = await BrowserTestUtils.openNewBrowserWindow(); + await new Promise(resolve => { + waitForFocus(resolve, win); + }); + + // At the time of writing, there are no reflows on window closing. + // Mochitest will fail if we have no assertions, so we add one here + // to make sure nobody adds any new ones. + Assert.equal( + EXPECTED_REFLOWS.length, + 0, + "We shouldn't have added any new expected reflows for window close." + ); + + await withPerfObserver( + async function () { + let promiseOrigBrowserFocused = TestUtils.waitForCondition(() => { + return Services.focus.activeWindow == window; + }); + await BrowserTestUtils.closeWindow(win); + await promiseOrigBrowserFocused; + }, + { + expectedReflows: EXPECTED_REFLOWS, + }, + win + ); +}); |