diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/service-workers/service-worker/extendable-event-waituntil.https.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/service-workers/service-worker/extendable-event-waituntil.https.html')
-rw-r--r-- | testing/web-platform/tests/service-workers/service-worker/extendable-event-waituntil.https.html | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/testing/web-platform/tests/service-workers/service-worker/extendable-event-waituntil.https.html b/testing/web-platform/tests/service-workers/service-worker/extendable-event-waituntil.https.html new file mode 100644 index 000000000..003e703b1 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/extendable-event-waituntil.https.html @@ -0,0 +1,125 @@ +<!DOCTYPE html> +<title>ExtendableEvent: waitUntil</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/test-helpers.sub.js"></script> +<script> +function runTest(test, scope, onRegister) { + var script = 'resources/extendable-event-waituntil.js?' + scope; + service_worker_unregister_and_register(test, script, scope) + .then(function(registration) { + onRegister(registration.installing); + }); +} + +// Sends a SYN to the worker and asynchronously listens for an ACK; sets +// |obj.synced| to true once ack'd. +function syncWorker(test, worker, obj) { + var channel = new MessageChannel(); + channel.port1.onmessage = test.step_func(function(e) { + var message = e.data; + assert_equals(message, 'SYNC', + 'Should receive sync message from worker.'); + obj.synced = true; + channel.port1.postMessage('ACK'); + }); + worker.postMessage({port: channel.port2}, [channel.port2]); +} + +async_test(function(t) { + // Passing scope as the test switch for worker script. + var scope = 'resources/install-fulfilled'; + var onRegister = function(worker) { + var obj = {}; + wait_for_state(t, worker, 'installed') + .then(function() { + assert_true( + obj.synced, + 'state should be "installed" after the waitUntil promise ' + + 'for "oninstall" is fulfilled.'); + service_worker_unregister_and_done(t, scope); + }) + .catch(unreached_rejection(t)); + syncWorker(t, worker, obj); + }; + runTest(t, scope, onRegister); + }, 'Test install event waitUntil fulfilled'); + +async_test(function(t) { + var scope = 'resources/install-multiple-fulfilled'; + var onRegister = function(worker) { + var obj1 = {}; + var obj2 = {}; + wait_for_state(t, worker, 'installed') + .then(function() { + assert_true( + obj1.synced && obj2.synced, + 'state should be "installed" after all waitUntil promises ' + + 'for "oninstall" are fulfilled.'); + service_worker_unregister_and_done(t, scope); + }) + .catch(unreached_rejection(t)); + syncWorker(t, worker, obj1); + syncWorker(t, worker, obj2); + }; + runTest(t, scope, onRegister); + }, 'Test ExtendableEvent multiple waitUntil fulfilled.'); + +async_test(function(t) { + var scope = 'resources/install-reject-precedence'; + var onRegister = function(worker) { + wait_for_state(t, worker, 'redundant') + .then(function() { + service_worker_unregister_and_done(t, scope); + }) + .catch(unreached_rejection(t)); + }; + runTest(t, scope, onRegister); + }, 'Test ExtendableEvent waitUntil reject precedence.'); + +async_test(function(t) { + var scope = 'resources/activate-fulfilled'; + var onRegister = function(worker) { + var obj = {}; + wait_for_state(t, worker, 'activating') + .then(function() { + syncWorker(t, worker, obj); + return wait_for_state(t, worker, 'activated'); + }) + .then(function() { + assert_true( + obj.synced, + 'state should be "activated" after the waitUntil promise ' + + 'for "onactivate" is fulfilled.'); + service_worker_unregister_and_done(t, scope); + }) + .catch(unreached_rejection(t)); + }; + runTest(t, scope, onRegister); + }, 'Test activate event waitUntil fulfilled'); + +async_test(function(t) { + var scope = 'resources/install-rejected'; + var onRegister = function(worker) { + wait_for_state(t, worker, 'redundant') + .then(function() { + service_worker_unregister_and_done(t, scope); + }) + .catch(unreached_rejection(t)); + }; + runTest(t, scope, onRegister); + }, 'Test install event waitUntil rejected'); + +async_test(function(t) { + var scope = 'resources/activate-rejected'; + var onRegister = function(worker) { + wait_for_state(t, worker, 'activated') + .then(function() { + service_worker_unregister_and_done(t, scope); + }) + .catch(unreached_rejection(t)); + }; + runTest(t, scope, onRegister); + }, 'Test activate event waitUntil rejected.'); + +</script> |