Bug 1445080 - fix handling of remote web progress for non-tab browsers, r=Gijs,mconley a=jcristau
authorShane Caraveo <scaraveo@mozilla.com>
Wed, 14 Mar 2018 09:12:26 -0500
changeset 462675 d95900c76f20660c03d69d7a617e35447a571a40
parent 462674 903344884b5546cd939260fcc625051e8f546a86
child 462676 ae0358583eccd3019d6748f43c49df777ad545e6
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, mconley, jcristau
bugs1445080
milestone60.0
Bug 1445080 - fix handling of remote web progress for non-tab browsers, r=Gijs,mconley a=jcristau Ensure remoteWebProgress is initialized for remote browsers. Includes devtools fix from jryans. MozReview-Commit-ID: Ce3TzwkNnyi
browser/components/extensions/test/browser/browser_ext_sidebarAction_runtime.js
devtools/client/responsive.html/browser/swap.js
toolkit/content/widgets/remote-browser.xml
--- a/browser/components/extensions/test/browser/browser_ext_sidebarAction_runtime.js
+++ b/browser/components/extensions/test/browser/browser_ext_sidebarAction_runtime.js
@@ -42,16 +42,20 @@ let extensionData = {
 };
 
 add_task(async function test_sidebar_disconnect() {
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   let connected = extension.awaitMessage("connected");
   await extension.startup();
   await connected;
 
+  // Bug 1445080 fixes currentURI, test to avoid future breakage.
+  let currentURI = window.SidebarUI.browser.contentDocument.getElementById("webext-panels-browser").currentURI;
+  is(currentURI.scheme, "moz-extension", "currentURI is set correctly");
+
   // switching sidebar to another extension
   let extension2 = ExtensionTestUtils.loadExtension(extensionData);
   let switched = Promise.all([
     extension.awaitMessage("disconnected"),
     extension2.awaitMessage("connected")]);
   await extension2.startup();
   await switched;
 
--- a/devtools/client/responsive.html/browser/swap.js
+++ b/devtools/client/responsive.html/browser/swap.js
@@ -370,16 +370,22 @@ function addXULBrowserDecorations(browse
       swapBrowser() {},
     };
   }
   if (browser._remoteWebProgressManager == undefined) {
     browser._remoteWebProgressManager = {
       swapBrowser() {},
     };
   }
+  if (browser._remoteWebProgress == undefined) {
+    browser._remoteWebProgress = {
+      addProgressListener() {},
+      removeProgressListener() {},
+    };
+  }
 }
 
 function tabLoaded(tab) {
   return new Promise(resolve => {
     function handle(event) {
       if (event.originalTarget != tab.linkedBrowser.contentDocument ||
           event.target.location.href == "about:blank") {
         return;
--- a/toolkit/content/widgets/remote-browser.xml
+++ b/toolkit/content/widgets/remote-browser.xml
@@ -44,34 +44,19 @@
       <field name="_remoteWebNavigation">null</field>
 
       <property name="webNavigation"
                 onget="return this._remoteWebNavigation;"
                 readonly="true"/>
 
       <field name="_remoteWebProgress">null</field>
 
-      <property name="webProgress" readonly="true">
-      	<getter>
-      	  <![CDATA[
-            if (!this._remoteWebProgress) {
-              // Don't attempt to create the remote web progress if the
-              // messageManager has already gone away
-              if (!this.messageManager)
-                return null;
-
-              let jsm = "resource://gre/modules/RemoteWebProgress.jsm";
-              let { RemoteWebProgressManager } = ChromeUtils.import(jsm, {});
-              this._remoteWebProgressManager = new RemoteWebProgressManager(this);
-              this._remoteWebProgress = this._remoteWebProgressManager.topLevelWebProgress;
-            }
-            return this._remoteWebProgress;
-      	  ]]>
-      	</getter>
-      </property>
+      <property name="webProgress"
+                onget="return this._remoteWebProgress;"
+                readonly="true"/>
 
       <field name="_remoteFinder">null</field>
 
       <property name="finder" readonly="true">
         <getter><![CDATA[
           if (!this._remoteFinder) {
             // Don't attempt to create the remote finder if the
             // messageManager has already gone away
@@ -408,16 +393,24 @@
           this.messageManager.addMessageListener("DOMTitleChanged", this);
           this.messageManager.addMessageListener("ImageDocumentLoaded", this);
           this.messageManager.addMessageListener("FullZoomChange", this);
           this.messageManager.addMessageListener("TextZoomChange", this);
           this.messageManager.addMessageListener("ZoomChangeUsingMouseWheel", this);
           this.messageManager.addMessageListener("DOMFullscreen:RequestExit", this);
           this.messageManager.addMessageListener("DOMFullscreen:RequestRollback", this);
           this.messageManager.addMessageListener("MozApplicationManifest", this);
+
+          // browser-child messages, such as Content:LocationChange, are handled in
+          // RemoteWebProgress, ensure it is loaded and ready.
+          let jsm = "resource://gre/modules/RemoteWebProgress.jsm";
+          let { RemoteWebProgressManager } = ChromeUtils.import(jsm, {});
+          this._remoteWebProgressManager = new RemoteWebProgressManager(this);
+          this._remoteWebProgress = this._remoteWebProgressManager.topLevelWebProgress;
+
           this.messageManager.loadFrameScript("chrome://global/content/browser-child.js", true);
 
           if (this.hasAttribute("selectmenulist")) {
             this.messageManager.addMessageListener("Forms:ShowDropDown", this);
             this.messageManager.addMessageListener("Forms:HideDropDown", this);
           }
 
           if (!this.hasAttribute("disablehistory")) {