OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="/resources/testharness.js"></script> | 2 <script src="/resources/testharness.js"></script> |
3 <script src="/resources/testharnessreport.js"></script> | 3 <script src="/resources/testharnessreport.js"></script> |
4 <script src="/common/get-host-info.sub.js"></script> | 4 <script src="/common/get-host-info.sub.js"></script> |
5 <script src="resources/test-helpers.sub.js"></script> | 5 <script src="resources/test-helpers.sub.js"></script> |
6 <body> | 6 <body> |
7 <script> | 7 <script> |
8 var worker = 'resources/fetch-event-test-worker.js'; | 8 var worker = 'resources/fetch-event-test-worker.js'; |
9 | 9 |
10 async_test(function(t) { | 10 async_test(function(t) { |
| 11 const scope = 'resources/simple.html?headers'; |
| 12 service_worker_unregister_and_register(t, worker, scope) |
| 13 .then(function(reg) { |
| 14 return wait_for_state(t, reg.installing, 'activated'); |
| 15 }) |
| 16 .then(function() { return with_iframe(scope); }) |
| 17 .then(function(frame) { |
| 18 t.add_cleanup(function() { frame.remove(); }); |
| 19 const headers = JSON.parse(frame.contentDocument.body.textContent); |
| 20 const header_names = {}; |
| 21 for (const [name, value] of headers) { |
| 22 header_names[name] = true; |
| 23 } |
| 24 |
| 25 assert_true( |
| 26 header_names.hasOwnProperty('accept'), |
| 27 'request includes "Accept" header as inserted by Fetch' |
| 28 ); |
| 29 assert_true( |
| 30 header_names.hasOwnProperty('upgrade-insecure-requests'), |
| 31 'request specifies "Upgrade-Insecure Requests header as inserted by
Fetch' |
| 32 ); |
| 33 |
| 34 return service_worker_unregister_and_done(t, scope); |
| 35 }) |
| 36 .catch(unreached_rejection(t)); |
| 37 }, 'Service Worker headers in the request of a fetch event'); |
| 38 |
| 39 async_test(function(t) { |
11 var scope = 'resources/simple.html?string'; | 40 var scope = 'resources/simple.html?string'; |
12 service_worker_unregister_and_register(t, worker, scope) | 41 service_worker_unregister_and_register(t, worker, scope) |
13 .then(function(reg) { | 42 .then(function(reg) { |
14 return wait_for_state(t, reg.installing, 'activated'); | 43 return wait_for_state(t, reg.installing, 'activated'); |
15 }) | 44 }) |
16 .then(function() { return with_iframe(scope); }) | 45 .then(function() { return with_iframe(scope); }) |
17 .then(function(frame) { | 46 .then(function(frame) { |
18 assert_equals( | 47 assert_equals( |
19 frame.contentDocument.body.textContent, | 48 frame.contentDocument.body.textContent, |
20 'Test string', | 49 'Test string', |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 .then(response_text => { | 678 .then(response_text => { |
650 assert_equals(response_text, integrity_metadata, 'integrity'); | 679 assert_equals(response_text, integrity_metadata, 'integrity'); |
651 frame.remove(); | 680 frame.remove(); |
652 return service_worker_unregister_and_done(t, scope); | 681 return service_worker_unregister_and_done(t, scope); |
653 }) | 682 }) |
654 .catch(unreached_rejection(t)); | 683 .catch(unreached_rejection(t)); |
655 }, 'Service Worker responds to fetch event with the correct integrity_metadata
'); | 684 }, 'Service Worker responds to fetch event with the correct integrity_metadata
'); |
656 | 685 |
657 </script> | 686 </script> |
658 </body> | 687 </body> |
OLD | NEW |