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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/unregister-then-register.https.html

Issue 2904123002: Upstream service worker "unregister" tests to WPT (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/reject-install-worker.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.sub.js"></script> 4 <script src="resources/test-helpers.sub.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 registration; 10 var registration;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 .then(function(new_registration) { 49 .then(function(new_registration) {
50 assert_equals(registration, new_registration, 50 assert_equals(registration, new_registration,
51 'new registration should resolve to the same registratio n'); 51 'new registration should resolve to the same registratio n');
52 service_worker_unregister_and_done(t, scope); 52 service_worker_unregister_and_done(t, scope);
53 }) 53 })
54 .catch(unreached_rejection(t)); 54 .catch(unreached_rejection(t));
55 }, 'Unregister then register resolves to the original value if the ' + 55 }, 'Unregister then register resolves to the original value if the ' +
56 'registration is in use.'); 56 'registration is in use.');
57 57
58 async_test(function(t) { 58 async_test(function(t) {
59 var scope = 'resources/scope/complete-unregistration-followed-by-' +
60 'reloading-controllee-iframe';
61 var registration;
62 var frame;
63 var service_worker;
64 service_worker_unregister_and_register(t, worker_url, scope)
65 .then(function(r) {
66 registration = r;
67 return wait_for_state(t, r.installing, 'activated');
68 })
69 .then(function() {
70 return with_iframe(scope);
71 })
72 .then(function(f) {
73 frame = f;
74 return registration.unregister();
75 })
76 .then(function() {
77 return new Promise(function(resolve) {
78 frame.onload = resolve;
79 frame.contentWindow.location.reload();
80 });
81 })
82 .then(function() {
83 var c = frame.contentWindow.navigator.serviceWorker.controller;
84 assert_equals(c, null, 'a page after unregistration should not be ' +
85 'controlled by service worker');
86 return navigator.serviceWorker.getRegistration(scope);
87 })
88 .then(function(r) {
89 assert_equals(r, undefined, 'getRegistration should return ' +
90 'undefined after unregistration');
91 service_worker_unregister_and_done(t, scope);
92 })
93 .catch(unreached_rejection(t));
94 }, 'Reloading the last controlled iframe after unregistration should ensure ' +
95 'the deletion of the registration');
96
97 async_test(function(t) {
59 var scope = 'resources/scope/re-register-does-not-affect-existing-controllee '; 98 var scope = 'resources/scope/re-register-does-not-affect-existing-controllee ';
60 var iframe; 99 var iframe;
61 var registration; 100 var registration;
62 var controller; 101 var controller;
63 102
64 service_worker_unregister_and_register(t, worker_url, scope) 103 service_worker_unregister_and_register(t, worker_url, scope)
65 .then(function(r) { 104 .then(function(r) {
66 registration = r; 105 registration = r;
67 return wait_for_state(t, r.installing, 'activated'); 106 return wait_for_state(t, r.installing, 'activated');
68 }) 107 })
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return registration.unregister(); 148 return registration.unregister();
110 }) 149 })
111 .then(function() { 150 .then(function() {
112 return navigator.serviceWorker.register(worker_url, { scope: scope }); 151 return navigator.serviceWorker.register(worker_url, { scope: scope });
113 }) 152 })
114 .then(function() { 153 .then(function() {
115 iframe.remove(); 154 iframe.remove();
116 return with_iframe(scope); 155 return with_iframe(scope);
117 }) 156 })
118 .then(function(frame) { 157 .then(function(frame) {
119 // FIXME: When crbug.com/400602 is fixed, assert that controller
120 // equals the original worker.
121 assert_not_equals( 158 assert_not_equals(
122 frame.contentWindow.navigator.serviceWorker.controller, null, 159 frame.contentWindow.navigator.serviceWorker.controller, null,
123 'document should have a controller'); 160 'document should have a controller');
124 frame.remove(); 161 frame.remove();
125 service_worker_unregister_and_done(t, scope); 162 service_worker_unregister_and_done(t, scope);
126 }) 163 })
127 .catch(unreached_rejection(t)); 164 .catch(unreached_rejection(t));
128 }, 'Unregister then register resurrects the registration'); 165 }, 'Unregister then register resurrects the registration');
129 </script> 166 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/reject-install-worker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698