OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Service Worker: CSP control of fetch()</title> | 2 <title>Service Worker: CSP control 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 <script> | 6 <script> |
7 async_test(function(t) { | 7 async_test(function(t) { |
8 var SCOPE = 'resources/fetch-csp-iframe.html'; | 8 var SCOPE = 'resources/fetch-csp-iframe.html'; |
9 var SCRIPT = 'resources/fetch-rewrite-worker.js'; | 9 var SCRIPT = 'resources/fetch-rewrite-worker.js'; |
10 var host_info = get_host_info(); | 10 var host_info = get_host_info(); |
11 service_worker_unregister_and_register(t, SCRIPT, SCOPE) | 11 service_worker_unregister_and_register(t, SCRIPT, SCOPE) |
12 .then(function(registration) { | 12 .then(function(registration) { |
13 return wait_for_update(t, registration); | 13 return wait_for_state(t, registration.installing, 'activated'); |
14 }) | |
15 .then(function(sw) { | |
16 return wait_for_state(t, sw, 'activated'); | |
17 }) | 14 }) |
18 .then(function() { return with_iframe(SCOPE); }) | 15 .then(function() { return with_iframe(SCOPE); }) |
19 .then(function(frame) { | 16 .then(function(frame) { |
20 return new Promise(function(resolve, reject) { | 17 return new Promise(function(resolve, reject) { |
21 var channel = new MessageChannel(); | 18 var channel = new MessageChannel(); |
22 channel.port1.onmessage = t.step_func(function(e) { | 19 channel.port1.onmessage = t.step_func(function(e) { |
23 assert_equals(e.data.results, 'finish'); | 20 assert_equals(e.data.results, 'finish'); |
24 service_worker_unregister_and_done(t, SCOPE); | 21 service_worker_unregister_and_done(t, SCOPE); |
25 }); | 22 }); |
26 frame.contentWindow.postMessage({}, | 23 frame.contentWindow.postMessage({}, |
27 [channel.port2], | 24 [channel.port2], |
28 host_info['HTTP_ORIGIN']); | 25 host_info['HTTP_ORIGIN']); |
29 }); | 26 }); |
30 }) | 27 }) |
31 .catch(unreached_rejection(t)); | 28 .catch(unreached_rejection(t)); |
32 }, 'Verify CSP control of fetch() in a Service Worker'); | 29 }, 'Verify CSP control of fetch() in a Service Worker'); |
33 </script> | 30 </script> |
OLD | NEW |