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

Side by Side Diff: LayoutTests/http/tests/serviceworker/chromium/postmessage-after-terminate.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>Tests that postMessage works during and after terminating a service worke r</title> 2 <title>Tests that postMessage works during and after terminating a service worke r</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/testharness-helpers.js"></script> 5 <script src="../../resources/testharness-helpers.js"></script>
6 <script src="../resources/test-helpers.js"></script> 6 <script src="../resources/test-helpers.js"></script>
7 <script> 7 <script>
8 function send_ping(worker) { 8 function send_ping(worker) {
9 return new Promise(function(resolve) { 9 return new Promise(function(resolve) {
10 var channel = new MessageChannel(); 10 var channel = new MessageChannel();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 var worker_script = 'resources/postmessage-worker.js'; 51 var worker_script = 'resources/postmessage-worker.js';
52 var scope = 'resources/postmessage-worker-scope'; 52 var scope = 'resources/postmessage-worker-scope';
53 var worker; 53 var worker;
54 var registration; 54 var registration;
55 var port; 55 var port;
56 56
57 service_worker_unregister_and_register( 57 service_worker_unregister_and_register(
58 t, worker_script, scope) 58 t, worker_script, scope)
59 .then(function(r) { 59 .then(function(r) {
60 registration = r; 60 registration = r;
61 return wait_for_activated(t, registration); 61 return wait_for_state(t, r.installing, 'activated');
62 }) 62 })
63 .then(function() { 63 .then(function() {
64 worker = registration.active; 64 worker = registration.active;
65 return internals.terminateServiceWorker(worker); 65 return internals.terminateServiceWorker(worker);
66 }) 66 })
67 .then(function() { 67 .then(function() {
68 var messageChannel = new MessageChannel(); 68 var messageChannel = new MessageChannel();
69 port = messageChannel.port1; 69 port = messageChannel.port1;
70 port.onmessage = t.step_func(on_message); 70 port.onmessage = t.step_func(on_message);
71 port.postMessage({value: 0}); 71 port.postMessage({value: 0});
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 var worker_script = 'resources/postmessage-port-worker.js'; 105 var worker_script = 'resources/postmessage-port-worker.js';
106 var scope = 'resources/postmessage-port-worker-scope'; 106 var scope = 'resources/postmessage-port-worker-scope';
107 var worker; 107 var worker;
108 var registration; 108 var registration;
109 var port; 109 var port;
110 110
111 service_worker_unregister_and_register( 111 service_worker_unregister_and_register(
112 t, worker_script, scope) 112 t, worker_script, scope)
113 .then(function(r) { 113 .then(function(r) {
114 registration = r; 114 registration = r;
115 return wait_for_activated(t, registration); 115 return wait_for_state(t, r.installing, 'activated');
116 }) 116 })
117 .then(function() { 117 .then(function() {
118 worker = registration.active; 118 worker = registration.active;
119 return internals.terminateServiceWorker(worker); 119 return internals.terminateServiceWorker(worker);
120 }) 120 })
121 .then(function() { 121 .then(function() {
122 var innerChannel = new MessageChannel(); 122 var innerChannel = new MessageChannel();
123 var outerChannel = new MessageChannel(); 123 var outerChannel = new MessageChannel();
124 port = innerChannel.port1; 124 port = innerChannel.port1;
125 port.onmessage = t.step_func(on_message); 125 port.onmessage = t.step_func(on_message);
(...skipping 24 matching lines...) Expand all
150 if (message === 'quit') { 150 if (message === 'quit') {
151 assert_array_equals(result, expected, 151 assert_array_equals(result, expected,
152 'Worker should post back expected values.'); 152 'Worker should post back expected values.');
153 service_worker_unregister_and_done(t, scope); 153 service_worker_unregister_and_done(t, scope);
154 } else { 154 } else {
155 result.push(message); 155 result.push(message);
156 } 156 }
157 } 157 }
158 }, 'postMessage on a port that was sent on a port that was sent to a terminate d service worker'); 158 }, 'postMessage on a port that was sent on a port that was sent to a terminate d service worker');
159 </script> 159 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698