| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Service Worker: CORS XHR of fetch()</title> | 2 <title>Service Worker: CORS XHR of fetch()</title> |
| 3 <script src="../resources/testharness.js"></script> | 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> | 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="resources/test-helpers.js?pipe=sub"></script> | 5 <script src="resources/test-helpers.js?pipe=sub"></script> |
| 6 <body> | 6 <body> |
| 7 <script> | 7 <script> |
| 8 async_test(function(t) { | 8 async_test(function(t) { |
| 9 var login1 = | 9 var login1 = |
| 10 test_login(t, 'http://127.0.0.1:8000', | 10 test_login(t, 'http://127.0.0.1:8000', |
| 11 'username1', 'password1', 'cookie1'); | 11 'username1', 'password1', 'cookie1'); |
| 12 var login2 = | 12 var login2 = |
| 13 test_login(t, 'http://localhost:8000', | 13 test_login(t, 'http://localhost:8000', |
| 14 'username2', 'password2', 'cookie2'); | 14 'username2', 'password2', 'cookie2'); |
| 15 var SCOPE = 'resources/fetch-cors-xhr-iframe.html'; | 15 var SCOPE = 'resources/fetch-cors-xhr-iframe.html'; |
| 16 var SCRIPT = 'resources/fetch-rewrite-worker.js'; | 16 var SCRIPT = 'resources/fetch-rewrite-worker.js'; |
| 17 var host_info = get_host_info(); | 17 var host_info = get_host_info(); |
| 18 | 18 |
| 19 Promise.all([login1, login2]) | 19 Promise.all([login1, login2]) |
| 20 .then(function() { | 20 .then(function() { |
| 21 return service_worker_unregister_and_register(t, SCRIPT, SCOPE); | 21 return service_worker_unregister_and_register(t, SCRIPT, SCOPE); |
| 22 }) | 22 }) |
| 23 .then(function(registration) { | 23 .then(function(registration) { |
| 24 return wait_for_update(t, registration); | 24 return wait_for_state(t, registration.installing, 'activated'); |
| 25 }) | |
| 26 .then(function(sw) { | |
| 27 return wait_for_state(t, sw, 'activated'); | |
| 28 }) | 25 }) |
| 29 .then(function() { return with_iframe(SCOPE); }) | 26 .then(function() { return with_iframe(SCOPE); }) |
| 30 .then(function(frame) { | 27 .then(function(frame) { |
| 31 return new Promise(function(resolve, reject) { | 28 return new Promise(function(resolve, reject) { |
| 32 var channel = new MessageChannel(); | 29 var channel = new MessageChannel(); |
| 33 channel.port1.onmessage = t.step_func(function(e) { | 30 channel.port1.onmessage = t.step_func(function(e) { |
| 34 assert_equals(e.data.results, 'finish'); | 31 assert_equals(e.data.results, 'finish'); |
| 35 unload_iframe(frame); | 32 unload_iframe(frame); |
| 36 service_worker_unregister_and_done(t, SCOPE); | 33 service_worker_unregister_and_done(t, SCOPE); |
| 37 }); | 34 }); |
| 38 frame.contentWindow.postMessage({}, | 35 frame.contentWindow.postMessage({}, |
| 39 [channel.port2], | 36 [channel.port2], |
| 40 host_info['HTTP_ORIGIN']); | 37 host_info['HTTP_ORIGIN']); |
| 41 }); | 38 }); |
| 42 }) | 39 }) |
| 43 .catch(unreached_rejection(t)); | 40 .catch(unreached_rejection(t)); |
| 44 }, 'Verify CORS XHR of fetch() in a Service Worker'); | 41 }, 'Verify CORS XHR of fetch() in a Service Worker'); |
| 45 </script> | 42 </script> |
| 46 </body> | 43 </body> |
| OLD | NEW |