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

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

Issue 1865103003: ServiceWorker: Add a test to check if worker is deleted after reloading iframe following unregister (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: indent 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
« no previous file with comments | « no previous file | 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
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/re-register-after-reloading-iframe-'
61 + 'with-old-registration-in-use';
62 var registration;
63 var frame;
64 service_worker_unregister_and_register(t, worker_url, scope)
65 .then(function(r) {
nhiroki 2016/04/07 10:27:58 Can you make indents consistent with other tests?
shimazu (google) 2016/04/08 02:09:20 Done.
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 = function() { resolve(); };
nhiroki 2016/04/07 10:27:58 |frame.onload = resolve;| may work.
shimazu (google) 2016/04/08 02:09:20 Done.
79 frame.contentWindow.location.reload();
80 });
81 })
82 .then(function() {
83 return navigator.serviceWorker.register(worker_url, { scope: scope });
84 })
85 .then(function(r) {
86 registration = r;
87 assert_not_equals(r.installing, null,
88 'installing version should exist after reloading');
89 assert_equals(r.active, null,
90 'active version should be null after reloading');
91 return wait_for_state(t, r.installing, 'activated');
92 }).then(function (state) {
nhiroki 2016/04/07 10:27:58 - There is an extra space before |(state)|. - Can
shimazu (google) 2016/04/08 02:09:20 Done.
93 assert_equals(registration.installing, null,
94 'installing version goes to active after activated');
nhiroki 2016/04/07 10:27:59 To identify the worker, how about keeping the inst
nhiroki 2016/04/07 10:27:59 Generally, an assertion message should have the wo
shimazu (google) 2016/04/08 02:09:20 Done.
95 assert_not_equals(registration.active, null,
96 'installing SW comes to active after activated');
nhiroki 2016/04/07 10:27:58 There are some variants that represent service wor
shimazu (google) 2016/04/08 02:09:20 Done.
97 service_worker_unregister_and_done(t, scope);
98 })
99 .catch(unreached_rejection(t));
100 }, 'Unregister then register on the page containing iframe provided by SW ' +
101 'should renew the SW script.');
102
103 async_test(function(t) {
60 var scope = 'resources/scope/re-register-does-not-affect-existing-controllee '; 104 var scope = 'resources/scope/re-register-does-not-affect-existing-controllee ';
61 var iframe; 105 var iframe;
62 var registration; 106 var registration;
63 var controller; 107 var controller;
64 108
65 service_worker_unregister_and_register(t, worker_url, scope) 109 service_worker_unregister_and_register(t, worker_url, scope)
66 .then(function(r) { 110 .then(function(r) {
67 registration = r; 111 registration = r;
68 return wait_for_state(t, r.installing, 'activated'); 112 return wait_for_state(t, r.installing, 'activated');
69 }) 113 })
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // FIXME: When crbug.com/400602 is fixed, assert that controller 163 // FIXME: When crbug.com/400602 is fixed, assert that controller
120 // equals the original worker. 164 // equals the original worker.
121 assert_not_equals( 165 assert_not_equals(
122 frame.contentWindow.navigator.serviceWorker.controller, null, 166 frame.contentWindow.navigator.serviceWorker.controller, null,
123 'document should have a controller'); 167 'document should have a controller');
124 service_worker_unregister_and_done(t, scope); 168 service_worker_unregister_and_done(t, scope);
125 }) 169 })
126 .catch(unreached_rejection(t)); 170 .catch(unreached_rejection(t));
127 }, 'Unregister then register resurrects the registration'); 171 }, 'Unregister then register resurrects the registration');
128 </script> 172 </script>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698