Bug 1465519 - avoid passing null node to getClassName, r?rpl draft
authorShane Caraveo <scaraveo@mozilla.com>
Wed, 30 May 2018 12:47:18 -0400
changeset 801732 fa4d53c8dee98b3532aa2d73f1ee51b3ff88c7f8
parent 801403 5866d6685849311f057e7e229b9ace63a2641c29
push id111715
push usermixedpuppy@gmail.com
push dateWed, 30 May 2018 16:47:47 +0000
reviewersrpl
bugs1465519
milestone62.0a1
Bug 1465519 - avoid passing null node to getClassName, r?rpl MozReview-Commit-ID: 7K8A0SdqjPJ
toolkit/modules/addons/WebRequestContent.js
--- 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) {