summaryrefslogtreecommitdiffstats
path: root/docshell/test/browser
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /docshell/test/browser
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'docshell/test/browser')
-rw-r--r--docshell/test/browser/browser.toml6
-rw-r--r--docshell/test/browser/browser_bug1673702.js2
-rw-r--r--docshell/test/browser/browser_bug1769189.js2
-rw-r--r--docshell/test/browser/browser_onbeforeunload_nested_with_delay.js58
-rw-r--r--docshell/test/browser/file_onbeforeunload_nested_inner.html3
-rw-r--r--docshell/test/browser/file_onbeforeunload_nested_outer.html3
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>