Bug 1520862 - Fixing WebNavigation serialization of principals to always be present. r=ckerschb
authorJonathan Kingston <jkt@mozilla.com>
Thu, 17 Jan 2019 18:50:40 +0000
changeset 511466 4fe0910cfb679969e615841077a055955c290b70
parent 511465 698395a5488d459236dc0bc34eb6648ff2913730
child 511467 bc44f16fc690df91c599eb2a37a5d0c73ea65a0f
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb
bugs1520862
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 1520862 - Fixing WebNavigation serialization of principals to always be present. r=ckerschb Differential Revision: https://phabricator.services.mozilla.com/D16884
devtools/client/responsive.html/browser/web-navigation.js
toolkit/actors/WebNavigationChild.jsm
toolkit/components/remotebrowserutils/RemoteWebNavigation.js
toolkit/modules/E10SUtils.jsm
--- a/devtools/client/responsive.html/browser/web-navigation.js
+++ b/devtools/client/responsive.html/browser/web-navigation.js
@@ -74,19 +74,19 @@ BrowserElementWebNavigation.prototype = 
     this._sendMessage("WebNavigation:LoadURI", {
       uri,
       flags,
       referrer: referrer ? referrer.spec : null,
       referrerPolicy: referrerPolicy,
       postData: postData ? readInputStreamToString(postData) : null,
       headers: headers ? readInputStreamToString(headers) : null,
       baseURI: baseURI ? baseURI.spec : null,
-      triggeringPrincipal: triggeringPrincipal
-                           ? Utils.serializePrincipal(triggeringPrincipal)
-                           : Services.scriptSecurityManager.createNullPrincipal({}),
+      triggeringPrincipal: Utils.serializePrincipal(
+                           triggeringPrincipal ||
+                           Services.scriptSecurityManager.createNullPrincipal({})),
       requestTime: telemetry.msSystemNow(),
     });
   },
 
   setOriginAttributesBeforeLoading(originAttributes) {
     // No equivalent in the current BrowserElement API
     this._sendMessage("WebNavigation:SetOriginAttributes", {
       originAttributes,
--- a/toolkit/actors/WebNavigationChild.jsm
+++ b/toolkit/actors/WebNavigationChild.jsm
@@ -103,17 +103,19 @@ class WebNavigationChild extends ActorCh
       postData = Utils.makeInputStream(postData);
     if (headers)
       headers = Utils.makeInputStream(headers);
     if (baseURI)
       baseURI = Services.io.newURI(baseURI);
     if (triggeringPrincipal)
       triggeringPrincipal = Utils.deserializePrincipal(triggeringPrincipal);
     if (!triggeringPrincipal) {
-      triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal({});
+      // 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);
     }
     let loadURIOptions = {
       triggeringPrincipal,
       loadFlags: flags,
       referrerURI: referrer,
       referrerPolicy,
       postData,
       headers,
--- a/toolkit/components/remotebrowserutils/RemoteWebNavigation.js
+++ b/toolkit/components/remotebrowserutils/RemoteWebNavigation.js
@@ -95,17 +95,17 @@ RemoteWebNavigation.prototype = {
       uri: aURI,
       flags: aLoadURIOptions.loadFlags,
       referrer: aLoadURIOptions.referrerURI ? aLoadURIOptions.referrerURI.spec : null,
       referrerPolicy: aLoadURIOptions.referrerPolicy,
       postData: aLoadURIOptions.postData ? Utils.serializeInputStream(aLoadURIOptions.postData) : null,
       headers: aLoadURIOptions.headers ? Utils.serializeInputStream(aLoadURIOptions.headers) : null,
       baseURI: aLoadURIOptions.baseURI ? aLoadURIOptions.baseURI.spec : null,
       triggeringPrincipal: Utils.serializePrincipal(
-          aLoadURIOptions.triggeringPrincipal || Services.scriptSecurityManager.createNullPrincipal({})),
+                           aLoadURIOptions.triggeringPrincipal || Services.scriptSecurityManager.createNullPrincipal({})),
       requestTime: Services.telemetry.msSystemNow(),
     });
   },
   setOriginAttributesBeforeLoading(aOriginAttributes) {
     this._sendMessage("WebNavigation:SetOriginAttributes", {
       originAttributes: aOriginAttributes,
     });
   },
--- a/toolkit/modules/E10SUtils.jsm
+++ b/toolkit/modules/E10SUtils.jsm
@@ -327,19 +327,17 @@ var E10SUtils = {
     let messageManager = aDocShell.messageManager;
     let sessionHistory = aDocShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
 
     messageManager.sendAsyncMessage("Browser:LoadURI", {
       loadOptions: {
         uri: aURI.spec,
         flags: aFlags || Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
         referrer: aReferrer ? aReferrer.spec : null,
-        triggeringPrincipal: aTriggeringPrincipal
-                             ? Utils.serializePrincipal(aTriggeringPrincipal)
-                             : null,
+        triggeringPrincipal: Utils.serializePrincipal(aTriggeringPrincipal || Services.scriptSecurityManager.createNullPrincipal({})),
         reloadInFreshProcess: !!aFreshProcess,
       },
       historyIndex: sessionHistory.legacySHistory.requestedIndex,
     });
     return false;
   },
 
   wrapHandlingUserInput(aWindow, aIsHandling, aCallback) {