Bug 1249362 - initialize remote browser's contentPrincipal to a null principal, r?mconley draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 06 May 2016 12:19:09 +0100
changeset 364338 78677d1cca684c5a3a3ba8c38e25d9965eb6d57c
parent 364236 e65c3c2186710e9ee1dfb3f254bd45019ea34c80
child 520233 e12b92a4d385bd6f586e42dbb77d5a94e5812f9a
push id17409
push usergijskruitbosch@gmail.com
push dateFri, 06 May 2016 11:19:45 +0000
reviewersmconley
bugs1249362
milestone49.0a1
Bug 1249362 - initialize remote browser's contentPrincipal to a null principal, r?mconley MozReview-Commit-ID: 4cglQaTLf7l
browser/base/content/browser.js
toolkit/content/widgets/remote-browser.xml
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6358,23 +6358,16 @@ function isTabEmpty(aTab) {
 function checkEmptyPageOrigin(browser = gBrowser.selectedBrowser,
                               uri = browser.currentURI) {
   // If another page opened this page with e.g. window.open, this page might
   // 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.
-    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;
     }
     return contentPrincipal.URI.equals(uri);
   }
--- a/toolkit/content/widgets/remote-browser.xml
+++ b/toolkit/content/widgets/remote-browser.xml
@@ -368,16 +368,20 @@
            * the <browser> element may not be initialized yet.
            */
 
           this._remoteWebNavigation = Components.classes["@mozilla.org/remote-web-navigation;1"]
                                                 .createInstance(Components.interfaces.nsIWebNavigation);
           this._remoteWebNavigationImpl = this._remoteWebNavigation.wrappedJSObject;
           this._remoteWebNavigationImpl.swapBrowser(this);
 
+          // Initialize to the null principal
+          let Services = Components.utils.import("resource://gre/modules/Services.jsm", {}).Services
+          this._contentPrincipal = Services.scriptSecurityManager.createNullPrincipal({});
+
           this.messageManager.addMessageListener("Browser:Init", this);
           this.messageManager.addMessageListener("DOMTitleChanged", this);
           this.messageManager.addMessageListener("ImageDocumentLoaded", this);
           this.messageManager.addMessageListener("DocumentInserted", this);
           this.messageManager.addMessageListener("FullZoomChange", this);
           this.messageManager.addMessageListener("TextZoomChange", this);
           this.messageManager.addMessageListener("ZoomChangeUsingMouseWheel", this);
           this.messageManager.addMessageListener("DOMFullscreen:RequestExit", this);
@@ -387,18 +391,17 @@
 
           if (this.hasAttribute("selectmenulist")) {
             this.messageManager.addMessageListener("Forms:ShowDropDown", this);
             this.messageManager.addMessageListener("Forms:HideDropDown", this);
             this.messageManager.loadFrameScript("chrome://global/content/select-child.js", true);
           }
 
           if (!this.hasAttribute("disablehistory")) {
-            Components.utils.import("resource://gre/modules/Services.jsm", {}).Services
-                      .obs.addObserver(this, "browser:purge-session-history", true);
+            Services.obs.addObserver(this, "browser:purge-session-history", true);
           }
 
           let jsm = "resource://gre/modules/RemoteController.jsm";
           let RemoteController = Components.utils.import(jsm, {}).RemoteController;
           this._controller = new RemoteController(this);
           this.controllers.appendController(this._controller);
         ]]>
       </constructor>