diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /docshell/test | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-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')
9 files changed, 72 insertions, 118 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> diff --git a/docshell/test/iframesandbox/file_marquee_event_handlers.html b/docshell/test/iframesandbox/file_marquee_event_handlers.html deleted file mode 100644 index 13ee31ddb7..0000000000 --- a/docshell/test/iframesandbox/file_marquee_event_handlers.html +++ /dev/null @@ -1,17 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> -<meta charset="utf-8"> -<title>Test marquee attribute event handlers in iframe sandbox</title> -</head> -<body> - <!-- Note that the width here is slightly longer than the contents, to make - sure we bounce and finish very quickly. --> - <marquee loop="2" width="145" behavior="alternate" truespeed scrolldelay="1" - onstart="parent.postMessage(window.name + ' marquee onstart', '*');" - onbounce="parent.postMessage(window.name + ' marquee onbounce', '*');" - onfinish="parent.postMessage(window.name + ' marquee onfinish', '*');"> - Will bounce and finish - </marquee> -</body> -</html> diff --git a/docshell/test/iframesandbox/mochitest.toml b/docshell/test/iframesandbox/mochitest.toml index a8bf4b1d72..97e6f76170 100644 --- a/docshell/test/iframesandbox/mochitest.toml +++ b/docshell/test/iframesandbox/mochitest.toml @@ -1,7 +1,6 @@ [DEFAULT] support-files = [ "file_child_navigation_by_location.html", - "file_marquee_event_handlers.html", "file_other_auxiliary_navigation_by_location.html", "file_our_auxiliary_navigation_by_location.html", "file_parent_navigation_by_location.html", @@ -12,9 +11,6 @@ support-files = [ ["test_child_navigation_by_location.html"] -["test_marquee_event_handlers.html"] -skip-if = ["true"] # Bug 1455996 - ["test_other_auxiliary_navigation_by_location.html"] tags = "openwindow" diff --git a/docshell/test/iframesandbox/test_marquee_event_handlers.html b/docshell/test/iframesandbox/test_marquee_event_handlers.html deleted file mode 100644 index 80added8ab..0000000000 --- a/docshell/test/iframesandbox/test_marquee_event_handlers.html +++ /dev/null @@ -1,95 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=1277475 -html5 sandboxed iframe should not run marquee attribute event handlers without allow-scripts ---> -<head> -<meta charset="utf-8"> -<title>Test for Bug 1277475 - html5 sandboxed iframe should not run marquee attribute event handlers without allow-scripts</title> -<script src="/tests/SimpleTest/SimpleTest.js"></script> -<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> -</head> -<body> -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1277475">Mozilla Bug 1277475</a> -<p id="display"></p> -<div id="content">Tests for Bug 1277475</div> - -<iframe id="if1" name="if1" src="file_marquee_event_handlers.html" - sandbox="allow-same-origin allow-forms allow-top-navigation allow-pointer-lock allow-orientation-lock allow-popups allow-modals allow-popups-to-escape-sandbox"> -</iframe> - -<iframe id="if2" name="if2" src="file_marquee_event_handlers.html" - sandbox="allow-scripts"></iframe> - -<script> - SimpleTest.waitForExplicitFinish(); - - var expectedMessages = new Set(); - var numberOfMessagesExpected = 4; - var unexpectedMessages = new Set(); - - window.onmessage = function(event) { - info(event.data + " message received"); - if (event.data.startsWith("if2") || event.data == "if1 chaser") { - expectedMessages.add(event.data); - if (expectedMessages.size == numberOfMessagesExpected) { - checkRecievedMessages(); - } - } else { - unexpectedMessages.add(event.data); - } - }; - - function checkRecievedMessages() { - // Check the expected messages explicitly as a cross-check. - ok(expectedMessages.has("if1 chaser"), - "if1 chaser message should have been received"); - ok(expectedMessages.has("if2 marquee onstart"), - "if2 marquee onstart should have run in iframe sandbox with allow-scripts"); - ok(expectedMessages.has("if2 marquee onbounce"), - "if2 marquee onbounce should have run in iframe sandbox with allow-scripts"); - ok(expectedMessages.has("if2 marquee onfinish"), - "if2 marquee onfinish should have run in iframe sandbox with allow-scripts"); - - unexpectedMessages.forEach( - (v) => { - ok(false, v + " should NOT have run in iframe sandbox without allow-scripts"); - } - ); - - SimpleTest.finish(); - } - - // If things are working properly the attribute event handlers won't run on - // the marquee in if1, so add our own capturing listeners on its window, so we - // know when they have fired. (These will run as we are not sandboxed.) - var if1FiredEvents = new Set(); - var if1NumberOfEventsExpected = 3; - var if1Win = document.getElementById("if1").contentWindow; - if1Win.addEventListener("start", () => { checkMarqueeEvent("start"); }, true); - if1Win.addEventListener("bounce", () => { checkMarqueeEvent("bounce"); }, true); - if1Win.addEventListener("finish", () => { checkMarqueeEvent("finish"); }, true); - - function checkMarqueeEvent(eventType) { - info("if1 event " + eventType + " fired"); - if1FiredEvents.add(eventType); - if (if1FiredEvents.size == if1NumberOfEventsExpected) { - // Only send the chasing message after a tick of the event loop to allow - // event handlers on the marquee to process. - SimpleTest.executeSoon(sendChasingMessage); - } - } - - function sendChasingMessage() { - // Add our own message listener to if1's window and echo back a chasing - // message to make sure that any messages from incorrectly run marquee - // attribute event handlers should have arrived before it. - if1Win.addEventListener("message", - (e) => { if1Win.parent.postMessage(e.data, "*"); }); - if1Win.postMessage("if1 chaser", "*"); - info("if1 chaser message sent"); - } -</script> -</body> -</html> |