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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/unregister-then-register.html

Issue 1886953003: ServiceWorker: Add a test to check the behavior after reloading iframe Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wrap at 80 columns Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="resources/test-helpers.js"></script> 4 <script src="resources/test-helpers.js"></script>
5 <script> 5 <script>
6 var worker_url = 'resources/empty-worker.js'; 6 var worker_url = 'resources/empty-worker.js';
7 7
8 async_test(function(t) { 8 async_test(function(t) {
9 var scope = 'resources/scope/re-register-resolves-to-new-value'; 9 var scope = 'resources/scope/re-register-resolves-to-new-value';
10 var iframe; 10 var iframe;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 .then(function(new_registration) { 50 .then(function(new_registration) {
51 assert_equals(registration, new_registration, 51 assert_equals(registration, new_registration,
52 'register should resolve to the same registration'); 52 'register should resolve to the same registration');
53 service_worker_unregister_and_done(t, scope); 53 service_worker_unregister_and_done(t, scope);
54 }) 54 })
55 .catch(unreached_rejection(t)); 55 .catch(unreached_rejection(t));
56 }, 'Unregister then register resolves to the original value if the ' + 56 }, 'Unregister then register resolves to the original value if the ' +
57 'registration is in use.'); 57 'registration is in use.');
58 58
59 async_test(function(t) { 59 async_test(function(t) {
60 var scope = 'resources/scope/complete-unregistration-followed-by-' +
61 'reloading-controllee-iframe';
62 var registration;
63 var frame;
64 var service_worker;
65 service_worker_unregister_and_register(t, worker_url, scope)
66 .then(function(r) {
67 registration = r;
68 return wait_for_state(t, r.installing, 'activated');
69 })
70 .then(function() {
71 return with_iframe(scope);
72 })
73 .then(function(f) {
74 frame = f;
75 return registration.unregister();
76 })
77 .then(function() {
78 return new Promise(function(resolve) {
79 frame.onload = resolve;
80 frame.contentWindow.location.reload();
81 });
82 })
83 .then(function() {
84 var c = frame.contentWindow.navigator.serviceWorker.controller;
85 assert_equals(c, null, 'a page after unregistration should not be ' +
86 'controlled by service worker');
87 return navigator.serviceWorker.getRegistration(scope);
88 })
89 .then(function(r) {
90 assert_equals(r, undefined, 'getRegistration should return ' +
91 'undefined after unregistration');
92 service_worker_unregister_and_done(t, scope);
93 })
94 .catch(unreached_rejection(t));
95 }, 'Reloading the last controlled iframe after unregistration should ensure ' +
96 'the deletion of the registration');
97
98 async_test(function(t) {
99 var scope = 'resources/scope/re-register-does-not-affect-existing-controllee '; 60 var scope = 'resources/scope/re-register-does-not-affect-existing-controllee ';
100 var iframe; 61 var iframe;
101 var registration; 62 var registration;
102 var controller; 63 var controller;
103 64
104 service_worker_unregister_and_register(t, worker_url, scope) 65 service_worker_unregister_and_register(t, worker_url, scope)
105 .then(function(r) { 66 .then(function(r) {
106 registration = r; 67 registration = r;
107 return wait_for_state(t, r.installing, 'activated'); 68 return wait_for_state(t, r.installing, 'activated');
108 }) 69 })
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // FIXME: When crbug.com/400602 is fixed, assert that controller 119 // FIXME: When crbug.com/400602 is fixed, assert that controller
159 // equals the original worker. 120 // equals the original worker.
160 assert_not_equals( 121 assert_not_equals(
161 frame.contentWindow.navigator.serviceWorker.controller, null, 122 frame.contentWindow.navigator.serviceWorker.controller, null,
162 'document should have a controller'); 123 'document should have a controller');
163 service_worker_unregister_and_done(t, scope); 124 service_worker_unregister_and_done(t, scope);
164 }) 125 })
165 .catch(unreached_rejection(t)); 126 .catch(unreached_rejection(t));
166 }, 'Unregister then register resurrects the registration'); 127 }, 'Unregister then register resurrects the registration');
167 </script> 128 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698