Bug 1410634 - Part 2: Verify ServiceWorkerInfo.lastUpdateTime is not changed when reading from http cache. r=tt, a=ritu
authorBen Kelly <ben@wanderview.com>
Tue, 24 Oct 2017 09:24:53 -0400
changeset 435158 f9071831e7d83987b96a29630cd06761898c56b3
parent 435157 f16311e84f0d54ef8d2597ebefb2b9fe9b6c3a0a
child 435159 a15dd610601a0a15c3f011baf2e49a5371f381d2
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstt, ritu
bugs1410634
milestone57.0
Bug 1410634 - Part 2: Verify ServiceWorkerInfo.lastUpdateTime is not changed when reading from http cache. r=tt, a=ritu
dom/workers/test/serviceworkers/serviceworkerinfo_iframe.html
dom/workers/test/serviceworkers/test_devtools_track_serviceworker_time.html
--- a/dom/workers/test/serviceworkers/serviceworkerinfo_iframe.html
+++ b/dom/workers/test/serviceworkers/serviceworkerinfo_iframe.html
@@ -2,17 +2,18 @@
 <html lang="en">
   <head>
     <meta charset="utf-8">
     <script>
       window.onmessage = function (event) {
         if (event.data !== "register") {
           return;
         }
-        var promise = navigator.serviceWorker.register("worker.js");
+        var promise = navigator.serviceWorker.register("worker.js",
+                                                       { updateViaCache: 'all' });
         window.onmessage = function (event) {
           if (event.data !== "unregister") {
             return;
           }
           promise.then(function (registration) {
             registration.unregister();
           });
           window.onmessage = null;
--- a/dom/workers/test/serviceworkers/test_devtools_track_serviceworker_time.html
+++ b/dom/workers/test/serviceworkers/test_devtools_track_serviceworker_time.html
@@ -48,16 +48,18 @@ let expectedResults = [
   {
     state: State.ACTIVATING, installedTimeRecorded: true,
     activatedTimeRecorded: false, redundantTimeRecorded: false
   },
   {
     state: State.ACTIVATED, installedTimeRecorded: true,
     activatedTimeRecorded: true, redundantTimeRecorded: false
   },
+
+  // On unregister
   {
     state: State.REDUNDANT, installedTimeRecorded: true,
     activatedTimeRecorded: true, redundantTimeRecorded: true
   }
 ];
 
 function waitForRegister(aScope, aCallback) {
   return new Promise(function (aResolve) {
@@ -165,16 +167,25 @@ function testServiceWorkerInfo() {
     }
   };
 
   registrationInfo.addListener(swrlistener);
 
   return promise;
 }
 
+async function testHttpCacheUpdateTime() {
+  let iframe = document.querySelector("iframe");
+  let reg = await iframe.contentWindow.navigator.serviceWorker.getRegistration();
+  let lastUpdateTime = registrationInfo.lastUpdateTime;
+  await reg.update();
+  is(lastUpdateTime, registrationInfo.lastUpdateTime,
+     "The update time should not change when SW script is read from http cache.");
+}
+
 function unregister() {
   info("Unregister the ServiceWorker");
 
   let iframe = document.querySelector("iframe");
   iframe.contentWindow.postMessage("unregister", "*");
   return waitForUnregister(EXAMPLE_URL);
 }
 
@@ -191,16 +202,17 @@ function cleanAll() {
     aResolve();
   })
 }
 
 function runTest() {
   return Promise.resolve()
     .then(register)
     .then(testServiceWorkerInfo)
+    .then(testHttpCacheUpdateTime)
     .then(unregister)
     .catch(aError => ok(false, "Some test failed with error " + aError))
     .then(cleanAll)
     .then(SimpleTest.finish);
 }
 
 SimpleTest.waitForExplicitFinish();
 SpecialPowers.pushPrefEnv({"set": [