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> | 3 <script src="../resources/testharness-helpers.js"></script> |
4 <script src="../resources/testharnessreport.js"></script> | 4 <script src="../resources/testharnessreport.js"></script> |
5 <script src="resources/test-helpers.js"></script> | 5 <script src="resources/test-helpers.js"></script> |
6 <script> | 6 <script> |
7 promise_test(function(t) { | 7 promise_test(function(t) { |
8 var script = 'resources/extendable-event-async-waituntil.js'; | 8 var script = 'resources/extendable-event-async-waituntil.js'; |
9 var scope = 'resources/async-waituntil'; | 9 var scope = 'resources/async-waituntil'; |
10 var worker; | 10 var worker; |
11 | 11 |
12 return service_worker_unregister_and_register(t, script, scope) | 12 return service_worker_unregister_and_register(t, script, scope) |
13 .then(function(registration) { | 13 .then(function(registration) { |
14 return wait_for_update(t, registration); | 14 worker = registration.installing; |
15 }) | 15 return wait_for_state(t, worker, 'activated'); |
16 .then(function(sw) { | |
17 worker = sw; | |
18 return wait_for_state(t, sw, 'activated'); | |
19 }) | 16 }) |
20 .then(function() { | 17 .then(function() { |
21 var channel = new MessageChannel(); | 18 var channel = new MessageChannel(); |
22 var saw_message = new Promise(function(resolve) { | 19 var saw_message = new Promise(function(resolve) { |
23 channel.port1.onmessage = function(e) { resolve(e.data); } | 20 channel.port1.onmessage = function(e) { resolve(e.data); } |
24 }); | 21 }); |
25 worker.postMessage({port: channel.port2}, [channel.port2]); | 22 worker.postMessage({port: channel.port2}, [channel.port2]); |
26 return saw_message; | 23 return saw_message; |
27 }) | 24 }) |
28 .then(function(message) { | 25 .then(function(message) { |
29 assert_equals(message, 'PASS'); | 26 assert_equals(message, 'PASS'); |
30 return service_worker_unregister_and_done(t, scope); | 27 return service_worker_unregister_and_done(t, scope); |
31 }) | 28 }) |
32 }, 'Calling waitUntil asynchronously throws an exception'); | 29 }, 'Calling waitUntil asynchronously throws an exception'); |
33 </script> | 30 </script> |
OLD | NEW |