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 /devtools/client/responsive/test/browser/browser_many_toggles.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 'devtools/client/responsive/test/browser/browser_many_toggles.js')
-rw-r--r-- | devtools/client/responsive/test/browser/browser_many_toggles.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/devtools/client/responsive/test/browser/browser_many_toggles.js b/devtools/client/responsive/test/browser/browser_many_toggles.js new file mode 100644 index 0000000000..a0fe19dba4 --- /dev/null +++ b/devtools/client/responsive/test/browser/browser_many_toggles.js @@ -0,0 +1,51 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Verify RDM can be toggled many times in a raw + +const TEST_URL = "https://example.com/"; + +addRDMTask( + null, + async function () { + const tab = await addTab(TEST_URL); + + // Record all currently active RDMs, there may not be one created on each loop + let opened = 0; + ResponsiveUIManager.on("on", () => opened++); + ResponsiveUIManager.on("off", () => opened--); + + for (let i = 0; i < 10; i++) { + info(`Toggling RDM #${i + 1}`); + // This may throw when we were just closing is still ongoing, + // ignore any exception. + openRDM(tab).catch(e => {}); + // Sometime pause in order to cover both full synchronous opening and close + // but also the same but with some pause between each operation. + if (i % 2 == 0) { + info("Wait a bit after open"); + await wait(250); + } + closeRDM(tab); + if (i % 3 == 0) { + info("Wait a bit after close"); + await wait(250); + } + } + + // Wait a bit so that we can receive the very last ResponsiveUIManager `on` event, + // and properly wait for its closing. + await wait(1000); + + // This is important to wait for all destruction as closing the tab while RDM + // is still closing may lead to exception because of pending cleanup RDP requests. + info("Wait for all opened RDM to be closed before closing the tab"); + await waitFor(() => opened == 0); + info("All RDM are closed"); + + await removeTab(tab); + }, + { onlyPrefAndTask: true } +); |