Bug 1427978 - P1: Update the wpt tests to expect to reject the cors synthesized response to a same origin request. r=bkelly
authorTom Tung <shes050117@gmail.com>
Mon, 08 Jan 2018 11:27:23 +0800
changeset 398285 e3edde0c2242804300ebd96b0a0f648ace682688
parent 398284 62603fdd915b7e4d47b23278ac951ca534b0b76d
child 398286 71e0525bd738a350582079354a5f7f96d0b5e555
push id98712
push userttung@mozilla.com
push dateTue, 09 Jan 2018 01:35:28 +0000
treeherdermozilla-inbound@71e0525bd738 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1427978
milestone59.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 1427978 - P1: Update the wpt tests to expect to reject the cors synthesized response to a same origin request. r=bkelly
testing/web-platform/tests/service-workers/service-worker/fetch-response-taint.https.html
testing/web-platform/tests/service-workers/service-worker/worker-interception.https.html
--- a/testing/web-platform/tests/service-workers/service-worker/fetch-response-taint.https.html
+++ b/testing/web-platform/tests/service-workers/service-worker/fetch-response-taint.https.html
@@ -188,30 +188,36 @@ for_each_origin_mode_credentials(functio
 
 for_each_origin_mode_credentials(function(origin, mode, credentials) {
   var url = build_rewrite_url(
       origin, OTHER_BASE_URL + 'ACAOrigin=*', 'cors', 'omit');
 
   // Fetch to the other origin with same-origin mode should fail.
   if (origin == OTHER_ORIGIN && mode == 'same-origin') {
     ng_test(url, mode, credentials);
+  } else if (origin == BASE_ORIGIN && mode == 'same-origin') {
+    // Cors type response to a same-origin mode request should fail
+    ng_test(url, mode, credentials);
   } else {
     // The response from the SW should be cors.
     ok_test(url, mode, credentials, 'cors', 'undefined');
   }
 });
 
 for_each_origin_mode_credentials(function(origin, mode, credentials) {
   var url = build_rewrite_url(
       origin,
       OTHER_BASE_URL + 'ACAOrigin=' + BASE_ORIGIN +
       '&ACACredentials=true',
       'cors', 'include');
   // Fetch to the other origin with same-origin mode should fail.
   if (origin == OTHER_ORIGIN && mode == 'same-origin') {
     ng_test(url, mode, credentials);
+  } else if (origin == BASE_ORIGIN && mode == 'same-origin') {
+    // Cors type response to a same-origin mode request should fail
+    ng_test(url, mode, credentials);
   } else {
     // The response from the SW should be cors.
     ok_test(url, mode, credentials, 'cors', 'username1s');
   }
 });
 </script>
 </body>
--- a/testing/web-platform/tests/service-workers/service-worker/worker-interception.https.html
+++ b/testing/web-platform/tests/service-workers/service-worker/worker-interception.https.html
@@ -76,20 +76,26 @@ promise_test(function(t) {
               }
 
               w.onerror = function(e) {
                 reject(e.message);
               }
             });
         })
       .then(function(data) {
-          assert_equals(data, 'dummy-worker-script loaded');
+          assert_unreached('intercepted cors response to a same-origin mode ' +
+                           'worker load should fail');
           service_worker_unregister_and_done(t, scope);
-        });
-  }, 'Verify worker script intercepted by cors response succeeds');
+        })
+      .catch(function(e) {
+          assert_true(true, 'intercepted cors response to a same-origin mode ' +
+                            'worker load should fail');
+          service_worker_unregister_and_done(t, scope);
+       });
+  }, 'Verify worker script intercepted by cors response fails');
 
 promise_test(function(t) {
     var worker_url = 'resources/dummy-no-cors-worker.js';
     var service_worker = 'resources/dummy-worker-interceptor.js';
     var scope = worker_url;
 
     return service_worker_unregister_and_register(t, service_worker, scope)
       .then(function(r) {