Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Unified Diff: LayoutTests/http/tests/serviceworker/unregister-then-register-new-script.html

Issue 474193002: Migrate some tests to use ServiceWorkerRegistration.unregister() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: nits Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/http/tests/serviceworker/unregister-then-register.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « LayoutTests/http/tests/serviceworker/unregister-then-register.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698