Bug 1592699 - Fix test_serviceworker_lifetime.html r=asuth
authorPerry Jiang <perry@mozilla.com>
Wed, 30 Oct 2019 17:23:53 +0000
changeset 499813 cf03264ec46e2ba479d759efba640b0cf9c44a70
parent 499812 db661db8875b9bce6dc1cc5e2e42b4315bf467a0
child 499814 03efc87340f939973dc0edbb137883958faa8ac3
push id114163
push useraiakab@mozilla.com
push dateThu, 31 Oct 2019 10:03:38 +0000
treeherdermozilla-inbound@5fe1e03dbfbc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1592699
milestone72.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 1592699 - Fix test_serviceworker_lifetime.html r=asuth - Reset idle timeout when dispatching service worker operations even if the worker is alive. - Use MessageEvent instead of FetchEvent to avoid creating objects that leak when the test finishes. Differential Revision: https://phabricator.services.mozilla.com/D51016
dom/push/test/mochitest.ini
dom/push/test/test_serviceworker_lifetime.html
dom/serviceworkers/ServiceWorkerPrivateImpl.cpp
--- a/dom/push/test/mochitest.ini
+++ b/dom/push/test/mochitest.ini
@@ -21,12 +21,11 @@ skip-if = (os == "win") || (os == "linux
 [test_multiple_register_different_scope.html]
 [test_subscription_change.html]
 skip-if = os == "win" # Bug 1373346
 [test_data.html]
 skip-if = os == "win" # Bug 1373346
 [test_try_registering_offline_disabled.html]
 skip-if = os == "win" # Bug 1373346
 [test_serviceworker_lifetime.html]
-fail-if = fission
 skip-if = serviceworker_e10s || !e10s || os == "win" || os =="linux" && bits == 64 || os =="mac" # e10s: Bug 1433689, Windows: Bug 1373346, Bug 1578333, Bug 1578374 
 [test_error_reporting.html]
 skip-if = serviceworker_e10s
--- a/dom/push/test/test_serviceworker_lifetime.html
+++ b/dom/push/test/test_serviceworker_lifetime.html
@@ -322,21 +322,21 @@
       // set the grace period to 0 and dispatch a message which will reset
       // the internal sw timer to the new value.
       var test3_1 = {
         prefs: [
           ["dom.serviceWorkers.idle_timeout", 0],
           ["dom.serviceWorkers.idle_extended_timeout", 0],
         ],
         steps(context) {
-        return new Promise(function(res, rej) {
-          context.iframe.contentWindow.fetch("update");
-          res(context);
-        });
-      },
+          return new Promise(function(res, rej) {
+            context.iframe.contentWindow.navigator.serviceWorker.controller.postMessage("ping");
+            res(context);
+          });
+        },
       };
 
       // Test that service worker is closed when the extended timeout expired
       return createIframe(ctx)
         .then(setShutdownObserver(false))
         .then(checkStateAndUpdate(messageEvent, "from_scope", "update"))
         .then(checkStateAndUpdate(messageEventIframe, "update", "update"))
         .then(checkStateAndUpdate(fetchEvent, "update", "wait"))
--- a/dom/serviceworkers/ServiceWorkerPrivateImpl.cpp
+++ b/dom/serviceworkers/ServiceWorkerPrivateImpl.cpp
@@ -225,16 +225,17 @@ void ServiceWorkerPrivateImpl::RefreshRe
 }
 
 nsresult ServiceWorkerPrivateImpl::SpawnWorkerIfNeeded() {
   AssertIsOnMainThread();
   MOZ_ASSERT(mOuter);
   MOZ_ASSERT(mOuter->mInfo);
 
   if (mControllerChild) {
+    mOuter->RenewKeepAliveToken(ServiceWorkerPrivate::WakeUpReason::Unknown);
     return NS_OK;
   }
 
   PBackgroundChild* bgChild = BackgroundChild::GetForCurrentThread();
 
   if (NS_WARN_IF(!bgChild)) {
     return NS_ERROR_DOM_INVALID_STATE_ERR;
   }