Bug 1678965 - Part 2: set cross opener group for openLinkIn tabs opened as new tabs, r=dao

Depends on D100152

Differential Revision: https://phabricator.services.mozilla.com/D136176
This commit is contained in:
Gijs Kruitbosch 2022-01-25 17:42:45 +00:00
parent 004e42c534
commit 867dbaa85b
3 changed files with 41 additions and 0 deletions

View File

@ -112,6 +112,7 @@ class ClickHandlerParent extends JSWindowActorParent {
triggeringPrincipal: data.triggeringPrincipal,
csp: data.csp ? E10SUtils.deserializeCSP(data.csp) : null,
frameID: data.frameID,
openerBrowser: browser,
};
// The new tab/window must use the same userContextId.

View File

@ -2820,6 +2820,20 @@
});
} else {
this._insertBrowser(t, true);
// If we were called by frontend and don't have openWindowInfo,
// but we were opened from another browser, set the cross group
// opener ID:
if (openerBrowser && !openWindowInfo) {
try {
b.browsingContext.setCrossGroupOpener(
openerBrowser.browsingContext
);
} catch (ex) {
// Shouldn't happen, but we shouldn't break tabbrowser if
// this failed.
Cu.reportError(ex);
}
}
}
} catch (e) {
Cu.reportError("Failed to create tab");

View File

@ -90,6 +90,32 @@ add_task(async function simple_navigation() {
});
});
add_task(async function accel_navigation() {
await BrowserTestUtils.withNewTab({ gBrowser, url: PAGE_URL }, async function(
browser
) {
let dialogAppeared = promiseHelperAppDialog();
let tabOpened = BrowserTestUtils.waitForEvent(
gBrowser.tabContainer,
"TabOpen"
).then(event => {
return [event.target, BrowserTestUtils.waitForTabClosing(event.target)];
});
await BrowserTestUtils.synthesizeMouseAtCenter(
"#regular_load",
{ accelKey: true },
browser
);
let windowContext = await dialogAppeared;
is(windowContext, browser.ownerGlobal, "got the right windowContext");
let [tab, closingPromise] = await tabOpened;
await closingPromise;
is(tab.linkedBrowser, null, "tab was opened and closed");
});
});
// Given a browser pointing to download_page.html, clicks on the link that
// opens with target="_blank" (i.e. a new tab) and ensures that we
// automatically open and close that tab.