Bug 1193837: Part 1 - Cache the last known inner window ID of remote browsers in parent process. r=billm
☠☠ backed out by de8bc7c996fe ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Mon, 30 Nov 2015 17:56:01 -0800
changeset 309346 c3307a5ac126e1347fc1cec02e5932544b904d51
parent 309345 2ec770d354e53708be3887e8e678ce21866d7a8e
child 309347 ebe2433705a55c4b91d5726ed81574e3bcb5c6fb
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1193837
milestone45.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 1193837: Part 1 - Cache the last known inner window ID of remote browsers in parent process. r=billm
toolkit/content/browser-child.js
toolkit/content/widgets/browser.xml
toolkit/content/widgets/remote-browser.xml
toolkit/modules/RemoteWebProgress.jsm
--- a/toolkit/content/browser-child.js
+++ b/toolkit/content/browser-child.js
@@ -50,39 +50,45 @@ var WebProgressListener = {
 
   _requestSpec: function (aRequest, aPropertyName) {
     if (!aRequest || !(aRequest instanceof Ci.nsIChannel))
       return null;
     return aRequest.QueryInterface(Ci.nsIChannel)[aPropertyName].spec;
   },
 
   _setupJSON: function setupJSON(aWebProgress, aRequest) {
+    let innerWindowID = null;
     if (aWebProgress) {
-      let domWindowID;
+      let domWindowID = null;
       try {
-        domWindowID = aWebProgress && aWebProgress.DOMWindowID;
+        let utils = aWebProgress.DOMWindow.QueryInterface(Ci.nsIInterfaceRequestor)
+                                .getInterface(Ci.nsIDOMWindowUtils);
+        domWindowID = utils.outerWindowID;
+        innerWindowID = utils.currentInnerWindowID;
       } catch (e) {
         // If nsDocShell::Destroy has already been called, then we'll
-        // get NS_NOINTERFACE when trying to get the DOM window ID.
-        domWindowID = null;
+        // get NS_NOINTERFACE when trying to get the DOM window.
+        // If there is no current inner window, we'll get
+        // NS_ERROR_NOT_AVAILABLE.
       }
 
       aWebProgress = {
         isTopLevel: aWebProgress.isTopLevel,
         isLoadingDocument: aWebProgress.isLoadingDocument,
         loadType: aWebProgress.loadType,
         DOMWindowID: domWindowID
       };
     }
 
     return {
       webProgress: aWebProgress || null,
       requestURI: this._requestSpec(aRequest, "URI"),
       originalRequestURI: this._requestSpec(aRequest, "originalURI"),
-      documentContentType: content.document && content.document.contentType
+      documentContentType: content.document && content.document.contentType,
+      innerWindowID,
     };
   },
 
   _setupObjects: function setupObjects(aWebProgress, aRequest) {
     let domWindow;
     try {
       domWindow = aWebProgress && aWebProgress.DOMWindow;
     } catch (e) {
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -415,16 +415,32 @@
         <getter><![CDATA[
           return this.contentWindow
                      .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                      .getInterface(Components.interfaces.nsIDOMWindowUtils)
                      .outerWindowID;
         ]]></getter>
       </property>
 
+      <property name="innerWindowID" readonly="true">
+        <getter><![CDATA[
+          try {
+            return this.contentWindow
+                       .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+                       .getInterface(Components.interfaces.nsIDOMWindowUtils)
+                       .currentInnerWindowID;
+          } catch (e) {
+            if (e.result != Cr.NS_ERROR_NOT_AVAILABLE) {
+              throw e;
+            }
+            return null;
+          }
+        ]]></getter>
+      </property>
+
       <field name="_lastSearchString">null</field>
       <field name="_lastSearchHighlight">false</field>
 
       <property name="webProgress"
                 readonly="true"
                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebProgress);"/>
 
       <field name="_contentWindow">null</field>
@@ -1176,16 +1192,17 @@
               "_documentContentType",
               "_contentTitle",
               "_characterSet",
               "_contentPrincipal",
               "_imageDocument",
               "_fullZoom",
               "_textZoom",
               "_isSyntheticDocument",
+              "_innerWindowID",
             ]);
           }
 
           var ourFieldValues = {};
           var otherFieldValues = {};
           for (var field of fieldsToSwap) {
             ourFieldValues[field] = this[field];
             otherFieldValues[field] = aOtherBrowser[field];
--- a/toolkit/content/widgets/remote-browser.xml
+++ b/toolkit/content/widgets/remote-browser.xml
@@ -207,16 +207,23 @@
         ]]></getter>
       </property>
 
       <field name="_outerWindowID">null</field>
       <property name="outerWindowID"
                 onget="return this._outerWindowID"
                 readonly="true"/>
 
+      <field name="_innerWindowID">null</field>
+      <property name="innerWindowID">
+        <getter><![CDATA[
+          return this._innerWindowID;
+        ]]></getter>
+      </property>
+
       <property name="autoCompletePopup"
                 onget="return document.getElementById(this.getAttribute('autocompletepopup'))"
                 readonly="true"/>
 
       <property name="docShellIsActive">
         <getter>
           <![CDATA[
             let {frameLoader} = this.QueryInterface(Ci.nsIFrameLoaderOwner);
--- a/toolkit/modules/RemoteWebProgress.jsm
+++ b/toolkit/modules/RemoteWebProgress.jsm
@@ -230,16 +230,17 @@ RemoteWebProgressManager.prototype = {
         this._browser.webNavigation._currentURI = location;
         this._browser._characterSet = json.charset;
         this._browser._documentURI = newURI(json.documentURI);
         this._browser._contentTitle = json.title;
         this._browser._imageDocument = null;
         this._browser._mayEnableCharacterEncodingMenu = json.mayEnableCharacterEncodingMenu;
         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":
       let [status, state] = this._fixSSLStatusAndState(json.status, json.state);