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/general/browser_new_http_window_opened_from_file_tab.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/general/browser_new_http_window_opened_from_file_tab.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/browser/base/content/test/general/browser_new_http_window_opened_from_file_tab.js b/browser/base/content/test/general/browser_new_http_window_opened_from_file_tab.js new file mode 100644 index 0000000000..8e9f458073 --- /dev/null +++ b/browser/base/content/test/general/browser_new_http_window_opened_from_file_tab.js @@ -0,0 +1,63 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ + +const TEST_FILE = "file_with_link_to_http.html"; +// eslint-disable-next-line @microsoft/sdl/no-insecure-url +const TEST_HTTP = "http://example.org/"; + +// Test for bug 1338375. +add_task(async function () { + // Open file:// page. + let dir = getChromeDir(getResolvedURI(gTestPath)); + dir.append(TEST_FILE); + const uriString = Services.io.newFileURI(dir).spec; + let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, uriString); + registerCleanupFunction(async function () { + BrowserTestUtils.removeTab(tab); + }); + let browser = tab.linkedBrowser; + + // Set pref to open in new window. + Services.prefs.setIntPref("browser.link.open_newwindow", 2); + registerCleanupFunction(function () { + Services.prefs.clearUserPref("browser.link.open_newwindow"); + }); + + // Open new http window from JavaScript in file:// page and check that we get + // a new window with the correct page and features. + let promiseNewWindow = BrowserTestUtils.waitForNewWindow({ url: TEST_HTTP }); + await SpecialPowers.spawn(browser, [TEST_HTTP], uri => { + content.open(uri, "_blank"); + }); + let win = await promiseNewWindow; + registerCleanupFunction(async function () { + await BrowserTestUtils.closeWindow(win); + }); + ok(win, "Check that an http window loaded when using window.open."); + ok( + win.menubar.visible, + "Check that the menu bar on the new window is visible." + ); + ok( + win.toolbar.visible, + "Check that the tool bar on the new window is visible." + ); + + // Open new http window from a link in file:// page and check that we get a + // new window with the correct page and features. + promiseNewWindow = BrowserTestUtils.waitForNewWindow({ url: TEST_HTTP }); + await BrowserTestUtils.synthesizeMouseAtCenter("#linkToExample", {}, browser); + let win2 = await promiseNewWindow; + registerCleanupFunction(async function () { + await BrowserTestUtils.closeWindow(win2); + }); + ok(win2, "Check that an http window loaded when using link."); + ok( + win2.menubar.visible, + "Check that the menu bar on the new window is visible." + ); + ok( + win2.toolbar.visible, + "Check that the tool bar on the new window is visible." + ); +}); |