Bug 1385548 - Part 3: Fix exception raised by calling target.contains on the gBrowser stub defined in "about:addons".
MozReview-Commit-ID: zvcyHIqjNR
--- a/toolkit/components/addoncompat/RemoteAddonsParent.jsm
+++ b/toolkit/components/addoncompat/RemoteAddonsParent.jsm
@@ -436,16 +436,30 @@ var EventTargetParent = {
return target;
} else if (target.localName == "tab") {
return target.linkedBrowser;
}
// Check if |target| is somewhere on the patch from the
// <tabbrowser> up to the root element.
let window = target.ownerGlobal;
+
+ // Prevents the fake about:addons gBrowser to be checked
+ // using target.contains, because it raises an exception if gBrowser
+ // is not a Node as expected by a tabbrowser gBrowser.
+ // (See Bug 1385548 for rationale).
+ if (window) {
+ let principal = window.document.nodePrincipal;
+ if (Services.scriptSecurityManager.isSystemPrincipal(principal) &&
+ window.location.href === "about:addons" &&
+ window.gBrowser) {
+ return null;
+ }
+ }
+
if (window && target.contains(window.gBrowser)) {
return window;
}
}
return null;
},