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 /browser/base/content/test/tabs/browser_file_to_http_named_popup.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 '')
-rw-r--r-- | browser/base/content/test/tabs/browser_file_to_http_named_popup.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/browser/base/content/test/tabs/browser_file_to_http_named_popup.js b/browser/base/content/test/tabs/browser_file_to_http_named_popup.js new file mode 100644 index 0000000000..57e5ec7ad3 --- /dev/null +++ b/browser/base/content/test/tabs/browser_file_to_http_named_popup.js @@ -0,0 +1,60 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ + +const TEST_FILE = fileURL("dummy_page.html"); +const TEST_HTTP = httpURL("dummy_page.html"); + +// Test for Bug 1634252 +add_task(async function () { + await BrowserTestUtils.withNewTab(TEST_FILE, async function (fileBrowser) { + info("Tab ready"); + + async function summonPopup(firstRun) { + var winPromise; + if (firstRun) { + winPromise = BrowserTestUtils.waitForNewWindow({ + url: TEST_HTTP, + }); + } + + await SpecialPowers.spawn( + fileBrowser, + [TEST_HTTP, firstRun], + (target, firstRun_) => { + var win = content.open(target, "named", "width=400,height=400"); + win.focus(); + ok(win, "window.open was successful"); + if (firstRun_) { + content.document.firstWindow = win; + } else { + content.document.otherWindow = win; + } + } + ); + + if (firstRun) { + // We should only wait for the window the first time, because only the + // later times no new window should be created. + info("Waiting for new window"); + var win = await winPromise; + ok(win, "Got a window"); + } + } + + info("Opening window"); + await summonPopup(true); + info("Opening window again"); + await summonPopup(false); + + await SpecialPowers.spawn(fileBrowser, [], () => { + ok(content.document.firstWindow, "Window is non-null"); + is( + content.document.otherWindow, + content.document.firstWindow, + "Windows are the same" + ); + + content.document.firstWindow.close(); + }); + }); +}); |