Backed out changeset 70304898d836 (bug 1595927) for causing browser_cmd_click.js to permafail CLOSED TREE
authorCiure Andrei <aciure@mozilla.com>
Thu, 14 Nov 2019 23:35:19 +0200
changeset 502034 f7d3a6261cb34b81f7382a917069a4ed84e573a7
parent 502033 96b4cb315770c2037cb2cee9c7ffd76ef252ed2b
child 502035 d0af2df439cdf6c7e153a2f4e209b0a110f20bd4
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1595927
milestone72.0a1
backs out70304898d836c345e2ad3583ed148bb5ba0797d9
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
Backed out changeset 70304898d836 (bug 1595927) for causing browser_cmd_click.js to permafail CLOSED TREE
toolkit/components/remotebrowserutils/RemoteWebNavigation.jsm
toolkit/components/remotebrowserutils/components.conf
toolkit/components/remotebrowserutils/moz.build
toolkit/content/widgets/browser-custom-element.js
--- a/toolkit/components/remotebrowserutils/RemoteWebNavigation.jsm
+++ b/toolkit/components/remotebrowserutils/RemoteWebNavigation.jsm
@@ -9,72 +9,76 @@ ChromeUtils.defineModuleGetter(
   "resource://gre/modules/Services.jsm"
 );
 ChromeUtils.defineModuleGetter(
   this,
   "PrivateBrowsingUtils",
   "resource://gre/modules/PrivateBrowsingUtils.jsm"
 );
 
-class RemoteWebNavigation {
-  constructor(aBrowser) {
-    this._browser = aBrowser;
-    this._cancelContentJSEpoch = 1;
-    this._currentURI = null;
-    this.canGoBack = false;
-    this.canGoForward = false;
-    this.referringURI = null;
-    this.wrappedJSObject = this;
-  }
+function RemoteWebNavigation() {
+  this.wrappedJSObject = this;
+  this._cancelContentJSEpoch = 1;
+}
+
+RemoteWebNavigation.prototype = {
+  classDescription: "nsIWebNavigation for remote browsers",
+  classID: Components.ID("{4b56964e-cdf3-4bb8-830c-0e2dad3f4ebd}"),
+  contractID: "@mozilla.org/remote-web-navigation;1",
+
+  QueryInterface: ChromeUtils.generateQI([Ci.nsIWebNavigation]),
 
   swapBrowser(aBrowser) {
     this._browser = aBrowser;
-  }
+  },
 
+  canGoBack: false,
+  canGoForward: false,
   goBack() {
     let cancelContentJSEpoch = this._cancelContentJSEpoch++;
     this._browser.frameLoader.remoteTab.maybeCancelContentJSExecution(
       Ci.nsIRemoteTab.NAVIGATE_BACK,
       { epoch: cancelContentJSEpoch }
     );
     this._sendMessage("WebNavigation:GoBack", { cancelContentJSEpoch });
-  }
+  },
   goForward() {
     let cancelContentJSEpoch = this._cancelContentJSEpoch++;
     this._browser.frameLoader.remoteTab.maybeCancelContentJSExecution(
       Ci.nsIRemoteTab.NAVIGATE_FORWARD,
       { epoch: cancelContentJSEpoch }
     );
     this._sendMessage("WebNavigation:GoForward", { cancelContentJSEpoch });
-  }
+  },
   gotoIndex(aIndex) {
     let cancelContentJSEpoch = this._cancelContentJSEpoch++;
     this._browser.frameLoader.remoteTab.maybeCancelContentJSExecution(
       Ci.nsIRemoteTab.NAVIGATE_INDEX,
       { index: aIndex, epoch: cancelContentJSEpoch }
     );
     this._sendMessage("WebNavigation:GotoIndex", {
       index: aIndex,
       cancelContentJSEpoch,
     });
-  }
+  },
   loadURI(aURI, aLoadURIOptions) {
     let uri;
     try {
-      let fixupFlags = Services.uriFixup.webNavigationFlagsToFixupFlags(
+      let fixup = Cc["@mozilla.org/docshell/urifixup;1"].getService();
+      let fixupFlags = fixup.webNavigationFlagsToFixupFlags(
         aURI,
         aLoadURIOptions.loadFlags
       );
       let isBrowserPrivate = PrivateBrowsingUtils.isBrowserPrivate(
         this._browser
       );
       if (isBrowserPrivate) {
         fixupFlags |= Services.uriFixup.FIXUP_FLAG_PRIVATE_CONTEXT;
       }
-      uri = Services.uriFixup.createFixupURI(aURI, fixupFlags);
+      uri = fixup.createFixupURI(aURI, fixupFlags);
 
       // We know the url is going to be loaded, let's start requesting network
       // connection before the content process asks.
       // Note that we might have already setup the speculative connection in
       // some cases, especially when the url is from location bar or its popup
       // menu.
       if (uri.schemeIs("http") || uri.schemeIs("https")) {
         let principal = aLoadURIOptions.triggeringPrincipal;
@@ -98,72 +102,64 @@ class RemoteWebNavigation {
       // reason (such as failing to parse the URI), just ignore it.
     }
 
     let cancelContentJSEpoch = this._cancelContentJSEpoch++;
     this._browser.frameLoader.remoteTab.maybeCancelContentJSExecution(
       Ci.nsIRemoteTab.NAVIGATE_URL,
       { uri, epoch: cancelContentJSEpoch }
     );
-    this._browser.frameLoader.browsingContext.loadURI(aURI, {
-      ...aLoadURIOptions,
-      cancelContentJSEpoch,
-    });
-  }
+    aLoadURIOptions.cancelContentJSEpoch = cancelContentJSEpoch;
+    this._browser.frameLoader.browsingContext.loadURI(aURI, aLoadURIOptions);
+  },
   setOriginAttributesBeforeLoading(aOriginAttributes) {
     this._sendMessage("WebNavigation:SetOriginAttributes", {
       originAttributes: aOriginAttributes,
     });
-  }
+  },
   reload(aReloadFlags) {
     this._sendMessage("WebNavigation:Reload", { loadFlags: aReloadFlags });
-  }
+  },
   stop(aStopFlags) {
     this._sendMessage("WebNavigation:Stop", { loadFlags: aStopFlags });
-  }
+  },
 
   get document() {
     return this._browser.contentDocument;
-  }
+  },
 
+  _currentURI: null,
   get currentURI() {
     if (!this._currentURI) {
       this._currentURI = Services.io.newURI("about:blank");
     }
+
     return this._currentURI;
-  }
+  },
   set currentURI(aURI) {
     // Bug 1498600 verify usages of systemPrincipal here
     let loadURIOptions = {
       triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
     };
     this.loadURI(aURI.spec, loadURIOptions);
-  }
+  },
+
+  referringURI: null,
 
   // Bug 1233803 - accessing the sessionHistory of remote browsers should be
   // done in content scripts.
   get sessionHistory() {
-    throw new Components.Exception(
-      "Not implemented",
-      Cr.NS_ERROR_NOT_IMPLEMENTED
-    );
-  }
+    throw Cr.NS_ERROR_NOT_IMPLEMENTED;
+  },
   set sessionHistory(aValue) {
-    throw new Components.Exception(
-      "Not implemented",
-      Cr.NS_ERROR_NOT_IMPLEMENTED
-    );
-  }
+    throw Cr.NS_ERROR_NOT_IMPLEMENTED;
+  },
 
   _sendMessage(aMessage, aData) {
     try {
       this._browser.sendMessageToActor(aMessage, aData, "WebNavigation");
     } catch (e) {
       Cu.reportError(e);
     }
-  }
-}
-
-RemoteWebNavigation.prototype.QueryInterface = ChromeUtils.generateQI([
-  Ci.nsIWebNavigation,
-]);
+  },
+};
 
 var EXPORTED_SYMBOLS = ["RemoteWebNavigation"];
new file mode 100644
--- /dev/null
+++ b/toolkit/components/remotebrowserutils/components.conf
@@ -0,0 +1,15 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+Classes = [
+    {
+        'cid': '{4b56964e-cdf3-4bb8-830c-0e2dad3f4ebd}',
+        'contract_ids': ['@mozilla.org/remote-web-navigation;1'],
+        'jsm': 'resource://gre/modules/RemoteWebNavigation.jsm',
+        'constructor': 'RemoteWebNavigation',
+        'processes': ProcessSelector.MAIN_PROCESS_ONLY,
+    },
+]
--- a/toolkit/components/remotebrowserutils/moz.build
+++ b/toolkit/components/remotebrowserutils/moz.build
@@ -6,9 +6,13 @@
 
 with Files('**'):
     BUG_COMPONENT = ('Core', 'DOM: Navigation')
 
 EXTRA_JS_MODULES += [
     'RemoteWebNavigation.jsm',
 ]
 
+XPCOM_MANIFESTS += [
+    'components.conf',
+]
+
 BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini']
--- a/toolkit/content/widgets/browser-custom-element.js
+++ b/toolkit/content/widgets/browser-custom-element.js
@@ -23,22 +23,16 @@
   );
 
   ChromeUtils.defineModuleGetter(
     LazyModules,
     "E10SUtils",
     "resource://gre/modules/E10SUtils.jsm"
   );
 
-  ChromeUtils.defineModuleGetter(
-    LazyModules,
-    "RemoteWebNavigation",
-    "resource://gre/modules/RemoteWebNavigation.jsm"
-  );
-
   const elementsToDestroyOnUnload = new Set();
 
   window.addEventListener(
     "unload",
     () => {
       for (let element of elementsToDestroyOnUnload.values()) {
         element.destroy();
       }
@@ -1257,19 +1251,26 @@
       this.resetFields();
       this.mInitialized = true;
       if (this.isRemoteBrowser) {
         /*
          * Don't try to send messages from this function. The message manager for
          * the <browser> element may not be initialized yet.
          */
 
-        this._remoteWebNavigation = new LazyModules.RemoteWebNavigation(this);
+        this._remoteWebNavigation = Cc[
+          "@mozilla.org/remote-web-navigation;1"
+        ].createInstance(Ci.nsIWebNavigation);
+        this._remoteWebNavigationImpl = this._remoteWebNavigation.wrappedJSObject;
+        this._remoteWebNavigationImpl.swapBrowser(this);
 
         // Initialize contentPrincipal to the about:blank principal for this loadcontext
+        let { Services } = ChromeUtils.import(
+          "resource://gre/modules/Services.jsm"
+        );
         let aboutBlank = Services.io.newURI("about:blank");
         let ssm = Services.scriptSecurityManager;
         this._contentPrincipal = ssm.getLoadContextContentPrincipal(
           aboutBlank,
           this.loadContext
         );
         // CSP for about:blank is null; if we ever change _contentPrincipal above,
         // we should re-evaluate the CSP here.
@@ -1573,18 +1574,19 @@
         if (aContentType != null) {
           this._documentContentType = aContentType;
         }
       }
     }
 
     updateWebNavigationForLocationChange(aCanGoBack, aCanGoForward) {
       if (this.isRemoteBrowser && this.messageManager) {
-        this._remoteWebNavigation.canGoBack = aCanGoBack;
-        this._remoteWebNavigation.canGoForward = aCanGoForward;
+        let remoteWebNav = this._remoteWebNavigationImpl;
+        remoteWebNav.canGoBack = aCanGoBack;
+        remoteWebNav.canGoForward = aCanGoForward;
       }
     }
 
     updateForLocationChange(
       aLocation,
       aCharset,
       aMayEnableCharacterEncodingMenu,
       aCharsetAutodetected,
@@ -1607,17 +1609,17 @@
           this._mayEnableCharacterEncodingMenu = aMayEnableCharacterEncodingMenu;
           this._charsetAutodetected = aCharsetAutodetected;
         }
 
         if (aContentType != null) {
           this._documentContentType = aContentType;
         }
 
-        this._remoteWebNavigation._currentURI = aLocation;
+        this._remoteWebNavigationImpl._currentURI = aLocation;
         this._documentURI = aDocumentURI;
         this._contentTitle = aTitle;
         this._imageDocument = null;
         this._contentPrincipal = aContentPrincipal;
         this._contentStoragePrincipal = aContentStoragePrincipal;
         this._contentBlockingAllowListPrincipal = aContentBlockingAllowListPrincipal;
         this._csp = aCSP;
         this._referrerInfo = aReferrerInfo;
@@ -1626,18 +1628,18 @@
         this._contentRequestContextID = aHaveRequestContextID
           ? aRequestContextID
           : null;
       }
     }
 
     purgeSessionHistory() {
       if (this.isRemoteBrowser) {
-        this._remoteWebNavigation.canGoBack = false;
-        this._remoteWebNavigation.canGoForward = false;
+        this._remoteWebNavigationImpl.canGoBack = false;
+        this._remoteWebNavigationImpl.canGoForward = false;
       }
       try {
         this.sendMessageToActor(
           "Browser:PurgeSessionHistory",
           {},
           "PurgeSessionHistory",
           true
         );
@@ -1950,16 +1952,17 @@
       // because these notifications are dispatched again once the docshells
       // are swapped.
       var fieldsToSwap = ["_webBrowserFind"];
 
       if (this.isRemoteBrowser) {
         fieldsToSwap.push(
           ...[
             "_remoteWebNavigation",
+            "_remoteWebNavigationImpl",
             "_remoteWebProgressManager",
             "_remoteWebProgress",
             "_remoteFinder",
             "_securityUI",
             "_documentURI",
             "_documentContentType",
             "_contentTitle",
             "_characterSet",
@@ -2002,18 +2005,18 @@
 
       if (!this.isRemoteBrowser) {
         // Null the current nsITypeAheadFind instances so that they're
         // lazily re-created on access. We need to do this because they
         // might have attached the wrong docShell.
         this._fastFind = aOtherBrowser._fastFind = null;
       } else {
         // Rewire the remote listeners
-        this._remoteWebNavigation.swapBrowser(this);
-        aOtherBrowser._remoteWebNavigation.swapBrowser(aOtherBrowser);
+        this._remoteWebNavigationImpl.swapBrowser(this);
+        aOtherBrowser._remoteWebNavigationImpl.swapBrowser(aOtherBrowser);
 
         if (
           this._remoteWebProgressManager &&
           aOtherBrowser._remoteWebProgressManager
         ) {
           this._remoteWebProgressManager.swapBrowser(this);
           aOtherBrowser._remoteWebProgressManager.swapBrowser(aOtherBrowser);
         }