OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
Peter Beverloo
2014/07/25 09:22:19
This is a new test, please do this in a separate p
Marijn Kruisselbrink
2014/07/30 23:40:54
Done.
| |
2 <title>Service Worker: fetch()</title> | |
3 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
4 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
5 <script src="resources/test-helpers.js"></script> | 4 <script src="../serviceworker/resources/test-helpers.js"></script> |
6 <script> | 5 <script> |
7 var test = async_test('Verify fetch() in a Service Worker'); | 6 var test = async_test('Verify geofencing in a Service Worker'); |
8 test.step(function() { | 7 test.step(function() { |
9 var scope = 'resources/blank.html'; | 8 var scope = 'resources/blank.html'; |
10 service_worker_unregister_and_register( | 9 service_worker_unregister_and_register( |
11 test, 'resources/fetch-worker.js', scope).then(test.step_func(onRegister )); | 10 test, 'resources/worker.js', scope).then(test.step_func(onRegister)); |
12 | 11 |
13 function onRegister(worker) { | 12 function onRegister(worker) { |
14 var messageChannel = new MessageChannel(); | 13 var messageChannel = new MessageChannel(); |
15 messageChannel.port1.onmessage = test.step_func(onMessage); | 14 messageChannel.port1.onmessage = test.step_func(onMessage); |
16 worker.postMessage({port: messageChannel.port2}, [messageChannel.port2]) ; | 15 worker.postMessage({port: messageChannel.port2}, [messageChannel.port2]) ; |
17 } | 16 } |
18 | 17 |
19 var result = []; | 18 var result = []; |
20 var expected = [ | 19 var expected = [ |
21 'Resolved: other.html [200]OK', | 20 'Rejected: The implementation did not support the requested type of obje ct or operation.', |
22 'Rejected: http:// : Invalid URL', | 21 'Rejected: The implementation did not support the requested type of obje ct or operation.', |
23 'Rejected: http://www.example.com/foo : Failed to fetch', | 22 'Rejected: The implementation did not support the requested type of obje ct or operation.' |
24 'Resolved: fetch-status.php?status=200 [200]OK', | |
25 'Resolved: fetch-status.php?status=404 [404]Not Found', | |
26 ]; | 23 ]; |
27 | 24 |
28 function onMessage(e) { | 25 function onMessage(e) { |
29 var message = e.data; | 26 var message = e.data; |
30 if (message == 'quit') { | 27 if (message == 'quit') { |
31 assert_array_equals(result, expected, 'Worker should post back expec ted values.'); | 28 assert_array_equals(result, expected, 'Worker should post back expec ted values.'); |
32 service_worker_unregister_and_done(test, scope); | 29 service_worker_unregister_and_done(test, scope); |
33 } else { | 30 } else { |
34 result.push(message); | 31 result.push(message); |
35 } | 32 } |
36 } | 33 } |
37 }); | 34 }); |
38 </script> | 35 </script> |
OLD | NEW |