зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1800149 - Part 2: Stop sending some values from a content process in ClickHandler, r=Gijs
Currently we are sending some values, such as principals, from the content process when handling clicks from the ClickHandler actor. This information is already available in the parent process on WindowGlobalParent, so changes the code to fetch the values from there instead. Differential Revision: https://phabricator.services.mozilla.com/D161836
This commit is contained in:
Родитель
ecbfe14912
Коммит
b86f55e3a2
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче