Bug 1507089 [wpt PR 14050] - Fix wpt: service-worker/navigation-redirect.https.html, a=testonly
authorMakoto Shimazu <shimazu@chromium.org>
Mon, 19 Nov 2018 18:44:49 +0000
changeset 503967 90562b1f464b15f2aaaf05326d6dd428a9f84d8b
parent 503966 30af87b9c6b78863ead8e828cb182925174ff3e9
child 503968 821fa7cd9dd5107388e09abe39e79fc1ba6cad0a
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1507089, 14050, 778497, 1335055, 608167
milestone65.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 1507089 [wpt PR 14050] - Fix wpt: service-worker/navigation-redirect.https.html, a=testonly Automatic update from web-platform-testsFix wpt: service-worker/navigation-redirect.https.html As preparation for adding FetchEvent#resultingClientId, this CL fixes the test to make it pass once resultingClientId is impelmeneted. Bug: 778497 Change-Id: I6309a13d4315e6a99149275a6d7889f14ce0d757 Reviewed-on: https://chromium-review.googlesource.com/c/1335055 Reviewed-by: Matt Falkenhagen <falken@chromium.org> Commit-Queue: Makoto Shimazu <shimazu@chromium.org> Cr-Commit-Position: refs/heads/master@{#608167} -- wpt-commits: 6856483bcc86322198f10e0c42385a7f9127eb66 wpt-pr: 14050
testing/web-platform/tests/service-workers/service-worker/navigation-redirect.https.html
testing/web-platform/tests/service-workers/service-worker/resources/redirect-worker.js
--- a/testing/web-platform/tests/service-workers/service-worker/navigation-redirect.https.html
+++ b/testing/web-platform/tests/service-workers/service-worker/navigation-redirect.https.html
@@ -92,17 +92,17 @@ function check_clients(clients,
                        expected_id,
                        expected_url,
                        expected_final_client_tag,
                        worker_name) {
   let found = false;
   Object.keys(clients).forEach(key => {
     const info = clients[key];
     if (info.found) {
-      assert_true(expected_final_client_tag,
+      assert_true(!!expected_final_client_tag,
                   `${worker_name} client tag exists`);
       assert_equals(key, expected_final_client_tag,
                     `${worker_name} client tag matches`);
       assert_equals(info.id, expected_id, `${worker_name} client id`);
       assert_equals(info.url, expected_url, `${worker_name} client url`);
       found = true;
     }
   });
@@ -115,20 +115,20 @@ function check_resulting_client_ids(info
   for (var i = 0; i < infos.length; i++) {
     const tag = expected_infos[i].resultingClientIdTag;
     const url = expected_infos[i].url;
     const actual_id = infos[i].resultingClientId;
     const expected_id = actual_ids[tag];
     assert_equals(typeof(actual_id), 'string',
                   `resultingClientId for ${url} request to ${worker}`);
     if (expected_id) {
-      assert_equals(requestInfos[0], expected_id,
+      assert_equals(actual_id, expected_id,
                     `resultingClientId for ${url} request to ${worker}`);
     } else {
-      actual_ids[key] = actual_id;
+      actual_ids[tag] = actual_id;
     }
   }
 }
 
 // Creates an iframe and navigates to |url|, which is expected to start a chain
 // of redirects.
 // - |expected_last_url| is the expected window.location after the
 //   navigation.
@@ -484,17 +484,17 @@ redirect_test(
     'SW-fallbacked redirect to same-origin other-scope.');
 
 url1 = SCOPE1 + 'url=' + encodeURIComponent(OTHER_ORIGIN_OUT_SCOPE);
 url2 = OTHER_ORIGIN_OUT_SCOPE;
 redirect_test(
     url1,
     url2,
     [[{url: url1, resultingClientIdTag: 'a'}], [], []],
-    'x',
+    null,
     'SW-fallbacked redirect to other-origin out-scope.');
 
 url1 = SCOPE1 + 'url=' + encodeURIComponent(OTHER_ORIGIN_SCOPE);
 url2 = OTHER_ORIGIN_SCOPE;
 redirect_test(
     url1,
     url2,
     [
@@ -525,18 +525,18 @@ redirect_test(
 
 // SW generated redirect.
 // SW: event.respondWith(Response.redirect(params['url']));
 url1 = SCOPE1 + 'sw=gen&url=' + encodeURIComponent(OUT_SCOPE);
 url2 = OUT_SCOPE;
 redirect_test(
     url1,
     url2,
-    [[{url: url1, resultingClientIdTag: 'a'}], [], []],
-    null,
+    [[{url: url1, resultingClientIdTag: 'x'}], [], []],
+    'x',
     'SW-generated redirect to same-origin out-scope.');
 
 url1 = SCOPE1 + 'sw=gen&url=' + encodeURIComponent(OUT_SCOPE) + '#ref';
 url2 = OUT_SCOPE + '#ref';
 redirect_test(
     url1,
     url2,
     [[{url: url1, resultingClientIdTag: 'x'}], [], []],
--- a/testing/web-platform/tests/service-workers/service-worker/resources/redirect-worker.js
+++ b/testing/web-platform/tests/service-workers/service-worker/resources/redirect-worker.js
@@ -109,35 +109,30 @@ self.addEventListener('fetch', function(
       // To avoid races, add the waitUntil() promise to our global list.
       // If we get a message event before we finish here, it will wait
       // these promises to complete before proceeding to read from the
       // cache.
       waitUntilPromiseList.push(waitUntilPromise);
       return;
     }
 
-    event.respondWith(waitUntilPromise.then(function() {
+    event.respondWith(waitUntilPromise.then(async () => {
       if (params['sw'] == 'gen') {
         return Response.redirect(params['url']);
       } else if (params['sw'] == 'fetch') {
         return fetch(event.request);
       } else if (params['sw'] == 'fetch-url') {
         return fetch(params['url']);
       } else if (params['sw'] == 'follow') {
         return fetch(new Request(event.request.url, {redirect: 'follow'}));
       } else if (params['sw'] == 'manual') {
         return fetch(new Request(event.request.url, {redirect: 'manual'}));
       } else if (params['sw'] == 'manualThroughCache') {
-        var url = event.request.url;
-        var cache;
-        return caches.delete(url)
-          .then(function() { return self.caches.open(url); })
-          .then(function(c) {
-            cache = c;
-            return fetch(new Request(url, {redirect: 'manual'}));
-          })
-          .then(function(res) { return cache.put(event.request, res); })
-          .then(function() { return cache.match(url); });
+        const url = event.request.url;
+        await caches.delete(url)
+        const cache = await self.caches.open(url);
+        const response = await fetch(new Request(url, {redirect: 'manual'}));
+        await cache.put(event.request, response);
+        return cache.match(url);
       }
-
       // unexpected... trigger an interception failure
     }));
   });