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/contextualidentity/test/browser/browser_middleClick.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.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/contextualidentity/test/browser/browser_middleClick.js')
-rw-r--r-- | browser/components/contextualidentity/test/browser/browser_middleClick.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/browser/components/contextualidentity/test/browser/browser_middleClick.js b/browser/components/contextualidentity/test/browser/browser_middleClick.js new file mode 100644 index 0000000000..9b9fbcb737 --- /dev/null +++ b/browser/components/contextualidentity/test/browser/browser_middleClick.js @@ -0,0 +1,50 @@ +"use strict"; + +const BASE_ORIGIN = "http://example.com"; +const URI = + BASE_ORIGIN + + "/browser/browser/components/contextualidentity/test/browser/empty_file.html"; + +add_task(async function () { + info("Opening a new container tab..."); + + let tab = BrowserTestUtils.addTab(gBrowser, URI, { userContextId: 1 }); + gBrowser.selectedTab = tab; + + let browser = gBrowser.getBrowserForTab(tab); + await BrowserTestUtils.browserLoaded(browser); + + info("Create a HTMLAnchorElement..."); + await SpecialPowers.spawn(browser, [URI], function (uri) { + let anchor = content.document.createElement("a"); + anchor.setAttribute("id", "clickMe"); + anchor.setAttribute("href", uri); + anchor.appendChild(content.document.createTextNode("click me!")); + content.document.body.appendChild(anchor); + }); + + info("Synthesize a mouse click and wait for a new tab..."); + let newTab = await new Promise((resolve, reject) => { + gBrowser.tabContainer.addEventListener( + "TabOpen", + function (openEvent) { + resolve(openEvent.target); + }, + { once: true } + ); + + BrowserTestUtils.synthesizeMouseAtCenter( + "#clickMe", + { button: 1 }, + browser + ); + }); + + is(newTab.getAttribute("usercontextid"), "1", "Correct UserContextId?"); + + // newTab shouldn't be closed in the same event tick as TabOpen. + await TestUtils.waitForTick(); + + BrowserTestUtils.removeTab(tab); + BrowserTestUtils.removeTab(newTab); +}); |