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