From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- ...browser_new_http_window_opened_from_file_tab.js | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 browser/base/content/test/general/browser_new_http_window_opened_from_file_tab.js (limited to 'browser/base/content/test/general/browser_new_http_window_opened_from_file_tab.js') 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." + ); +}); -- cgit v1.2.3