diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /browser/components/extensions/test/browser/browser_ext_contentscript_incognito.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/extensions/test/browser/browser_ext_contentscript_incognito.js')
-rw-r--r-- | browser/components/extensions/test/browser/browser_ext_contentscript_incognito.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/browser/components/extensions/test/browser/browser_ext_contentscript_incognito.js b/browser/components/extensions/test/browser/browser_ext_contentscript_incognito.js new file mode 100644 index 0000000000..fc365a2a4a --- /dev/null +++ b/browser/components/extensions/test/browser/browser_ext_contentscript_incognito.js @@ -0,0 +1,42 @@ +/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set sts=2 sw=2 et tw=80: */ +"use strict"; + +// Test that calling window.open from a content script running in a private +// window does not trigger a crash (regression test introduced in Bug 1653530 +// to cover the issue introduced in Bug 1616353 and fixed by Bug 1638793). +add_task(async function test_contentscript_window_open_doesnot_crash() { + const extension = ExtensionTestUtils.loadExtension({ + incognitoOverride: "spanning", + manifest: { + content_scripts: [ + { + matches: ["https://example.com/*"], + js: ["test_window_open.js"], + }, + ], + }, + files: { + "test_window_open.js": function () { + const newWin = window.open(); + browser.test.log("calling window.open did not triggered a crash"); + browser.test.sendMessage("window-open-called", !!newWin); + }, + }, + }); + await extension.startup(); + + const winPrivate = await BrowserTestUtils.openNewBrowserWindow({ + private: true, + }); + + await BrowserTestUtils.openNewForegroundTab( + winPrivate.gBrowser, + "https://example.com" + ); + const newWinOpened = await extension.awaitMessage("window-open-called"); + ok(newWinOpened, "Content script successfully open a new window"); + + await extension.unload(); + await BrowserTestUtils.closeWindow(winPrivate); +}); |