| 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..f3aea71aae68b27d3096fb92b26b170c4eeef95f
|
| --- /dev/null
|
| +++ b/LayoutTests/http/tests/serviceworker/chromium/postmessage-after-terminate.html
|
| @@ -0,0 +1,46 @@
|
| +<!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>
|
| +function send_ping(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 send_ping(sw);
|
| + })
|
| + .then(function(reply) {
|
| + assert_equals(reply, 0);
|
| + return internals.terminateServiceWorker(sw);
|
| + })
|
| + .then(function() {
|
| + return send_ping(sw);
|
| + })
|
| + .then(function(reply) {
|
| + assert_equals(reply, 0);
|
| + return send_ping(sw);
|
| + })
|
| + .then(function(reply) {
|
| + assert_equals(reply, 1);
|
| + return service_worker_unregister_and_done(test, scope);
|
| + });
|
| + }, 'postMessage to a terminated service worker.');
|
| +</script>
|
|
|