waiter waiter more webextensions please

This commit is contained in:
wuggy 2026-09-14 14:37:34 -07:00
commit bb0adb61ae
10 changed files with 198 additions and 8 deletions

View file

@ -5466,6 +5466,9 @@ function handleLinkClick(event, href, linkNode) {
urlSecurityCheck(href, doc.nodePrincipal);
let params = {
charset: doc.characterSet,
currentBrowser: gBrowser.getBrowserForDocument(doc),
frameOuterWindowID: doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils).outerWindowID,
allowMixedContent: persistAllowMixedContentInChildTab,
referrerURI: referrerURI,
referrerPolicy: referrerPolicy,

View file

@ -442,7 +442,9 @@ var ClickEventHandler = {
}
}
let json = { button: event.button, shiftKey: event.shiftKey,
let json = { frameOuterWindowID: ownerDoc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils).outerWindowID,
button: event.button, shiftKey: event.shiftKey,
ctrlKey: event.ctrlKey, metaKey: event.metaKey,
altKey: event.altKey, href: null, title: null,
bookmark: false, referrerPolicy: referrerPolicy,

View file

@ -938,6 +938,8 @@ nsContextMenu.prototype = {
_openLinkInParameters : function (extra) {
let params = { charset: gContextMenuContentData.charSet,
currentBrowser: this.browser,
frameOuterWindowID: this.frameOuterWindowID,
originPrincipal: this.principal,
triggeringPrincipal: this.principal,
referrerURI: gContextMenuContentData.documentURIObject,

View file

@ -273,6 +273,18 @@ function openLinkIn(url, where, params) {
// Note that if |w| is null we might have no current browser (we'll open a new window).
var aCurrentBrowser = params.currentBrowser || (w && w.gBrowser.selectedBrowser);
// Capture the source before opening a foreground tab changes the selection.
function notifyNavigationTarget(createdTabBrowser) {
if (params.frameOuterWindowID && aCurrentBrowser) {
Services.obs.notifyObservers({wrappedJSObject: {
url,
createdTabBrowser,
sourceTabBrowser: aCurrentBrowser,
sourceFrameOuterWindowID: params.frameOuterWindowID,
}}, "webNavigation-createdNavigationTarget", null);
}
}
if (where == "save") {
// TODO(1073187): propagate referrerPolicy.
@ -365,7 +377,21 @@ function openLinkIn(url, where, params) {
features += ",private";
}
Services.ww.openWindow(w || window, getBrowserURL(), null, features, sa);
let newWindow = Services.ww.openWindow(w || window, getBrowserURL(), null, features, sa);
if (params.frameOuterWindowID && aCurrentBrowser) {
let cleanup = () => {
Services.obs.removeObserver(observer, "browser-delayed-startup-finished");
newWindow.removeEventListener("unload", cleanup);
};
let observer = subject => {
if (subject == newWindow) {
cleanup();
notifyNavigationTarget(newWindow.gBrowser.selectedBrowser);
}
};
Services.obs.addObserver(observer, "browser-delayed-startup-finished", false);
newWindow.addEventListener("unload", cleanup);
}
return;
}
@ -474,6 +500,7 @@ function openLinkIn(url, where, params) {
triggeringPrincipal: aTriggeringPrincipal,
});
browserUsedForLoad = tabUsedForLoad.linkedBrowser;
notifyNavigationTarget(browserUsedForLoad);
break;
}