Bug 1249362 - correct content principal when about:blank loads stop, r?mconley draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 12 Apr 2016 15:09:53 +0100
changeset 349867 e439ef8f905783f5860dc280b99fccad14b8377f
parent 349524 02a6023f95ceb20beb3f996608c26cf8f5f5753a
child 518207 4eb7b1fac167a92e41969227f433981770a0d82c
push id15201
push usergijskruitbosch@gmail.com
push dateTue, 12 Apr 2016 14:18:26 +0000
reviewersmconley
bugs1249362
milestone48.0a1
Bug 1249362 - correct content principal when about:blank loads stop, r?mconley MozReview-Commit-ID: Da9eKdv7W0u
browser/base/content/browser.js
toolkit/content/browser-child.js
toolkit/modules/RemoteWebProgress.jsm
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6321,18 +6321,18 @@ function checkEmptyPageOrigin(browser = 
   // be controlled by its opener - return false.
   if (browser.hasContentOpener) {
     return false;
   }
   let contentPrincipal = browser.contentPrincipal;
   if (gMultiProcessBrowser && browser.isRemoteBrowser &&
       !contentPrincipal && uri.spec == "about:blank") {
     // Need to specialcase this because of how stopping an about:blank
-    // load from chrome on e10s causes a permanently null contentPrincipal,
-    // see bug 1249362.
+    // load from chrome on e10s immediately leaves a null principal for
+    // one turn of the event loop, see bug 1249362.
     return true;
   }
   // Not all principals have URIs...
   if (contentPrincipal.URI) {
     // A manually entered about:blank URI is slightly magical:
     if (uri.spec == "about:blank" && contentPrincipal.isNullPrincipal) {
       return true;
     }
--- a/toolkit/content/browser-child.js
+++ b/toolkit/content/browser-child.js
@@ -125,16 +125,21 @@ var WebProgressListener = {
     // It's possible that this state change was triggered by
     // loading an internal error page, for which the parent
     // will want to know some details, so we'll update it with
     // the documentURI.
     if (aWebProgress && aWebProgress.isTopLevel) {
       json.documentURI = content.document.documentURIObject.spec;
       json.charset = content.document.characterSet;
       json.mayEnableCharacterEncodingMenu = docShell.mayEnableCharacterEncodingMenu;
+
+      // Separately, if we're stopped, we also want to know the content principal:
+      if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) {
+        json.principal = content.document.nodePrincipal;
+      }
     }
 
     json.inLoadURI = WebNavigation.inLoadURI;
     this._send("Content:StateChange", json, objects);
   },
 
   onProgressChange: function onProgressChange(aWebProgress, aRequest, aCurSelf, aMaxSelf, aCurTotal, aMaxTotal) {
     let json = this._setupJSON(aWebProgress, aRequest);
--- a/toolkit/modules/RemoteWebProgress.jsm
+++ b/toolkit/modules/RemoteWebProgress.jsm
@@ -220,16 +220,19 @@ RemoteWebProgressManager.prototype = {
     if (isTopLevel) {
       this._browser._contentWindow = objects.contentWindow;
       this._browser._documentContentType = json.documentContentType;
       this._browser.inLoadURI = json.inLoadURI;
       if (json.charset) {
         this._browser._characterSet = json.charset;
         this._browser._mayEnableCharacterEncodingMenu = json.mayEnableCharacterEncodingMenu;
       }
+      if (json.principal) {
+        this._browser._contentPrincipal = json.principal;
+      }
     }
 
     switch (aMessage.name) {
     case "Content:StateChange":
       if (isTopLevel) {
         this._browser._documentURI = newURI(json.documentURI);
       }
       this._callProgressListeners("onStateChange", webProgress, request, json.stateFlags, json.status);
@@ -244,17 +247,16 @@ RemoteWebProgressManager.prototype = {
       remoteWebNav.canGoBack = json.canGoBack;
       remoteWebNav.canGoForward = json.canGoForward;
 
       if (isTopLevel) {
         remoteWebNav._currentURI = location;
         this._browser._documentURI = newURI(json.documentURI);
         this._browser._contentTitle = json.title;
         this._browser._imageDocument = null;
-        this._browser._contentPrincipal = json.principal;
         this._browser._isSyntheticDocument = json.synthetic;
         this._browser._innerWindowID = json.innerWindowID;
       }
 
       this._callProgressListeners("onLocationChange", webProgress, request, location, flags);
       break;
 
     case "Content:SecurityChange":