Bug 1659587 - Ignore events coming from non-GeckoView windows. r=snorp

Differential Revision: https://phabricator.services.mozilla.com/D87358
This commit is contained in:
Agi Sferro 2020-08-18 16:06:38 +00:00
Родитель 6742cf83d7
Коммит ba52475378
4 изменённых файлов: 36 добавлений и 28 удалений

Просмотреть файл

@ -42,6 +42,10 @@ class ContentDelegateChild extends GeckoViewActorChild {
// eslint-disable-next-line complexity
handleEvent(aEvent) {
debug`handleEvent: ${aEvent.type}`;
if (!this.isContentWindow) {
// This not a GeckoView-controlled window
return;
}
switch (aEvent.type) {
case "contextmenu": {

Просмотреть файл

@ -332,6 +332,10 @@ class GeckoViewContentChild extends GeckoViewActorChild {
// eslint-disable-next-line complexity
handleEvent(aEvent) {
debug`handleEvent: ${aEvent.type}`;
if (!this.isContentWindow) {
// This is not a GeckoView-controlled window
return;
}
switch (aEvent.type) {
case "mozcaretstatechanged":

Просмотреть файл

@ -21,34 +21,6 @@ var EXPORTED_SYMBOLS = ["LoadURIDelegateChild"];
// Implements nsILoadURIDelegate.
class LoadURIDelegateChild extends GeckoViewActorChild {
/** Returns true if this docShell is of type Content, false otherwise. */
get isContentWindow() {
if (!this.docShell) {
return false;
}
// Some WebExtension windows are tagged as content but really they are not
// for us (e.g. the remote debugging window or the background extension
// page).
const browser = this.browsingContext.top.embedderElement;
if (browser) {
const viewType = browser.getAttribute("webextension-view-type");
if (viewType) {
debug`webextension-view-type: ${viewType}`;
return false;
}
const debugTarget = browser.getAttribute(
"webextension-addon-debug-target"
);
if (debugTarget) {
debug`webextension-addon-debug-target: ${debugTarget}`;
return false;
}
}
return this.docShell.itemType == this.docShell.typeContent;
}
// nsILoadURIDelegate.
loadURI(aUri, aWhere, aFlags, aTriggeringPrincipal) {
debug`loadURI: uri=${aUri && aUri.spec}

Просмотреть файл

@ -19,6 +19,34 @@ class GeckoViewActorChild extends JSWindowActorChild {
this.docShell.domWindow
);
}
/** Returns true if this docShell is of type Content, false otherwise. */
get isContentWindow() {
if (!this.docShell) {
return false;
}
// Some WebExtension windows are tagged as content but really they are not
// for us (e.g. the remote debugging window or the background extension
// page).
const browser = this.browsingContext.top.embedderElement;
if (browser) {
const viewType = browser.getAttribute("webextension-view-type");
if (viewType) {
debug`webextension-view-type: ${viewType}`;
return false;
}
const debugTarget = browser.getAttribute(
"webextension-addon-debug-target"
);
if (debugTarget) {
debug`webextension-addon-debug-target: ${debugTarget}`;
return false;
}
}
return this.docShell.itemType == this.docShell.typeContent;
}
}
const { debug, warn } = GeckoViewUtils.initLogging("Actor[C]");