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

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: Fix the indents and check if r.active is the same with r.installing after the activation 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 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 return navigator.serviceWorker.register(worker_url, { scope: scope });
85 })
86 .then(function(r) {
87 registration = r;
88 service_worker = r.installing;
89 assert_not_equals(r.installing, null,
90 'installing sw should exist after reloading');
91 assert_equals(r.active, null,
92 'active sw should be null after reloading');
nhiroki 2016/04/08 03:46:26 The purpose of these assertions is to check that t
shimazu (google) 2016/04/11 03:28:45 Done.
93 return wait_for_state(t, r.installing, 'activated');
94 })
95 .then(function() {
96 assert_equals(registration.installing, null,
97 'installing sw should go to active after an ' +
98 'activated event fired');
99 assert_equals(registration.active, service_worker,
100 'installing sw should get activated after an ' +
101 'activated event fired');
102 service_worker_unregister_and_done(t, scope);
103 })
104 .catch(unreached_rejection(t));
105 }, 'Unregister then register on the page containing iframe provided by SW ' +
106 'should renew the SW script.');
falken 2016/04/08 02:27:18 This description doesn't seem to capture what the
shimazu (google) 2016/04/11 03:28:45 Done.
107
108 async_test(function(t) {
60 var scope = 'resources/scope/re-register-does-not-affect-existing-controllee '; 109 var scope = 'resources/scope/re-register-does-not-affect-existing-controllee ';
61 var iframe; 110 var iframe;
62 var registration; 111 var registration;
63 var controller; 112 var controller;
64 113
65 service_worker_unregister_and_register(t, worker_url, scope) 114 service_worker_unregister_and_register(t, worker_url, scope)
66 .then(function(r) { 115 .then(function(r) {
67 registration = r; 116 registration = r;
68 return wait_for_state(t, r.installing, 'activated'); 117 return wait_for_state(t, r.installing, 'activated');
69 }) 118 })
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // FIXME: When crbug.com/400602 is fixed, assert that controller 168 // FIXME: When crbug.com/400602 is fixed, assert that controller
120 // equals the original worker. 169 // equals the original worker.
121 assert_not_equals( 170 assert_not_equals(
122 frame.contentWindow.navigator.serviceWorker.controller, null, 171 frame.contentWindow.navigator.serviceWorker.controller, null,
123 'document should have a controller'); 172 'document should have a controller');
124 service_worker_unregister_and_done(t, scope); 173 service_worker_unregister_and_done(t, scope);
125 }) 174 })
126 .catch(unreached_rejection(t)); 175 .catch(unreached_rejection(t));
127 }, 'Unregister then register resurrects the registration'); 176 }, 'Unregister then register resurrects the registration');
128 </script> 177 </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