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

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

Issue 1859343002: ServiceWorker: Remove iframes explicitly after a test is finished (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 21 matching lines...) Expand all
32 async_test(function(t) { 32 async_test(function(t) {
33 var scope = 'resources/scope/re-register-while-old-registration-in-use'; 33 var scope = 'resources/scope/re-register-while-old-registration-in-use';
34 var registration; 34 var registration;
35 35
36 service_worker_unregister_and_register(t, worker_url, scope) 36 service_worker_unregister_and_register(t, worker_url, scope)
37 .then(function(r) { 37 .then(function(r) {
38 registration = r; 38 registration = r;
39 return wait_for_state(t, r.installing, 'activated'); 39 return wait_for_state(t, r.installing, 'activated');
40 }) 40 })
41 .then(function() { 41 .then(function() {
42 return with_iframe(scope); 42 return with_iframe(scope, true);
43 }) 43 })
44 .then(function(frame) { 44 .then(function(frame) {
45 return registration.unregister(); 45 return registration.unregister();
46 }) 46 })
47 .then(function() { 47 .then(function() {
48 return navigator.serviceWorker.register(worker_url, { scope: scope }); 48 return navigator.serviceWorker.register(worker_url, { scope: scope });
49 }) 49 })
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-does-not-affect-existing-controllee '; 60 var scope = 'resources/scope/re-register-does-not-affect-existing-controllee ';
61 var iframe; 61 var iframe;
62 var registration; 62 var registration;
63 var controller; 63 var controller;
64 64
65 service_worker_unregister_and_register(t, worker_url, scope) 65 service_worker_unregister_and_register(t, worker_url, scope)
66 .then(function(r) { 66 .then(function(r) {
67 registration = r; 67 registration = r;
68 return wait_for_state(t, r.installing, 'activated'); 68 return wait_for_state(t, r.installing, 'activated');
69 }) 69 })
70 .then(function() { 70 .then(function() {
71 return with_iframe(scope); 71 return with_iframe(scope, true);
72 }) 72 })
73 .then(function(frame) { 73 .then(function(frame) {
74 iframe = frame; 74 iframe = frame;
75 controller = iframe.contentWindow.navigator.serviceWorker.controller; 75 controller = iframe.contentWindow.navigator.serviceWorker.controller;
76 return registration.unregister(); 76 return registration.unregister();
77 }) 77 })
78 .then(function() { 78 .then(function() {
79 return navigator.serviceWorker.register(worker_url, { scope: scope }); 79 return navigator.serviceWorker.register(worker_url, { scope: scope });
80 }) 80 })
81 .then(function(registration) { 81 .then(function(registration) {
(...skipping 13 matching lines...) Expand all
95 var scope = 'resources/scope/resurrection'; 95 var scope = 'resources/scope/resurrection';
96 var iframe; 96 var iframe;
97 var registration; 97 var registration;
98 98
99 service_worker_unregister_and_register(t, worker_url, scope) 99 service_worker_unregister_and_register(t, worker_url, scope)
100 .then(function(r) { 100 .then(function(r) {
101 registration = r; 101 registration = r;
102 return wait_for_state(t, r.installing, 'activated'); 102 return wait_for_state(t, r.installing, 'activated');
103 }) 103 })
104 .then(function() { 104 .then(function() {
105 return with_iframe(scope); 105 return with_iframe(scope, true);
106 }) 106 })
107 .then(function(frame) { 107 .then(function(frame) {
108 iframe = frame; 108 iframe = frame;
109 return registration.unregister(); 109 return registration.unregister();
110 }) 110 })
111 .then(function() { 111 .then(function() {
112 return navigator.serviceWorker.register(worker_url, { scope: scope }); 112 return navigator.serviceWorker.register(worker_url, { scope: scope });
113 }) 113 })
114 .then(function() { 114 .then(function() {
115 iframe.remove(); 115 iframe.remove();
116 return with_iframe(scope); 116 return with_iframe(scope, true);
117 }) 117 })
118 .then(function(frame) { 118 .then(function(frame) {
119 // FIXME: When crbug.com/400602 is fixed, assert that controller 119 // FIXME: When crbug.com/400602 is fixed, assert that controller
120 // equals the original worker. 120 // equals the original worker.
121 assert_not_equals( 121 assert_not_equals(
122 frame.contentWindow.navigator.serviceWorker.controller, null, 122 frame.contentWindow.navigator.serviceWorker.controller, null,
123 'document should have a controller'); 123 'document should have a controller');
124 service_worker_unregister_and_done(t, scope); 124 service_worker_unregister_and_done(t, scope);
125 }) 125 })
126 .catch(unreached_rejection(t)); 126 .catch(unreached_rejection(t));
127 }, 'Unregister then register resurrects the registration'); 127 }, 'Unregister then register resurrects the registration');
128 </script> 128 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698