summaryrefslogtreecommitdiffstats
path: root/dom/ipc/tests/test_window_open_discarded_bc.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/ipc/tests/test_window_open_discarded_bc.html
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/ipc/tests/test_window_open_discarded_bc.html')
-rw-r--r--dom/ipc/tests/test_window_open_discarded_bc.html40
1 files changed, 40 insertions, 0 deletions
diff --git a/dom/ipc/tests/test_window_open_discarded_bc.html b/dom/ipc/tests/test_window_open_discarded_bc.html
new file mode 100644
index 0000000000..4cd81463e0
--- /dev/null
+++ b/dom/ipc/tests/test_window_open_discarded_bc.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Discard a new BrowsingContext during window.open nested event loop</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<script>
+add_task(async function() {
+ const TOPIC = "dangerous:test-only:new-browser-child-ready";
+
+ let found = false;
+ function observer(subject, topic, data) {
+ let win = SpecialPowers.wrap(subject);
+ if (SpecialPowers.compare(win.opener, window)) {
+ found = true;
+ SpecialPowers.removeObserver(observer, TOPIC);
+
+ win.close();
+ // window.close() is not synchronous, so we need to wait for the
+ // BrowsingContext to actually become discarded after we call it, to
+ // make sure that the window provider actually has a discarded BC at the
+ // end of its own nested event loop.
+ SpecialPowers.Services.tm.spinEventLoopUntil(
+ "Test(test_window_open_discarded_bc.html:add_task)",
+ () => !win.opener
+ );
+ }
+ }
+ SpecialPowers.addObserver(observer, TOPIC);
+
+ let win = window.open();
+
+ is(found, true, "Our observer should have fired for the new window");
+ is(win, null, "window.open() should return null when new window is already closed");
+});
+</script>
+</body>
+</html>