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

Side by Side Diff: LayoutTests/http/tests/serviceworker/ready.html

Issue 790683002: ServiceWorker cleanup: remove wait_for_activated(); just use wait_for_state() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Service Worker: navigator.serviceWorker.ready</title> 2 <title>Service Worker: navigator.serviceWorker.ready</title>
3 <script src="../resources/testharness.js"></script> 3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.js"></script> 5 <script src="resources/test-helpers.js"></script>
6 <body> 6 <body>
7 <script> 7 <script>
8 test(function() { 8 test(function() {
9 var promise = navigator.serviceWorker.ready; 9 var promise = navigator.serviceWorker.ready;
10 assert_equals(promise, navigator.serviceWorker.ready, 10 assert_equals(promise, navigator.serviceWorker.ready,
(...skipping 15 matching lines...) Expand all
26 }, 'ready returns a Promise object in the context of the related document'); 26 }, 'ready returns a Promise object in the context of the related document');
27 27
28 async_test(function(t) { 28 async_test(function(t) {
29 var url = 'resources/empty-worker.js'; 29 var url = 'resources/empty-worker.js';
30 var scope = 'resources/blank.html?ready-controlled'; 30 var scope = 'resources/blank.html?ready-controlled';
31 var expected_url = normalizeURL(url); 31 var expected_url = normalizeURL(url);
32 var frame; 32 var frame;
33 33
34 service_worker_unregister_and_register(t, url, scope) 34 service_worker_unregister_and_register(t, url, scope)
35 .then(function(registration) { 35 .then(function(registration) {
36 return wait_for_activated(t, registration); 36 return wait_for_state(t, registration.installing, 'activated');
37 }) 37 })
38 .then(function() { return with_iframe(scope); }) 38 .then(function() { return with_iframe(scope); })
39 .then(function(f) { 39 .then(function(f) {
40 frame = f; 40 frame = f;
41 return frame.contentWindow.navigator.serviceWorker.ready; 41 return frame.contentWindow.navigator.serviceWorker.ready;
42 }) 42 })
43 .then(function(registration) { 43 .then(function(registration) {
44 assert_equals(registration.installing, null, 44 assert_equals(registration.installing, null,
45 'installing should be null'); 45 'installing should be null');
46 assert_equals(registration.waiting, null, 46 assert_equals(registration.waiting, null,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 async_test(function(t) { 92 async_test(function(t) {
93 var url = 'resources/empty-worker.js'; 93 var url = 'resources/empty-worker.js';
94 var scope = 'resources/blank.html?ready-after-unregister'; 94 var scope = 'resources/blank.html?ready-after-unregister';
95 var expected_url = normalizeURL(url); 95 var expected_url = normalizeURL(url);
96 var frame; 96 var frame;
97 var registration; 97 var registration;
98 98
99 service_worker_unregister_and_register(t, url, scope) 99 service_worker_unregister_and_register(t, url, scope)
100 .then(function(r) { 100 .then(function(r) {
101 registration = r; 101 registration = r;
102 return wait_for_activated(t, registration); 102 return wait_for_state(t, r.installing, 'activated');
103 }) 103 })
104 .then(function() { return with_iframe(scope); }) 104 .then(function() { return with_iframe(scope); })
105 .then(function(f) { 105 .then(function(f) {
106 frame = f; 106 frame = f;
107 return registration.unregister(); 107 return registration.unregister();
108 }) 108 })
109 .then(function() { 109 .then(function() {
110 return frame.contentWindow.navigator.serviceWorker.ready; 110 return frame.contentWindow.navigator.serviceWorker.ready;
111 }) 111 })
112 .then(function(registration) { 112 .then(function(registration) {
(...skipping 10 matching lines...) Expand all
123 123
124 unload_iframe(frame); 124 unload_iframe(frame);
125 service_worker_unregister_and_done(t, scope); 125 service_worker_unregister_and_done(t, scope);
126 }) 126 })
127 .catch(unreached_rejection(t)); 127 .catch(unreached_rejection(t));
128 }, 'ready after unregistration'); 128 }, 'ready after unregistration');
129 129
130 // FIXME: When replace() is implemented add a test that .ready is 130 // FIXME: When replace() is implemented add a test that .ready is
131 // repeatedly created and settled. 131 // repeatedly created and settled.
132 </script> 132 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698