OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <title>Service Worker: the headers of FetchEvent shouldn't contain freshness hea
ders</title> | |
3 <script src="../resources/testharness.js"></script> | |
4 <script src="../resources/testharnessreport.js"></script> | |
5 <script src="resources/test-helpers.js"></script> | |
6 <script> | |
7 async_test(function(t) { | |
8 var SCOPE = 'resources/fetch-request-no-freshness-headers-iframe.html'; | |
9 var SCRIPT = 'resources/fetch-request-no-freshness-headers-worker.js'; | |
10 var worker; | |
11 service_worker_unregister_and_register(t, SCRIPT, SCOPE) | |
12 .then(function(registration) { | |
13 worker = registration.installing; | |
14 return wait_for_state(t, worker, 'activated'); | |
15 }) | |
16 .then(function() { return with_iframe(SCOPE); }) | |
17 .then(function(frame) { | |
18 return new Promise(function(resolve) { | |
19 frame.onload = function() { | |
20 resolve(frame); | |
21 }; | |
22 frame.contentWindow.location.reload(); | |
23 }); | |
24 }) | |
25 .then(function(frame) { | |
26 return new Promise(function(resolve) { | |
27 var channel = new MessageChannel(); | |
28 channel.port1.onmessage = t.step_func(function(msg) { | |
29 frame.remove(); | |
30 resolve(msg); | |
31 }); | |
32 worker.postMessage( | |
33 {port: channel.port2}, [channel.port2]); | |
34 }); | |
35 }) | |
36 .then(function(msg) { | |
37 var freshness_headers = { | |
38 'if-none-match': true, | |
39 'if-modified-since': true | |
40 }; | |
41 msg.data.requests.forEach(t.step_func(function(request) { | |
42 request.headers.forEach(t.step_func(function(header) { | |
43 assert_false( | |
44 !!freshness_headers[header[0]], | |
45 header[0] + ' header must not be set in the ' + | |
46 'FetchEvent\'s request. (url = ' + request.url + ')'); | |
47 })); | |
48 })) | |
49 service_worker_unregister_and_done(t, SCOPE); | |
50 }) | |
51 .catch(unreached_rejection(t)); | |
52 }, 'The headers of FetchEvent shouldn\'t contain freshness headers.'); | |
53 </script> | |
OLD | NEW |