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

Side by Side Diff: LayoutTests/http/tests/serviceworker/request-end-to-end.html

Issue 776373003: ServiceWorker cleanup: remove wait_for_update() in favor of r.installing in most tests (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: Request end-to-end</title> 2 <title>Service Worker: Request end-to-end</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 <script> 6 <script>
7 var t = async_test('Request: end-to-end'); 7 var t = async_test('Request: end-to-end');
8 t.step(function() { 8 t.step(function() {
9 var url = 'resources/request-end-to-end-worker.js'; 9 var url = 'resources/request-end-to-end-worker.js';
10 var scope = 'resources/blank.html'; 10 var scope = 'resources/blank.html';
11 11
12 service_worker_unregister_and_register(t, url, scope) 12 service_worker_unregister_and_register(t, url, scope)
13 .then(t.step_func(function(registration) { 13 .then(onRegister)
14 return wait_for_update(t, registration);
15 }))
16 .then(t.step_func(onUpdateFound))
17 .catch(unreached_rejection(t)); 14 .catch(unreached_rejection(t));
18 15
19 function sendMessagePort(worker) { 16 function sendMessagePort(worker) {
20 var messageChannel = new MessageChannel(); 17 var messageChannel = new MessageChannel();
21 worker.postMessage({port:messageChannel.port2}, [messageChannel.port2]); 18 worker.postMessage({port:messageChannel.port2}, [messageChannel.port2]);
22 return messageChannel.port1; 19 return messageChannel.port1;
23 } 20 }
24 21
25 function onUpdateFound(sw) { 22 function onRegister(registration) {
23 var sw = registration.installing;
26 var port = sendMessagePort(sw); 24 var port = sendMessagePort(sw);
27 port.addEventListener('message', t.step_func(function(event) { 25 port.addEventListener('message', t.step_func(function(event) {
28 onMessage(event); 26 onMessage(event);
29 }), false); 27 }), false);
30 port.start(); 28 port.start();
31 sw.addEventListener('statechange', t.step_func(function(event) { 29 sw.addEventListener('statechange', t.step_func(function(event) {
32 if (event.target.state == 'activated') 30 if (event.target.state == 'activated')
33 onActive(); 31 onActive();
34 })); 32 }));
35 } 33 }
(...skipping 14 matching lines...) Expand all
50 'request.referrer should be passed to onfetch event.'); 48 'request.referrer should be passed to onfetch event.');
51 assert_equals(event.data.headers['user-agent'], navigator.userAgent, 49 assert_equals(event.data.headers['user-agent'], navigator.userAgent,
52 'User-Agent header should be passed to onfetch event.') 50 'User-Agent header should be passed to onfetch event.')
53 assert_equals(event.data.errorNameWhileAppendingHeader, 'TypeError', 51 assert_equals(event.data.errorNameWhileAppendingHeader, 'TypeError',
54 'Appending a new header to the request must throw a ' + 52 'Appending a new header to the request must throw a ' +
55 'TypeError.') 53 'TypeError.')
56 service_worker_unregister_and_done(t, scope); 54 service_worker_unregister_and_done(t, scope);
57 } 55 }
58 }); 56 });
59 </script> 57 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698