diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /docshell/test/browser | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'docshell/test/browser')
6 files changed, 72 insertions, 2 deletions
diff --git a/docshell/test/browser/browser.toml b/docshell/test/browser/browser.toml index bcda46fd2e..ddea8bcc01 100644 --- a/docshell/test/browser/browser.toml +++ b/docshell/test/browser/browser.toml @@ -286,6 +286,12 @@ support-files = ["head_browser_onbeforeunload.js"] ["browser_onbeforeunload_navigation.js"] skip-if = ["os == 'win' && !debug"] # bug 1300351 +["browser_onbeforeunload_nested_with_delay.js"] +support-files = [ + "file_onbeforeunload_nested_inner.html", + "file_onbeforeunload_nested_outer.html", +] + ["browser_onbeforeunload_parent.js"] support-files = ["head_browser_onbeforeunload.js"] diff --git a/docshell/test/browser/browser_bug1673702.js b/docshell/test/browser/browser_bug1673702.js index c32c38fe45..f87a671900 100644 --- a/docshell/test/browser/browser_bug1673702.js +++ b/docshell/test/browser/browser_bug1673702.js @@ -18,7 +18,7 @@ add_task(async function test_backAndReload() { await BrowserTestUtils.browserStopped(browser); info("Reload."); - BrowserReload(); + BrowserCommands.reload(); await BrowserTestUtils.waitForLocationChange(gBrowser); is(browser.documentURI.spec, DUMMY); diff --git a/docshell/test/browser/browser_bug1769189.js b/docshell/test/browser/browser_bug1769189.js index 08cb4f9002..823f76c678 100644 --- a/docshell/test/browser/browser_bug1769189.js +++ b/docshell/test/browser/browser_bug1769189.js @@ -20,7 +20,7 @@ add_task(async function test_beforeUnload_and_replaceState() { browser, "pageshow" ); - BrowserReload(); + BrowserCommands.reload(); await awaitPageShow; let updatedState = await SpecialPowers.spawn(browser, [], () => { diff --git a/docshell/test/browser/browser_onbeforeunload_nested_with_delay.js b/docshell/test/browser/browser_onbeforeunload_nested_with_delay.js new file mode 100644 index 0000000000..409c73d0b7 --- /dev/null +++ b/docshell/test/browser/browser_onbeforeunload_nested_with_delay.js @@ -0,0 +1,58 @@ +"use strict"; + +add_task(async function () { + const outer = + "http://mochi.test:8888/browser/docshell/test/browser/file_onbeforeunload_nested_outer.html"; + await BrowserTestUtils.withNewTab(outer, async browser => { + let inner = browser.browsingContext.children[0]; + + // Install a beforeunload event handler that resolves a promise. + await SpecialPowers.spawn(inner, [], () => { + let { promise, resolve } = Promise.withResolvers(); + content.addEventListener( + "beforeunload", + e => { + e.preventDefault(); + resolve(); + }, + { + once: true, + } + ); + content.beforeunloadPromise = promise; + }); + + // Get the promise for the beforeunload handler so we can wait for it. + let beforeunloadFired = SpecialPowers.spawn( + browser.browsingContext.children[0], + [], + () => { + return content.beforeunloadPromise; + } + ); + + // Register whether a load has started. + let loaded = BrowserTestUtils.browserLoaded(browser).then(() => "loaded"); + + // This is rather fragile, but we need to make sure we don't start a + // speculative load in the parent so let's give it the time to be done. + let timeout = new Promise(resolve => + // eslint-disable-next-line mozilla/no-arbitrary-setTimeout + setTimeout(() => resolve("timeout"), 3000) + ); + + // Need to add some user interaction for beforeunload. + await BrowserTestUtils.synthesizeMouse("body", 0, 0, {}, inner, true); + + // Try to start a speculative load in the parent. + BrowserTestUtils.startLoadingURIString(browser, "https://example.com/"); + + await beforeunloadFired; + + is( + await Promise.race([loaded, timeout]), + "timeout", + "Timed out because the load was blocked by beforeunload." + ); + }); +}); diff --git a/docshell/test/browser/file_onbeforeunload_nested_inner.html b/docshell/test/browser/file_onbeforeunload_nested_inner.html new file mode 100644 index 0000000000..d9568d142b --- /dev/null +++ b/docshell/test/browser/file_onbeforeunload_nested_inner.html @@ -0,0 +1,3 @@ +<body> + <div>inner</div> +</body> diff --git a/docshell/test/browser/file_onbeforeunload_nested_outer.html b/docshell/test/browser/file_onbeforeunload_nested_outer.html new file mode 100644 index 0000000000..7689281eca --- /dev/null +++ b/docshell/test/browser/file_onbeforeunload_nested_outer.html @@ -0,0 +1,3 @@ +<body> +<iframe src="http://example.org/browser/docshell/test/browser/file_onbeforeunload_nested_inner.html"></iframe> +</body> |