Bug 1529684 - Part 5: Support using remote window proxy objects in the parent process, r=farre
authorNika Layzell <nika@thelayzells.com>
Thu, 14 Mar 2019 18:50:52 +0000
changeset 464038 cb217921cf9a1aee8d4f3b43fe0209c0899ddcc4
parent 464037 0a3848628be99cb7e072e992b6075e9ff069da12
child 464039 2e9f31ee6571578ab190de831353a3a870609f07
push id35707
push userrmaries@mozilla.com
push dateFri, 15 Mar 2019 03:42:43 +0000
treeherdermozilla-central@5ce27c44f79e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfarre
bugs1529684
milestone67.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 1529684 - Part 5: Support using remote window proxy objects in the parent process, r=farre Depends on D22762 Differential Revision: https://phabricator.services.mozilla.com/D22763
docshell/base/BrowsingContext.cpp
--- a/docshell/base/BrowsingContext.cpp
+++ b/docshell/base/BrowsingContext.cpp
@@ -581,28 +581,37 @@ void BrowsingContext::Location(JSContext
   }
 }
 
 void BrowsingContext::Close(CallerType aCallerType, ErrorResult& aError) {
   // FIXME We need to set mClosed, but only once we're sending the
   //       DOMWindowClose event (which happens in the process where the
   //       document for this browsing context is loaded).
   //       See https://bugzilla.mozilla.org/show_bug.cgi?id=1516343.
-  ContentChild* cc = ContentChild::GetSingleton();
-  cc->SendWindowClose(this, aCallerType == CallerType::System);
+  if (ContentChild* cc = ContentChild::GetSingleton()) {
+    cc->SendWindowClose(this, aCallerType == CallerType::System);
+  } else if (ContentParent* cp = Canonical()->GetContentParent()) {
+    Unused << cp->SendWindowClose(this, aCallerType == CallerType::System);
+  }
 }
 
 void BrowsingContext::Focus(ErrorResult& aError) {
-  ContentChild* cc = ContentChild::GetSingleton();
-  cc->SendWindowFocus(this);
+  if (ContentChild* cc = ContentChild::GetSingleton()) {
+    cc->SendWindowFocus(this);
+  } else if (ContentParent* cp = Canonical()->GetContentParent()) {
+    Unused << cp->SendWindowFocus(this);
+  }
 }
 
 void BrowsingContext::Blur(ErrorResult& aError) {
-  ContentChild* cc = ContentChild::GetSingleton();
-  cc->SendWindowBlur(this);
+  if (ContentChild* cc = ContentChild::GetSingleton()) {
+    cc->SendWindowBlur(this);
+  } else if (ContentParent* cp = Canonical()->GetContentParent()) {
+    Unused << cp->SendWindowBlur(this);
+  }
 }
 
 Nullable<WindowProxyHolder> BrowsingContext::GetTop(ErrorResult& aError) {
   // We never return null or throw an error, but the implementation in
   // nsGlobalWindow does and we need to use the same signature.
   return WindowProxyHolder(TopLevelBrowsingContext());
 }
 
@@ -662,24 +671,32 @@ void BrowsingContext::PostMessageMoz(JSC
   }
 
   ipc::StructuredCloneData message;
   message.Write(aCx, aMessage, transferArray, aError);
   if (NS_WARN_IF(aError.Failed())) {
     return;
   }
 
-  ContentChild* cc = ContentChild::GetSingleton();
   ClonedMessageData messageData;
-  if (!message.BuildClonedMessageDataForChild(cc, messageData)) {
-    aError.Throw(NS_ERROR_FAILURE);
-    return;
+  if (ContentChild* cc = ContentChild::GetSingleton()) {
+    if (!message.BuildClonedMessageDataForChild(cc, messageData)) {
+      aError.Throw(NS_ERROR_FAILURE);
+      return;
+    }
+
+    cc->SendWindowPostMessage(this, messageData, data);
+  } else if (ContentParent* cp = Canonical()->GetContentParent()) {
+    if (!message.BuildClonedMessageDataForParent(cp, messageData)) {
+      aError.Throw(NS_ERROR_FAILURE);
+      return;
+    }
+
+    Unused << cp->SendWindowPostMessage(this, messageData, data);
   }
-
-  cc->SendWindowPostMessage(this, messageData, data);
 }
 
 void BrowsingContext::PostMessageMoz(JSContext* aCx,
                                      JS::Handle<JS::Value> aMessage,
                                      const WindowPostMessageOptions& aOptions,
                                      nsIPrincipal& aSubjectPrincipal,
                                      ErrorResult& aError) {
   PostMessageMoz(aCx, aMessage, aOptions.mTargetOrigin, aOptions.mTransfer,