Bug 1524619 - Part 5 - Propagate user interaction through APIs that return ServiceWorkerRegistrations. r=Ehsan a=pascalc
authorJohann Hofmann <jhofmann@mozilla.com>
Tue, 19 Mar 2019 00:13:36 +0100
changeset 526322 70f93db9a0817fc666e5551ef0085bad133725f6
parent 526321 fa0ac55df425d5393b8e30ce34cb21bb7da3ff85
child 526323 81b2e6c7139d2ace9b70332269e02f8633317c98
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan, pascalc
bugs1524619
milestone67.0
Bug 1524619 - Part 5 - Propagate user interaction through APIs that return ServiceWorkerRegistrations. r=Ehsan a=pascalc This is done to support requiring user interaction when calling PushManager.subscribe(). Because PushManager must usually be accessed with async APIs, this makes for a better developer experience and should reduce breakage. Differential Revision: https://phabricator.services.mozilla.com/D23970
dom/serviceworkers/ServiceWorkerContainer.cpp
--- a/dom/serviceworkers/ServiceWorkerContainer.cpp
+++ b/dom/serviceworkers/ServiceWorkerContainer.cpp
@@ -363,17 +363,18 @@ already_AddRefed<Promise> ServiceWorkerC
     nsContentUtils::ReportToConsole(
         nsIScriptError::errorFlag, NS_LITERAL_CSTRING("Service Workers"), aDoc,
         nsContentUtils::eDOM_PROPERTIES, "ServiceWorkerRegisterStorageError",
         param, 1);
   });
 
   window->NoteCalledRegisterForServiceWorkerScope(cleanedScopeURL);
 
-  RefPtr<Promise> outer = Promise::Create(global, aRv);
+  RefPtr<Promise> outer =
+      Promise::Create(global, aRv, Promise::ePropagateUserInteraction);
   if (aRv.Failed()) {
     return nullptr;
   }
 
   RefPtr<ServiceWorkerContainer> self = this;
 
   mInner->Register(
       clientInfo.ref(), cleanedScopeURL, cleanedScriptURL,
@@ -412,17 +413,18 @@ already_AddRefed<Promise> ServiceWorkerC
   }
 
   Maybe<ClientInfo> clientInfo = global->GetClientInfo();
   if (clientInfo.isNothing()) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
 
-  RefPtr<Promise> outer = Promise::Create(global, aRv);
+  RefPtr<Promise> outer =
+      Promise::Create(global, aRv, Promise::ePropagateUserInteraction);
   if (aRv.Failed()) {
     return nullptr;
   }
 
   RefPtr<ServiceWorkerContainer> self = this;
 
   mInner->GetRegistrations(
       clientInfo.ref(),
@@ -487,17 +489,18 @@ already_AddRefed<Promise> ServiceWorkerC
   }
 
   nsCString spec;
   aRv = uri->GetSpec(spec);
   if (aRv.Failed()) {
     return nullptr;
   }
 
-  RefPtr<Promise> outer = Promise::Create(global, aRv);
+  RefPtr<Promise> outer =
+      Promise::Create(global, aRv, Promise::ePropagateUserInteraction);
   if (aRv.Failed()) {
     return nullptr;
   }
 
   RefPtr<ServiceWorkerContainer> self = this;
 
   mInner->GetRegistration(
       clientInfo.ref(), spec,
@@ -538,17 +541,18 @@ Promise* ServiceWorkerContainer::GetRead
   MOZ_DIAGNOSTIC_ASSERT(global);
 
   Maybe<ClientInfo> clientInfo(global->GetClientInfo());
   if (clientInfo.isNothing()) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
 
-  mReadyPromise = Promise::Create(global, aRv);
+  mReadyPromise =
+      Promise::Create(global, aRv, Promise::ePropagateUserInteraction);
   if (aRv.Failed()) {
     return nullptr;
   }
 
   RefPtr<ServiceWorkerContainer> self = this;
   RefPtr<Promise> outer = mReadyPromise;
 
   mInner->GetReady(