Bug 1469882 Don't consult child process ServiceWorkerManager when populating MessageEvent.source with the e10s pref flipped. r=mrbkap
authorBen Kelly <ben@wanderview.com>
Sat, 23 Jun 2018 10:10:53 -0700
changeset 423446 c208fc0cd931b26fd918c5be4367402c17e93ff0
parent 423441 b00a4031dbe4d29acb5358e60f509a926caa4753
child 423447 3f78c17a1ceaaaa4b7e1fa04c3375f96e5acc9c8
push id34181
push userbtara@mozilla.com
push dateSun, 24 Jun 2018 09:37:59 +0000
treeherdermozilla-central@d69b7fc884fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1469882
milestone62.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 1469882 Don't consult child process ServiceWorkerManager when populating MessageEvent.source with the e10s pref flipped. r=mrbkap
dom/clients/manager/ClientSource.cpp
--- a/dom/clients/manager/ClientSource.cpp
+++ b/dom/clients/manager/ClientSource.cpp
@@ -606,31 +606,39 @@ ClientSource::PostMessage(const ClientPo
   }
 
   nsAutoCString origin;
   rv = principal->GetOriginNoSuffix(origin);
   if (NS_SUCCEEDED(rv)) {
     CopyUTF8toUTF16(origin, init.mOrigin);
   }
 
-  RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
-  if (!swm) {
-    // Shutting down. Just don't deliver this message.
-    ref = ClientOpPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
-    return ref.forget();
+  RefPtr<ServiceWorker> instance;
+
+  if (ServiceWorkerParentInterceptEnabled()) {
+    instance = globalObject->GetOrCreateServiceWorker(source);
+  } else {
+    // If we are in legacy child-side intercept mode then we need to verify
+    // this registration exists in the current process.
+    RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
+    if (!swm) {
+      // Shutting down. Just don't deliver this message.
+      ref = ClientOpPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
+      return ref.forget();
+    }
+
+    RefPtr<ServiceWorkerRegistrationInfo> reg =
+      swm->GetRegistration(principal, source.Scope());
+    if (reg) {
+      instance = globalObject->GetOrCreateServiceWorker(source);
+    }
   }
 
-  RefPtr<ServiceWorkerRegistrationInfo> reg =
-    swm->GetRegistration(principal, source.Scope());
-  if (reg) {
-    RefPtr<ServiceWorker> instance =
-      globalObject->GetOrCreateServiceWorker(source);
-    if (instance) {
-      init.mSource.SetValue().SetAsServiceWorker() = instance;
-    }
+  if (instance) {
+    init.mSource.SetValue().SetAsServiceWorker() = instance;
   }
 
   RefPtr<MessageEvent> event =
     MessageEvent::Constructor(target, NS_LITERAL_STRING("message"), init);
   event->SetTrusted(true);
 
   target->DispatchEvent(*event, result);
   if (result.Failed()) {