Bug 1521469 - Change loadURI crash to only happen in a debug build. r=gsvelto,ckerschb
authorJonathan Kingston <jkt@mozilla.com>
Wed, 23 Jan 2019 12:05:28 +0000
changeset 515087 ac8dff6980b7c45cbe8037f9c93d4a812e707df8
parent 515086 21dc0a08a9511252d39f28e1ca976e8a403899a5
child 515097 2e27f3f1ebc6f38d98ddd42b6955083f637e2b1b
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgsvelto, ckerschb
bugs1521469
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1521469 - Change loadURI crash to only happen in a debug build. r=gsvelto,ckerschb Differential Revision: https://phabricator.services.mozilla.com/D17250
toolkit/actors/WebNavigationChild.jsm
--- a/toolkit/actors/WebNavigationChild.jsm
+++ b/toolkit/actors/WebNavigationChild.jsm
@@ -100,37 +100,46 @@ class WebNavigationChild extends ActorCh
     if (referrer)
       referrer = Services.io.newURI(referrer);
     if (postData)
       postData = Utils.makeInputStream(postData);
     if (headers)
       headers = Utils.makeInputStream(headers);
     if (baseURI)
       baseURI = Services.io.newURI(baseURI);
+    this._assert(triggeringPrincipal, "We need a triggering principal to continue loading", new Error().lineNumber);
     if (triggeringPrincipal)
       triggeringPrincipal = Utils.deserializePrincipal(triggeringPrincipal);
+    this._assert(triggeringPrincipal, "Unable to deserialize passed triggering principal", new Error().lineNumber);
     if (!triggeringPrincipal) {
-      // If we don't have a triggering principal we won't be able to continue the load.
-      let debug = Cc["@mozilla.org/xpcom/debug;1"].getService(Ci.nsIDebug2);
-      debug.abort("WebNavigationChild.js", 112);
+      triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal({});
     }
+
     let loadURIOptions = {
       triggeringPrincipal,
       loadFlags: flags,
       referrerURI: referrer,
       referrerPolicy,
       postData,
       headers,
       baseURI,
     };
     this._wrapURIChangeCall(() => {
       return this.webNavigation.loadURI(uri, loadURIOptions);
     });
   }
 
+  _assert(condition, msg, line = 0) {
+    let debug = Cc["@mozilla.org/xpcom/debug;1"].getService(Ci.nsIDebug2);
+    if (!condition && debug.isDebugBuild) {
+      debug.warning(`${msg} - ${new Error().stack}`, "WebNavigationChild.js", line);
+      debug.abort("WebNavigationChild.js", line);
+    }
+  }
+
   setOriginAttributes(originAttributes) {
     if (originAttributes) {
       this.webNavigation.setOriginAttributesBeforeLoading(originAttributes);
     }
   }
 
   reload(flags) {
     this.webNavigation.reload(flags);