Chromium Code Reviews| Index: LayoutTests/http/tests/serviceworker/chromium/postmessage-after-terminate.html |
| diff --git a/LayoutTests/http/tests/serviceworker/chromium/postmessage-after-terminate.html b/LayoutTests/http/tests/serviceworker/chromium/postmessage-after-terminate.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cda38abf2531b4587d4404ffad8901a140fa4a06 |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/serviceworker/chromium/postmessage-after-terminate.html |
| @@ -0,0 +1,48 @@ |
| +<!DOCTYPE html> |
| +<title>Tests that postMessage works during and after terminating a service worker</title> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script src="../../resources/testharness-helpers.js"></script> |
| +<script src="../resources/test-helpers.js"></script> |
| +<script> |
| + |
|
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.
|
| +function sendPing(worker) { |
| + return new Promise(function(resolve) { |
| + var channel = new MessageChannel(); |
| + channel.port1.onmessage = function(message) { |
| + resolve(message.data); |
| + }; |
| + worker.postMessage({port: channel.port2}, [channel.port2]); |
| + }); |
| +} |
| + |
| +promise_test(function(test) { |
| + var worker = 'resources/ping-worker.js'; |
| + var scope = 'resources/blank.html'; |
| + var sw; |
| + return service_worker_unregister_and_register(test, worker, scope) |
| + .then(function(registration) { |
| + return wait_for_update(test, registration); |
| + }) |
| + .then(function(worker) { |
| + sw = worker; |
| + return sendPing(sw); |
| + }) |
| + .then(function(reply) { |
| + assert_equals(reply, 1); |
| + return internals.terminateServiceWorker(sw); |
| + }) |
| + .then(function() { |
| + return sendPing(sw); |
| + }) |
| + .then(function(reply) { |
| + assert_equals(reply, 1); |
| + return sendPing(sw); |
| + }) |
| + .then(function(reply) { |
| + assert_equals(reply, 2); |
| + return service_worker_unregister_and_done(test, scope); |
| + }); |
| + }, 'Terminate terminates the worker.'); |
| + |
| +</script> |