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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/http/tests/serviceworker/unregister-then-register.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="resources/test-helpers.js"></script>
5 <script>
6 var worker_url = 'resources/empty-worker.js';
7
8 async_test(function(t) {
9 var scope = 'scope/new-worker';
10 var new_worker_url = worker_url + '?new';
11 var iframe;
12 var registration;
13
14 service_worker_unregister_and_register(t, worker_url, scope)
15 .then(function(r) {
16 registration = r;
17 return wait_for_update(t, registration);
18 })
19 .then(function(worker) {
20 return wait_for_state(t, worker, 'activated');
21 })
22 .then(function() {
23 return with_iframe(scope);
24 })
25 .then(function(frame) {
26 iframe = frame;
27 return registration.unregister();
28 })
29 .then(function() {
30 // FIXME: Register should not resolve until controllees are unloaded.
31 return navigator.serviceWorker.register(new_worker_url,
32 { scope: scope });
33 })
34 .then(function(new_registration) {
35 return wait_for_update(t, new_registration);
36 })
37 .then(function(worker) {
38 return wait_for_state(t, worker, 'activated');
39 })
40 .then(function() {
41 return with_iframe(scope);
42 })
43 .then(function(frame) {
44 assert_equals(
45 frame.contentWindow.navigator.serviceWorker.controller.scriptURL,
46 normalizeURL(new_worker_url),
47 'document controller is the new worker');
48 service_worker_unregister_and_done(t, scope);
49 })
50 .catch(unreached_rejection(t));
51 }, 'Unregister then register a new script URL');
52
53 async_test(function(t) {
54 var scope = 'scope/non-existent-worker';
55 var iframe;
56 var registration;
57
58 service_worker_unregister_and_register(t, worker_url, scope)
59 .then(function(r) {
60 registration = r;
61 return wait_for_update(t, registration);
62 })
63 .then(function(worker) {
64 return wait_for_state(t, worker, 'activated');
65 })
66 .then(function() {
67 return with_iframe(scope);
68 })
69 .then(function(frame) {
70 iframe = frame;
71 return registration.unregister();
72 })
73 .then(function() {
74 // FIXME: Register should not resolve until controllees are unloaded.
75 return navigator.serviceWorker.register('this-will-404',
76 { scope: scope });
77 })
78 .then(
79 function() {
80 assert_unreached('register should reject the promise');
81 },
82 function() {
83 return unload_iframe(iframe);
84 })
85 .then(function() {
86 return with_iframe(scope);
87 })
88 .then(function(frame) {
89 assert_equals(frame.contentWindow.navigator.serviceWorker.controller,
90 null,
91 'document should not load with a controller');
92 service_worker_unregister_and_done(t, scope);
93 })
94 .catch(unreached_rejection(t));
95 }, 'Registering a new script URL that 404s does not resurrect an ' +
96 'unregistered registration');
97
98 async_test(function(t) {
99 var scope = 'scope/reject-install-worker';
100 var iframe;
101 var registration;
102
103 service_worker_unregister_and_register(t, worker_url, scope)
104 .then(function(r) {
105 registration = r;
106 return wait_for_update(t, registration);
107 })
108 .then(function(worker) {
109 return wait_for_state(t, worker, 'activated');
110 })
111 .then(function() {
112 return with_iframe(scope);
113 })
114 .then(function(frame) {
115 iframe = frame;
116 return registration.unregister();
117 })
118 .then(function() {
119 // FIXME: Register should not resolve until controllees are unloaded.
120 return navigator.serviceWorker.register(
121 'resources/reject-install-worker.js', { scope: scope });
122 })
123 .then(function(new_registration) {
124 return wait_for_update(t, new_registration);
125 })
126 .then(function(worker) {
127 return wait_for_state(t, worker, 'redundant');
128 })
129 .then(function(worker) {
130 return unload_iframe(iframe);
131 })
132 .then(function() {
133 return with_iframe(scope);
134 })
135 .then(function(frame) {
136 assert_equals(frame.contentWindow.navigator.serviceWorker.controller,
137 null,
138 'document should not load with a controller');
139 service_worker_unregister_and_done(t, scope);
140 })
141 .catch(unreached_rejection(t));
142 }, 'Registering a new script URL that fails to install does not resurrect ' +
143 'an unregistered registration');
144 </script>
OLDNEW
« 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