Bug 1465519 - avoid passing null node to getClassName, r?rpl
MozReview-Commit-ID: 7K8A0SdqjPJ
--- a/toolkit/modules/addons/WebRequestContent.js
+++ b/toolkit/modules/addons/WebRequestContent.js
@@ -73,17 +73,16 @@ var ContentPolicy = {
unregister() {
let catMan = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
catMan.deleteCategoryEntry("content-policy", this._contractID, false);
},
shouldLoad(contentLocation, loadInfo, mimeTypeGuess) {
let policyType = loadInfo.externalContentPolicyType;
- let node = loadInfo.loadingContext;
let loadingPrincipal = loadInfo.loadingPrincipal;
let requestPrincipal = loadInfo.triggeringPrincipal;
let requestOrigin = null;
if (loadingPrincipal) {
requestOrigin = loadingPrincipal.URI;
}
// Loads of TYPE_DOCUMENT and TYPE_SUBDOCUMENT perform a ConPol check
@@ -121,19 +120,21 @@ var ContentPolicy = {
let mm = Services.cpmm;
function getWindowId(window) {
return window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.outerWindowID;
}
- if (policyType == Ci.nsIContentPolicy.TYPE_SUBDOCUMENT ||
- (ChromeUtils.getClassName(node) == "XULElement" &&
- node.localName == "browser")) {
+ let node = loadInfo.loadingContext;
+ if (node &&
+ (policyType == Ci.nsIContentPolicy.TYPE_SUBDOCUMENT ||
+ (ChromeUtils.getClassName(node) == "XULElement" &&
+ node.localName == "browser"))) {
// Chrome sets frameId to the ID of the sub-window. But when
// Firefox loads an iframe, it sets |node| to the <iframe>
// element, whose window is the parent window. We adopt the
// Chrome behavior here.
node = node.contentWindow;
}
if (node) {