OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <title>Tests that postMessage works during and after terminating a service worke r</title> | |
3 <script src="../../resources/testharness.js"></script> | |
4 <script src="../../resources/testharnessreport.js"></script> | |
5 <script src="../../resources/testharness-helpers.js"></script> | |
6 <script src="../resources/test-helpers.js"></script> | |
7 <script> | |
8 | |
dominicc (has gone to gerrit)
2014/11/20 05:48:08
Delete this and the trailing blank line.
Marijn Kruisselbrink
2014/11/20 19:28:22
Done.
| |
9 function sendPing(worker) { | |
10 return new Promise(function(resolve) { | |
11 var channel = new MessageChannel(); | |
12 channel.port1.onmessage = function(message) { | |
13 resolve(message.data); | |
14 }; | |
15 worker.postMessage({port: channel.port2}, [channel.port2]); | |
16 }); | |
17 } | |
18 | |
19 promise_test(function(test) { | |
20 var worker = 'resources/ping-worker.js'; | |
21 var scope = 'resources/blank.html'; | |
22 var sw; | |
23 return service_worker_unregister_and_register(test, worker, scope) | |
24 .then(function(registration) { | |
25 return wait_for_update(test, registration); | |
26 }) | |
27 .then(function(worker) { | |
28 sw = worker; | |
29 return sendPing(sw); | |
30 }) | |
31 .then(function(reply) { | |
32 assert_equals(reply, 1); | |
33 return internals.terminateServiceWorker(sw); | |
34 }) | |
35 .then(function() { | |
36 return sendPing(sw); | |
37 }) | |
38 .then(function(reply) { | |
39 assert_equals(reply, 1); | |
40 return sendPing(sw); | |
41 }) | |
42 .then(function(reply) { | |
43 assert_equals(reply, 2); | |
44 return service_worker_unregister_and_done(test, scope); | |
45 }); | |
46 }, 'Terminate terminates the worker.'); | |
47 | |
48 </script> | |
OLD | NEW |