diff --git a/browser/actors/ClickHandlerChild.sys.mjs b/browser/actors/ClickHandlerChild.sys.mjs index ab0da34242f2..c08b599856fe 100644 --- a/browser/actors/ClickHandlerChild.sys.mjs +++ b/browser/actors/ClickHandlerChild.sys.mjs @@ -10,13 +10,7 @@ const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs", E10SUtils: "resource://gre/modules/E10SUtils.sys.mjs", - PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs", }); -ChromeUtils.defineModuleGetter( - lazy, - "WebNavigationFrames", - "resource://gre/modules/WebNavigationFrames.jsm" -); export class MiddleMousePasteHandlerChild extends JSWindowActorChild { handleEvent(clickEvent) { @@ -107,7 +101,6 @@ export class ClickHandlerChild extends JSWindowActorChild { referrerInfo.initWithDocument(ownerDoc); } referrerInfo = lazy.E10SUtils.serializeReferrerInfo(referrerInfo); - let frameID = lazy.WebNavigationFrames.getFrameId(ownerDoc.defaultView); let json = { button: event.button, @@ -117,14 +110,8 @@ export class ClickHandlerChild extends JSWindowActorChild { altKey: event.altKey, href: null, title: null, - frameID, - triggeringPrincipal: principal, csp, referrerInfo, - originAttributes: principal ? principal.originAttributes : {}, - isContentWindowPrivate: lazy.PrivateBrowsingUtils.isContentWindowPrivate( - ownerDoc.defaultView - ), }; if (href && !isFromMiddleMousePasteHandler) { @@ -162,10 +149,6 @@ export class ClickHandlerChild extends JSWindowActorChild { json.title = node.getAttribute("title"); } - json.originPrincipal = ownerDoc.nodePrincipal; - json.originStoragePrincipal = ownerDoc.effectiveStoragePrincipal; - json.triggeringPrincipal = ownerDoc.nodePrincipal; - if ( (ownerDoc.URL === "about:newtab" || ownerDoc.URL === "about:home") && node.dataset.isSponsoredLink === "true" diff --git a/browser/actors/ClickHandlerParent.sys.mjs b/browser/actors/ClickHandlerParent.sys.mjs index 28f3c62586a9..e3ae3a02aacd 100644 --- a/browser/actors/ClickHandlerParent.sys.mjs +++ b/browser/actors/ClickHandlerParent.sys.mjs @@ -10,9 +10,26 @@ ChromeUtils.defineESModuleGetters(lazy, { PlacesUIUtils: "resource:///modules/PlacesUIUtils.sys.mjs", PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs", }); +ChromeUtils.defineModuleGetter( + lazy, + "WebNavigationFrames", + "resource://gre/modules/WebNavigationFrames.jsm" +); let gContentClickListeners = new Set(); +// Fill in fields which are not sent by the content process for the click event +// based on known data in the parent process. +function fillInClickEvent(actor, data) { + const wgp = actor.manager; + data.frameID = lazy.WebNavigationFrames.getFrameId(wgp.browsingContext); + data.triggeringPrincipal = wgp.documentPrincipal; + data.originPrincipal = wgp.documentPrincipal; + data.originStoragePrincipal = wgp.documentStoragePrincipal; + data.originAttributes = wgp.documentPrincipal?.originAttributes ?? {}; + data.isContentWindowPrivate = wgp.browsingContext.usePrivateBrowsing; +} + export class MiddleMousePasteHandlerParent extends JSWindowActorParent { receiveMessage(message) { if (message.name == "MiddleClickPaste") { @@ -24,6 +41,7 @@ export class MiddleMousePasteHandlerParent extends JSWindowActorParent { // Just bail. return; } + fillInClickEvent(this, message.data); browser.ownerGlobal.middleMousePaste(message.data); } } @@ -41,6 +59,7 @@ export class ClickHandlerParent extends JSWindowActorParent { receiveMessage(message) { switch (message.name) { case "Content:Click": + fillInClickEvent(this, message.data); this.contentAreaClick(message.data); this.notifyClickListeners(message.data); break;