Bug 1492482 - Stop sending CPOWs with WebProgressChild messages. r=Felipe
authorMike Conley <mconley@mozilla.com>
Tue, 02 Oct 2018 18:38:39 +0000
changeset 487612 cfa50dc1f61600b08d966210d0319b052ac86627
parent 487611 7cfc774d8178448d690a9c2c2eda8671dc5cf91a
child 487613 4392b5198fb7773f6148d2caedff82da5f527bfe
push id246
push userfmarier@mozilla.com
push dateSat, 13 Oct 2018 00:15:40 +0000
reviewersFelipe
bugs1492482
milestone64.0a1
Bug 1492482 - Stop sending CPOWs with WebProgressChild messages. r=Felipe Depends on D6972 Differential Revision: https://phabricator.services.mozilla.com/D6973
toolkit/content/widgets/browser.xml
toolkit/modules/RemoteWebProgress.jsm
toolkit/modules/WebProgressChild.jsm
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -494,34 +494,24 @@
                 readonly="true"
                 onget="return this.isRemoteBrowser ? this._remoteWebNavigation : this.docShell.QueryInterface(Components.interfaces.nsIWebNavigation);"/>
 
       <field name="_remoteWebProgress">null</field>
       <property name="webProgress"
                 readonly="true"
                 onget="return this.isRemoteBrowser ? this._remoteWebProgress : this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebProgress);"/>
 
-      <field name="_contentWindow">null</field>
-      <property name="contentWindowAsCPOW"
-                readonly="true"
-                onget="return this.isRemoteBrowser ? this._contentWindow : this.contentWindow;"/>
-
       <property name="sessionHistory"
                 onget="return this.webNavigation.sessionHistory;"
                 readonly="true"/>
 
       <property name="markupDocumentViewer"
                 onget="return this.docShell.contentViewer;"
                 readonly="true"/>
 
-      <field name="_contentDocument">null</field>
-      <property name="contentDocumentAsCPOW"
-                onget="return this.isRemoteBrowser ? this._contentDocument : this.contentDocument;"
-                readonly="true"/>
-
       <field name="_contentTitle">""</field>
       <property name="contentTitle"
                 onget="return this.isRemoteBrowser ? this._contentTitle : this.contentDocument.title;"
                 readonly="true"/>
 
       <field name="_characterSet">""</field>
       <property name="characterSet"
                 onget="return this.isRemoteBrowser ? this._characterSet : this.docShell.charset;">
--- a/toolkit/modules/RemoteWebProgress.jsm
+++ b/toolkit/modules/RemoteWebProgress.jsm
@@ -2,22 +2,21 @@
 // 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/.
 
 var EXPORTED_SYMBOLS = ["RemoteWebProgressManager"];
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-function RemoteWebProgressRequest(spec, originalSpec, matchedList, requestCPOW) {
+function RemoteWebProgressRequest(spec, originalSpec, matchedList) {
   this.wrappedJSObject = this;
 
   this._uri = Services.io.newURI(spec);
   this._originalURI = Services.io.newURI(originalSpec);
-  this._requestCPOW = requestCPOW;
   this._matchedList = matchedList;
 }
 
 RemoteWebProgressRequest.prototype = {
   QueryInterface: ChromeUtils.generateQI([Ci.nsIChannel, Ci.nsIClassifiedChannel]),
 
   get URI() { return this._uri; },
   get originalURI() { return this._originalURI; },
@@ -25,17 +24,16 @@ RemoteWebProgressRequest.prototype = {
 };
 
 function RemoteWebProgress(aManager, aIsTopLevel) {
   this.wrappedJSObject = this;
 
   this._manager = aManager;
 
   this._isLoadingDocument = false;
-  this._DOMWindow = null;
   this._DOMWindowID = 0;
   this._isTopLevel = aIsTopLevel;
   this._loadType = 0;
 }
 
 RemoteWebProgress.prototype = {
   NOTIFY_STATE_REQUEST:  0x00000001,
   NOTIFY_STATE_DOCUMENT: 0x00000002,
@@ -45,17 +43,19 @@ RemoteWebProgress.prototype = {
   NOTIFY_PROGRESS:       0x00000010,
   NOTIFY_STATUS:         0x00000020,
   NOTIFY_SECURITY:       0x00000040,
   NOTIFY_LOCATION:       0x00000080,
   NOTIFY_REFRESH:        0x00000100,
   NOTIFY_ALL:            0x000001ff,
 
   get isLoadingDocument() { return this._isLoadingDocument; },
-  get DOMWindow() { return this._DOMWindow; },
+  get DOMWindow() {
+    throw Cr.NS_ERROR_NOT_AVAILABLE;
+  },
   get DOMWindowID() { return this._DOMWindowID; },
   get isTopLevel() { return this._isTopLevel; },
   get loadType() { return this._loadType; },
 
   addProgressListener(aListener, aNotifyMask) {
     this._manager.addProgressListener(aListener, aNotifyMask);
   },
 
@@ -145,17 +145,16 @@ RemoteWebProgressManager.prototype = {
           Cu.reportError("RemoteWebProgress failed to call " + methodName + ": " + ex + "\n");
         }
       }
     }
   },
 
   receiveMessage(aMessage) {
     let json = aMessage.json;
-    let objects = aMessage.objects;
     // This message is a custom one we send as a result of a loadURI call.
     // It shouldn't go through the same processing as all the forwarded
     // webprogresslistener messages.
     if (aMessage.name == "Content:LoadURIResult") {
       this._browser.inLoadURI = false;
       return;
     }
 
@@ -165,34 +164,29 @@ RemoteWebProgressManager.prototype = {
     // really have a concept of subframes/content we always create a new object
     // for those.
     if (json.webProgress) {
       webProgress = isTopLevel ? this._topLevelWebProgress
                                : new RemoteWebProgress(this, false);
 
       // Update the actual WebProgress fields.
       webProgress._isLoadingDocument = json.webProgress.isLoadingDocument;
-      webProgress._DOMWindow = objects.DOMWindow;
       webProgress._DOMWindowID = json.webProgress.DOMWindowID;
       webProgress._loadType = json.webProgress.loadType;
-      webProgress._webProgressCPOW = objects.webProgress;
     }
 
     // The WebProgressRequest object however is always dynamic.
     let request = null;
     if (json.requestURI) {
       request = new RemoteWebProgressRequest(json.requestURI,
                                              json.originalRequestURI,
-                                             json.matchedList,
-                                             objects.request);
+                                             json.matchedList);
     }
 
     if (isTopLevel) {
-      this._browser._contentWindow = objects.contentWindow;
-      this._browser._contentDocument = objects.contentDocument;
       // Setting a content-type back to `null` is quite nonsensical for the
       // frontend, especially since we're not expecting it.
       if (json.documentContentType !== null) {
         this._browser._documentContentType = json.documentContentType;
       }
       if (typeof json.inLoadURI != "undefined") {
         this._browser.inLoadURI = json.inLoadURI;
       }
--- a/toolkit/modules/WebProgressChild.jsm
+++ b/toolkit/modules/WebProgressChild.jsm
@@ -82,84 +82,60 @@ class WebProgressChild {
       webProgress: aWebProgress || null,
       requestURI: this._requestSpec(aRequest, "URI"),
       originalRequestURI: this._requestSpec(aRequest, "originalURI"),
       documentContentType: contentDocument ? contentDocument.contentType : null,
       innerWindowID,
     };
   }
 
-  _setupObjects(aWebProgress, aRequest) {
-    let domWindow;
-    try {
-      domWindow = aWebProgress && aWebProgress.DOMWindow;
-    } catch (e) {
-      // If nsDocShell::Destroy has already been called, then we'll
-      // get NS_NOINTERFACE when trying to get the DOM window. Ignore
-      // that here.
-      domWindow = null;
-    }
-
-    return {
-      contentWindow: this.mm.content,
-      contentDocument: this.mm.content.document,
-      // DOMWindow is not necessarily the this.mm.content-window with subframes.
-      DOMWindow: domWindow,
-      webProgress: aWebProgress,
-      request: aRequest,
-    };
-  }
-
-  _send(name, data, objects) {
-    this.mm.sendAsyncMessage(name, data, objects);
+  _send(name, data) {
+    this.mm.sendAsyncMessage(name, data);
   }
 
   onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
     let json = this._setupJSON(aWebProgress, aRequest, aStateFlags);
-    let objects = this._setupObjects(aWebProgress, aRequest);
 
     json.stateFlags = aStateFlags;
     json.status = aStatus;
 
     // 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 = this.mm.content.document.documentURIObject.spec;
       json.charset = this.mm.content.document.characterSet;
       json.mayEnableCharacterEncodingMenu = this.mm.docShell.mayEnableCharacterEncodingMenu;
       json.inLoadURI = this.inLoadURI;
     }
 
-    this._send("Content:StateChange", json, objects);
+    this._send("Content:StateChange", json);
   }
 
   // Note: Because the nsBrowserStatusFilter timeout runnable is
   // SystemGroup-labeled, this method should not modify this.mm.content DOM or
   // run this.mm.content JS.
   onProgressChange(aWebProgress, aRequest, aCurSelf, aMaxSelf, aCurTotal, aMaxTotal) {
     let json = this._setupJSON(aWebProgress, aRequest);
-    let objects = this._setupObjects(aWebProgress, aRequest);
 
     json.curSelf = aCurSelf;
     json.maxSelf = aMaxSelf;
     json.curTotal = aCurTotal;
     json.maxTotal = aMaxTotal;
 
-    this._send("Content:ProgressChange", json, objects);
+    this._send("Content:ProgressChange", json);
   }
 
   onProgressChange64(aWebProgress, aRequest, aCurSelf, aMaxSelf, aCurTotal, aMaxTotal) {
     this.onProgressChange(aWebProgress, aRequest, aCurSelf, aMaxSelf, aCurTotal, aMaxTotal);
   }
 
   onLocationChange(aWebProgress, aRequest, aLocationURI, aFlags) {
     let json = this._setupJSON(aWebProgress, aRequest);
-    let objects = this._setupObjects(aWebProgress, aRequest);
 
     json.location = aLocationURI ? aLocationURI.spec : "";
     json.flags = aFlags;
 
     // These properties can change even for a sub-frame navigation.
     let webNav = this.mm.docShell.QueryInterface(Ci.nsIWebNavigation);
     json.canGoBack = webNav.canGoBack;
     json.canGoForward = webNav.canGoForward;
@@ -183,57 +159,55 @@ class WebProgressChild {
           uri = uri.mutate()
                    .setUserPass("")
                    .finalize();
         } catch (ex) { /* Ignore failures on about: URIs. */ }
         CrashReporter.annotateCrashReport("URL", uri.spec);
       }
     }
 
-    this._send("Content:LocationChange", json, objects);
+    this._send("Content:LocationChange", json);
   }
 
   // Note: Because the nsBrowserStatusFilter timeout runnable is
   // SystemGroup-labeled, this method should not modify this.mm.content DOM or
   // run this.mm.content JS.
   onStatusChange(aWebProgress, aRequest, aStatus, aMessage) {
     let json = this._setupJSON(aWebProgress, aRequest);
-    let objects = this._setupObjects(aWebProgress, aRequest);
 
     json.status = aStatus;
     json.message = aMessage;
 
-    this._send("Content:StatusChange", json, objects);
+    this._send("Content:StatusChange", json);
   }
 
   getSecInfoAsString() {
     let secInfo = this.mm.docShell.securityUI.secInfo;
     if (secInfo) {
       return serializationHelper.serializeToString(secInfo);
     }
 
     return null;
   }
 
   onSecurityChange(aWebProgress, aRequest, aOldState, aState,
                    aContentBlockingLogJSON) {
     let json = this._setupJSON(aWebProgress, aRequest);
-    let objects = this._setupObjects(aWebProgress, aRequest);
 
     json.oldState = aOldState;
     json.state = aState;
     json.secInfo = this.getSecInfoAsString();
     json.contentBlockingLogJSON = aContentBlockingLogJSON;
 
     json.matchedList = null;
     if (aRequest && aRequest instanceof Ci.nsIClassifiedChannel) {
       json.matchedList = aRequest.matchedList;
     }
 
-    this._send("Content:SecurityChange", json, objects);
+    this._send("Content:SecurityChange", json);
   }
 
   onRefreshAttempted(aWebProgress, aURI, aDelay, aSameURI) {
     return true;
   }
 
   sendLoadCallResult() {
     this.mm.sendAsyncMessage("Content:LoadURIResult");