2 <title>Service Worker: fetch()</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.js"></script>
7 async_test(function(t) {
8 var scope = 'resources/blank.html';
9 service_worker_unregister_and_register(
10 t, 'resources/fetch-worker.js', scope)
11 .then(function(registration) {
12 return wait_for_update(t, registration);
15 var messageChannel = new MessageChannel();
16 messageChannel.port1.onmessage = t.step_func(onMessage);
17 sw.postMessage({port: messageChannel.port2}, [messageChannel.port2]);
19 .catch(unreached_rejection(t));
23 'Resolved: other.html [200]OK',
24 'Rejected: http:// : Invalid URL',
25 'Rejected: http://www.example.com/foo : Failed to fetch',
26 'Resolved: fetch-status.php?status=200 [200]OK',
27 'Resolved: fetch-status.php?status=404 [404]Not Found',
30 function onMessage(e) {
32 if (message == 'quit') {
33 assert_array_equals(result, expected,
34 'Worker should post back expected values.');
35 service_worker_unregister_and_done(t, scope);
40 }, 'Verify fetch() in a Service Worker');