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

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

Issue 354953002: Promisify Service Worker test unregister_and_register helper function (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: patch for landing Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Service Worker: fetch()</title> 2 <title>Service Worker: fetch()</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 test = async_test('Verify fetch() in a Service Worker'); 7 var test = async_test('Verify fetch() in a Service Worker');
8 test.step(function() { 8 test.step(function() {
9 var scope = 'resources/blank.html'; 9 var scope = 'resources/blank.html';
10 service_worker_unregister_and_register( 10 service_worker_unregister_and_register(
11 test, 'resources/fetch-worker.js', scope, onRegister); 11 test, 'resources/fetch-worker.js', scope).then(test.step_func(onRegister ));
12 12
13 function onRegister(worker) { 13 function onRegister(worker) {
14 var messageChannel = new MessageChannel(); 14 var messageChannel = new MessageChannel();
15 messageChannel.port1.onmessage = test.step_func(onMessage); 15 messageChannel.port1.onmessage = test.step_func(onMessage);
16 worker.postMessage({port: messageChannel.port2}, [messageChannel.port2]) ; 16 worker.postMessage({port: messageChannel.port2}, [messageChannel.port2]) ;
17 } 17 }
18 18
19 var result = []; 19 var result = [];
20 var expected = [ 20 var expected = [
21 'Resolved: other.html [200]OK', 21 'Resolved: other.html [200]OK',
22 'Rejected: http:// : Invalid URL', 22 'Rejected: http:// : Invalid URL',
23 'Rejected: http://www.example.com/foo : Failed to fetch', 23 'Rejected: http://www.example.com/foo : Failed to fetch',
24 'Resolved: fetch-status.php?status=200 [200]OK', 24 'Resolved: fetch-status.php?status=200 [200]OK',
25 'Resolved: fetch-status.php?status=404 [404]Not Found', 25 'Resolved: fetch-status.php?status=404 [404]Not Found',
26 ]; 26 ];
27 27
28 function onMessage(e) { 28 function onMessage(e) {
29 var message = e.data; 29 var message = e.data;
30 if (message == 'quit') { 30 if (message == 'quit') {
31 assert_array_equals(result, expected, 'Worker should post back expec ted values.'); 31 assert_array_equals(result, expected, 'Worker should post back expec ted values.');
32 service_worker_unregister_and_done(test, scope); 32 service_worker_unregister_and_done(test, scope);
33 } else { 33 } else {
34 result.push(message); 34 result.push(message);
35 } 35 }
36 } 36 }
37 }); 37 });
38 </script> 38 </script>
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/controller-on-load.html ('k') | LayoutTests/http/tests/serviceworker/fetch-event.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698