OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- This test is prefixed with `chromium.` because the equivalent version |
| 3 available in Web Platform Tests contains additional assertions which Chromium |
| 4 currently fails. This test should be persisted only to preserve test coverage |
| 5 until such time as the upstream version can be made to pass. See |
| 6 https://crbug.com/595993 --> |
2 <title>Service Worker: FetchEvent.request passed to onfetch</title> | 7 <title>Service Worker: FetchEvent.request passed to onfetch</title> |
3 <script src="../resources/testharness.js"></script> | 8 <script src="../resources/testharness.js"></script> |
4 <script src="../resources/testharnessreport.js"></script> | 9 <script src="../resources/testharnessreport.js"></script> |
5 <script src="resources/test-helpers.js"></script> | 10 <script src="resources/test-helpers.js"></script> |
6 <script> | 11 <script> |
| 12 'use strict'; |
| 13 |
7 promise_test(t => { | 14 promise_test(t => { |
8 var url = 'resources/request-end-to-end-worker.js'; | 15 var url = 'resources/request-end-to-end-worker.js'; |
9 var scope = 'resources/blank.html'; | 16 var scope = 'resources/blank.html'; |
10 return service_worker_unregister_and_register(t, url, scope) | 17 return service_worker_unregister_and_register(t, url, scope) |
11 .then(r => { | 18 .then(r => { |
12 add_completion_callback(() => { r.unregister(); }); | 19 add_completion_callback(() => { r.unregister(); }); |
13 return wait_for_state(t, r.installing, 'activated'); | 20 return wait_for_state(t, r.installing, 'activated'); |
14 }) | 21 }) |
15 .then(() => { return with_iframe(scope); }) | 22 .then(() => { return with_iframe(scope); }) |
16 .then(frame => { | 23 .then(frame => { |
17 add_completion_callback(() => { frame.remove(); }); | 24 add_completion_callback(() => { frame.remove(); }); |
18 | 25 |
19 var result = JSON.parse(frame.contentDocument.body.textContent); | 26 var result = JSON.parse(frame.contentDocument.body.textContent); |
20 assert_equals(result.url, frame.src, 'request.url'); | 27 assert_equals(result.url, frame.src, 'request.url'); |
21 assert_equals(result.method, 'GET', 'request.method'); | 28 assert_equals(result.method, 'GET', 'request.method'); |
22 assert_equals(result.referrer, location.href, 'request.referrer'); | 29 assert_equals(result.referrer, location.href, 'request.referrer'); |
23 assert_equals(result.mode, 'navigate', 'request.mode'); | 30 assert_equals(result.mode, 'navigate', 'request.mode'); |
24 assert_equals(result.request_construct_error, 'TypeError', | 31 assert_equals(result.request_construct_error, 'TypeError', |
25 'Constructing a Request with a Request whose mode ' + | 32 'Constructing a Request with a Request whose mode ' + |
26 'is navigate and non-empty RequestInit must throw a ' + | 33 'is navigate and non-empty RequestInit must throw a ' + |
27 'TypeError.') | 34 'TypeError.') |
28 assert_equals(result.credentials, 'include', 'request.credentials'); | 35 assert_equals(result.credentials, 'include', 'request.credentials'); |
29 assert_equals(result.redirect, 'manual', 'request.redirect'); | 36 assert_equals(result.redirect, 'manual', 'request.redirect'); |
| 37 // TODO(falken): Chromium should fail this assertion but currently |
| 38 // passes it. The equivalent WPT test instead asserts: |
| 39 // assert_equals(result.headers['user-agent'], undefined); |
| 40 // Once Chromium passes the WPT test assertion, this test file can be |
| 41 // removed. |
30 assert_equals(result.headers['user-agent'], navigator.userAgent, | 42 assert_equals(result.headers['user-agent'], navigator.userAgent, |
31 'User-Agent header'); | 43 'User-Agent header'); |
32 assert_equals(result.append_header_error, 'TypeError', | 44 assert_equals(result.append_header_error, 'TypeError', |
33 'Appending a new header to the request must throw a ' + | 45 'Appending a new header to the request must throw a ' + |
34 'TypeError.') | 46 'TypeError.') |
35 }); | 47 }); |
36 }, 'Test FetchEvent.request passed to onfetch'); | 48 }, 'Test FetchEvent.request passed to onfetch'); |
37 </script> | 49 </script> |
OLD | NEW |