OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="/resources/testharness.js"></script> | 2 <script src="/resources/testharness.js"></script> |
3 <script src="resources/testharness-helpers.js"></script> | |
4 <script src="/resources/testharnessreport.js"></script> | 3 <script src="/resources/testharnessreport.js"></script> |
5 <script src="resources/test-helpers.sub.js"></script> | 4 <script src="resources/test-helpers.sub.js"></script> |
6 <script> | 5 <script> |
7 promise_test(function(t) { | 6 promise_test(function(t) { |
8 var script = | 7 var script = |
9 'resources/fetch-event-respond-with-stops-propagation-worker.js'; | 8 'resources/fetch-event-respond-with-stops-propagation-worker.js'; |
10 var scope = 'resources/simple.html'; | 9 var scope = 'resources/simple.html'; |
11 | 10 |
12 return service_worker_unregister_and_register(t, script, scope) | 11 return service_worker_unregister_and_register(t, script, scope) |
13 .then(function(registration) { | 12 .then(function(registration) { |
14 return wait_for_state(t, registration.installing, 'activated'); | 13 return wait_for_state(t, registration.installing, 'activated'); |
15 }) | 14 }) |
16 .then(function() { | 15 .then(function() { |
17 return with_iframe(scope); | 16 return with_iframe(scope); |
18 }) | 17 }) |
19 .then(function(frame) { | 18 .then(function(frame) { |
| 19 t.add_cleanup(function() { frame.remove(); }); |
20 var channel = new MessageChannel(); | 20 var channel = new MessageChannel(); |
21 var saw_message = new Promise(function(resolve) { | 21 var saw_message = new Promise(function(resolve) { |
22 channel.port1.onmessage = function(e) { resolve(e.data); } | 22 channel.port1.onmessage = function(e) { resolve(e.data); } |
23 }); | 23 }); |
24 var worker = frame.contentWindow.navigator.serviceWorker.controller; | 24 var worker = frame.contentWindow.navigator.serviceWorker.controller; |
25 | 25 |
26 worker.postMessage({port: channel.port2}, [channel.port2]); | 26 worker.postMessage({port: channel.port2}, [channel.port2]); |
27 frame.remove(); | |
28 return saw_message; | 27 return saw_message; |
29 }) | 28 }) |
30 .then(function(message) { | 29 .then(function(message) { |
31 assert_equals(message, 'PASS'); | 30 assert_equals(message, 'PASS'); |
32 return service_worker_unregister_and_done(t, scope); | 31 return service_worker_unregister_and_done(t, scope); |
33 }) | 32 }) |
34 }, 'respondWith() invokes stopImmediatePropagation()'); | 33 }, 'respondWith() invokes stopImmediatePropagation()'); |
35 </script> | 34 </script> |
OLD | NEW |