| Index: LayoutTests/http/tests/serviceworker/extendable-message-event.html
|
| diff --git a/LayoutTests/http/tests/serviceworker/extendable-message-event.html b/LayoutTests/http/tests/serviceworker/extendable-message-event.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..486becc4100a48895aab301cde9299f4350b8383
|
| --- /dev/null
|
| +++ b/LayoutTests/http/tests/serviceworker/extendable-message-event.html
|
| @@ -0,0 +1,117 @@
|
| +<!DOCTYPE html>
|
| +<title>Service Worker: ExtendableMessageEvent</title>
|
| +<script src="../resources/testharness.js"></script>
|
| +<script src="../resources/testharness-helpers.js"></script>
|
| +<script src="../resources/testharnessreport.js"></script>
|
| +<script src="resources/test-helpers.js"></script>
|
| +<script>
|
| +
|
| +promise_test(function(t) {
|
| + var scope = 'resources/extendable-message-event-client';
|
| + var url = 'resources/extendable-message-event-worker.js';
|
| + var worker;
|
| + return service_worker_unregister_and_register(t, url, scope)
|
| + .then(function(r) {
|
| + worker = r.installing;
|
| + var channel = new MessageChannel();
|
| + return new Promise(function(resolve) {
|
| + channel.port1.onmessage = t.step_func(function(e) {
|
| + assert_equals(e.data, 'PASS');
|
| + resolve();
|
| + });
|
| + worker.postMessage({port: channel.port2}, [channel.port2]);
|
| + worker.postMessage('TEST');
|
| + });
|
| + })
|
| + .then(function() {
|
| + return service_worker_unregister_and_done(t, scope);
|
| + })
|
| + }, 'Test ExtendableMessageEvent sending from client.');
|
| +
|
| +promise_test(function(t) {
|
| + var scope = 'resources/blank.html';
|
| + var sender = 'resources/extendable-message-event-sender-worker.js';
|
| + var receiver = 'resources/extendable-message-event-worker.js';
|
| + var frame, saw_message;
|
| + return service_worker_unregister_and_register(t, receiver, scope)
|
| + .then(function(r) {
|
| + var channel = new MessageChannel();
|
| + saw_message = new Promise(function(resolve) {
|
| + channel.port1.onmessage = t.step_func(function(e) {
|
| + assert_equals(e.data, 'PASS');
|
| + resolve();
|
| + });
|
| + r.installing.postMessage({port: channel.port2}, [channel.port2]);
|
| + });
|
| + return wait_for_state(t, r.installing, 'activated');
|
| + })
|
| + .then(function() {
|
| + return with_iframe(scope);
|
| + })
|
| + .then(function(f) {
|
| + frame = f;
|
| + navigator.serviceWorker.register(sender, {scope: scope});
|
| + return saw_message;
|
| + })
|
| + .then(function() {
|
| + frame.remove();
|
| + service_worker_unregister_and_done(t, scope);
|
| + });
|
| + }, 'Test ExtendableMessageEvent sending from service worker.');
|
| +
|
| +promise_test(function(t) {
|
| + var scope = 'resources/extendable-message-event-waituntil';
|
| + var url = 'resources/extendable-message-event-worker-waituntil.js';
|
| + var worker, channel;
|
| + return service_worker_unregister_and_register(t, url, scope)
|
| + .then(function(r) {
|
| + worker = r.installing;
|
| + channel = new MessageChannel();
|
| + return new Promise(function(resolve) {
|
| + channel.port1.onmessage = t.step_func(function(e) {
|
| + assert_equals(e.data, 'ACK',
|
| + 'WAIT message should be acked first');
|
| + resolve();
|
| + });
|
| + worker.postMessage({port: channel.port2}, [channel.port2]);
|
| + worker.postMessage('WAIT');
|
| + });
|
| + })
|
| + .then(function() {
|
| + return new Promise(function(resolve) {
|
| + channel.port1.onmessage = t.step_func(function(e) {
|
| + assert_equals(e.data, 'PASS',
|
| + 'Previous waitUntil should be resolved');
|
| + resolve();
|
| + });
|
| + worker.postMessage('DONE');
|
| + });
|
| + })
|
| + .then(function() {
|
| + return service_worker_unregister_and_done(t, scope);
|
| + });
|
| + }, 'Test calling waitUntil synchronously.');
|
| +
|
| +promise_test(function(t) {
|
| + var scope = 'resources/extendable-message-event-waituntil-async';
|
| + var url = 'resources/extendable-message-event-worker-waituntil.js';
|
| + var worker, channel;
|
| + return service_worker_unregister_and_register(t, url, scope)
|
| + .then(function(r) {
|
| + worker = r.installing;
|
| + channel = new MessageChannel();
|
| + return new Promise(function(resolve) {
|
| + channel.port1.onmessage = t.step_func(function(e) {
|
| + assert_equals(e.data, 'PASS');
|
| + resolve();
|
| + });
|
| + worker.postMessage({port: channel.port2}, [channel.port2]);
|
| + worker.postMessage('WAIT_ASYNC');
|
| + });
|
| + })
|
| + .then(function() {
|
| + return service_worker_unregister_and_done(t, scope);
|
| + });
|
| + }, 'Test calling waitUntil asynchronously.');
|
| +
|
| +</script>
|
|
|