| Index: LayoutTests/http/tests/serviceworker/unregister-then-register-new-script.html
|
| diff --git a/LayoutTests/http/tests/serviceworker/unregister-then-register-new-script.html b/LayoutTests/http/tests/serviceworker/unregister-then-register-new-script.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..baf22ff77fe961dc5f99caaacf9961bafd55719f
|
| --- /dev/null
|
| +++ b/LayoutTests/http/tests/serviceworker/unregister-then-register-new-script.html
|
| @@ -0,0 +1,144 @@
|
| +<!DOCTYPE html>
|
| +<script src="../resources/testharness.js"></script>
|
| +<script src="../resources/testharnessreport.js"></script>
|
| +<script src="resources/test-helpers.js"></script>
|
| +<script>
|
| +var worker_url = 'resources/empty-worker.js';
|
| +
|
| +async_test(function(t) {
|
| + var scope = 'scope/new-worker';
|
| + var new_worker_url = worker_url + '?new';
|
| + var iframe;
|
| + var registration;
|
| +
|
| + service_worker_unregister_and_register(t, worker_url, scope)
|
| + .then(function(r) {
|
| + registration = r;
|
| + return wait_for_update(t, registration);
|
| + })
|
| + .then(function(worker) {
|
| + return wait_for_state(t, worker, 'activated');
|
| + })
|
| + .then(function() {
|
| + return with_iframe(scope);
|
| + })
|
| + .then(function(frame) {
|
| + iframe = frame;
|
| + return registration.unregister();
|
| + })
|
| + .then(function() {
|
| + // FIXME: Register should not resolve until controllees are unloaded.
|
| + return navigator.serviceWorker.register(new_worker_url,
|
| + { scope: scope });
|
| + })
|
| + .then(function(new_registration) {
|
| + return wait_for_update(t, new_registration);
|
| + })
|
| + .then(function(worker) {
|
| + return wait_for_state(t, worker, 'activated');
|
| + })
|
| + .then(function() {
|
| + return with_iframe(scope);
|
| + })
|
| + .then(function(frame) {
|
| + assert_equals(
|
| + frame.contentWindow.navigator.serviceWorker.controller.scriptURL,
|
| + normalizeURL(new_worker_url),
|
| + 'document controller is the new worker');
|
| + service_worker_unregister_and_done(t, scope);
|
| + })
|
| + .catch(unreached_rejection(t));
|
| +}, 'Unregister then register a new script URL');
|
| +
|
| +async_test(function(t) {
|
| + var scope = 'scope/non-existent-worker';
|
| + var iframe;
|
| + var registration;
|
| +
|
| + service_worker_unregister_and_register(t, worker_url, scope)
|
| + .then(function(r) {
|
| + registration = r;
|
| + return wait_for_update(t, registration);
|
| + })
|
| + .then(function(worker) {
|
| + return wait_for_state(t, worker, 'activated');
|
| + })
|
| + .then(function() {
|
| + return with_iframe(scope);
|
| + })
|
| + .then(function(frame) {
|
| + iframe = frame;
|
| + return registration.unregister();
|
| + })
|
| + .then(function() {
|
| + // FIXME: Register should not resolve until controllees are unloaded.
|
| + return navigator.serviceWorker.register('this-will-404',
|
| + { scope: scope });
|
| + })
|
| + .then(
|
| + function() {
|
| + assert_unreached('register should reject the promise');
|
| + },
|
| + function() {
|
| + return unload_iframe(iframe);
|
| + })
|
| + .then(function() {
|
| + return with_iframe(scope);
|
| + })
|
| + .then(function(frame) {
|
| + assert_equals(frame.contentWindow.navigator.serviceWorker.controller,
|
| + null,
|
| + 'document should not load with a controller');
|
| + service_worker_unregister_and_done(t, scope);
|
| + })
|
| + .catch(unreached_rejection(t));
|
| +}, 'Registering a new script URL that 404s does not resurrect an ' +
|
| + 'unregistered registration');
|
| +
|
| +async_test(function(t) {
|
| + var scope = 'scope/reject-install-worker';
|
| + var iframe;
|
| + var registration;
|
| +
|
| + service_worker_unregister_and_register(t, worker_url, scope)
|
| + .then(function(r) {
|
| + registration = r;
|
| + return wait_for_update(t, registration);
|
| + })
|
| + .then(function(worker) {
|
| + return wait_for_state(t, worker, 'activated');
|
| + })
|
| + .then(function() {
|
| + return with_iframe(scope);
|
| + })
|
| + .then(function(frame) {
|
| + iframe = frame;
|
| + return registration.unregister();
|
| + })
|
| + .then(function() {
|
| + // FIXME: Register should not resolve until controllees are unloaded.
|
| + return navigator.serviceWorker.register(
|
| + 'resources/reject-install-worker.js', { scope: scope });
|
| + })
|
| + .then(function(new_registration) {
|
| + return wait_for_update(t, new_registration);
|
| + })
|
| + .then(function(worker) {
|
| + return wait_for_state(t, worker, 'redundant');
|
| + })
|
| + .then(function(worker) {
|
| + return unload_iframe(iframe);
|
| + })
|
| + .then(function() {
|
| + return with_iframe(scope);
|
| + })
|
| + .then(function(frame) {
|
| + assert_equals(frame.contentWindow.navigator.serviceWorker.controller,
|
| + null,
|
| + 'document should not load with a controller');
|
| + service_worker_unregister_and_done(t, scope);
|
| + })
|
| + .catch(unreached_rejection(t));
|
| + }, 'Registering a new script URL that fails to install does not resurrect ' +
|
| + 'an unregistered registration');
|
| +</script>
|
|
|