| OLD | NEW |
| 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, onRegister); | 12 service_worker_unregister_and_register(t, url, scope).then(onRegister); |
| 13 | 13 |
| 14 function sendMessagePort(worker) { | 14 function sendMessagePort(worker) { |
| 15 var messageChannel = new MessageChannel(); | 15 var messageChannel = new MessageChannel(); |
| 16 worker.postMessage({port:messageChannel.port2}, [messageChannel.port2]); | 16 worker.postMessage({port:messageChannel.port2}, [messageChannel.port2]); |
| 17 return messageChannel.port1; | 17 return messageChannel.port1; |
| 18 } | 18 } |
| 19 | 19 |
| 20 function onRegister(sw) { | 20 function onRegister(sw) { |
| 21 var port = sendMessagePort(sw); | 21 var port = sendMessagePort(sw); |
| 22 port.addEventListener('message', t.step_func(function(event) { | 22 port.addEventListener('message', t.step_func(function(event) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 39 location.href.substring(0, location.href.lastIndexOf('/') + 1) + sco
pe, | 39 location.href.substring(0, location.href.lastIndexOf('/') + 1) + sco
pe, |
| 40 'request.url should be passed to onfetch event.'); | 40 'request.url should be passed to onfetch event.'); |
| 41 assert_equals(event.data.method, 'GET', | 41 assert_equals(event.data.method, 'GET', |
| 42 'request.method should be passed to onfetch event.'); | 42 'request.method should be passed to onfetch event.'); |
| 43 assert_equals(event.data.headers['User-Agent'], navigator.userAgent, | 43 assert_equals(event.data.headers['User-Agent'], navigator.userAgent, |
| 44 'User-Agent header should be passed to onfetch event.') | 44 'User-Agent header should be passed to onfetch event.') |
| 45 service_worker_unregister_and_done(t, scope); | 45 service_worker_unregister_and_done(t, scope); |
| 46 } | 46 } |
| 47 }); | 47 }); |
| 48 </script> | 48 </script> |
| OLD | NEW |