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/unregister-then-register-new-script.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/unregister-then-register-new-script.https.html')
-rw-r--r-- | testing/web-platform/tests/service-workers/service-worker/unregister-then-register-new-script.https.html | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/testing/web-platform/tests/service-workers/service-worker/unregister-then-register-new-script.https.html b/testing/web-platform/tests/service-workers/service-worker/unregister-then-register-new-script.https.html new file mode 100644 index 000000000..385430c2d --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/unregister-then-register-new-script.https.html @@ -0,0 +1,159 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/test-helpers.sub.js"></script> +<script> +var worker_url = 'resources/empty-worker.js'; + +async_test(function(t) { + var scope = 'resources/scope/unregister-then-register-new-script-that-exists'; + var new_worker_url = worker_url + '?new'; + var iframe; + var registration; + var new_registration; + + service_worker_unregister_and_register(t, worker_url, scope) + .then(function(r) { + registration = r; + return wait_for_state(t, r.installing, 'activated'); + }) + .then(function() { + return with_iframe(scope); + }) + .then(function(frame) { + iframe = frame; + return registration.unregister(); + }) + .then(function() { + return navigator.serviceWorker.register(new_worker_url, + { scope: scope }); + }) + .then(function(r) { + new_registration = r; + assert_equals(registration.installing.scriptURL, + normalizeURL(new_worker_url), + 'before activated registration.installing'); + assert_equals(registration.waiting, null, + 'before activated registration.waiting'); + assert_equals(registration.active.scriptURL, normalizeURL(worker_url), + 'before activated registration.active'); + assert_equals(new_registration.installing.scriptURL, + normalizeURL(new_worker_url), + 'before activated new_registration.installing'); + assert_equals(new_registration.waiting, null, + 'before activated new_registration.waiting'); + assert_equals(new_registration.active.scriptURL, + normalizeURL(worker_url), + 'before activated new_registration.active'); + iframe.remove(); + return wait_for_state(t, registration.installing, 'activated'); + }) + .then(function() { + assert_equals(new_registration.installing, null, + 'after activated new_registration.installing'); + assert_equals(new_registration.waiting, null, + 'after activated new_registration.waiting'); + assert_equals(new_registration.active.scriptURL, + normalizeURL(new_worker_url), + 'after activated new_registration.active'); + return with_iframe(scope); + }) + .then(function(frame) { + assert_equals( + frame.contentWindow.navigator.serviceWorker.controller.scriptURL, + normalizeURL(new_worker_url), + 'the new worker should control a new document'); + frame.remove(); + return registration.unregister(); + }) + .then(function() { + t.done(); + }) + .catch(unreached_rejection(t)); +}, 'Registering a new script URL while an unregistered registration is in use'); + +async_test(function(t) { + var scope = 'resources/scope/unregister-then-register-new-script-that-404s'; + var iframe; + var registration; + + service_worker_unregister_and_register(t, worker_url, scope) + .then(function(r) { + registration = r; + return wait_for_state(t, r.installing, 'activated'); + }) + .then(function() { + return with_iframe(scope); + }) + .then(function(frame) { + iframe = frame; + return registration.unregister(); + }) + .then(function() { + var promise = navigator.serviceWorker.register('this-will-404', + { scope: scope }); + iframe.remove(); + return promise; + }) + .then( + function() { + assert_unreached('register should reject the promise'); + }, + function() { + return with_iframe(scope); + }) + .then(function(frame) { + assert_equals(frame.contentWindow.navigator.serviceWorker.controller, + null, + 'document should not load with a controller'); + frame.remove(); + t.done(); + }) + .catch(unreached_rejection(t)); +}, 'Registering a new script URL that 404s does not resurrect an ' + + 'unregistered registration'); + +async_test(function(t) { + var scope = 'resources/scope/unregister-then-register-reject-install-worker'; + var iframe; + var registration; + + service_worker_unregister_and_register(t, worker_url, scope) + .then(function(r) { + registration = r; + return wait_for_state(t, r.installing, 'activated'); + }) + .then(function() { + return with_iframe(scope); + }) + .then(function(frame) { + iframe = frame; + return registration.unregister(); + }) + .then(function() { + var promise = navigator.serviceWorker.register( + 'resources/reject-install-worker.js', { scope: scope }); + iframe.remove(); + return promise; + }) + .then(function(r) { + registration = r; + return wait_for_state(t, r.installing, 'redundant'); + }) + .then(function() { + return with_iframe(scope); + }) + .then(function(frame) { + assert_equals(frame.contentWindow.navigator.serviceWorker.controller, + null, + 'document should not load with a controller'); + frame.remove(); + return registration.unregister(); + }) + .then(function() { + t.done(); + }) + .catch(unreached_rejection(t)); + }, 'Registering a new script URL that fails to install does not resurrect ' + + 'an unregistered registration'); +</script> |