2 <title>Service Worker: the headers of FetchEvent shouldn't contain freshness headers
</title>
3 <script src=
"../resources/testharness.js"></script>
4 <script src=
"../resources/testharnessreport.js"></script>
5 <script src=
"resources/test-helpers.js?pipe=sub"></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';
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');
16 .then(function() { return with_iframe(SCOPE
); })
17 .then(function(frame
) {
18 return new Promise(function(resolve
) {
19 frame
.onload = function() {
22 frame
.contentWindow
.location
.reload();
25 .then(function(frame
) {
26 return new Promise(function(resolve
) {
27 var channel
= new MessageChannel();
28 channel
.port1
.onmessage
= t
.step_func(function(msg
) {
33 {port
: channel
.port2
}, [channel
.port2
]);
37 var freshness_headers
= {
38 'if-none-match': true,
39 'if-modified-since': true
41 msg
.data
.requests
.forEach(t
.step_func(function(request
) {
42 request
.headers
.forEach(t
.step_func(function(header
) {
44 !!freshness_headers
[header
[0]],
45 header
[0] + ' header must not be set in the ' +
46 'FetchEvent\'s request. (url = ' + request
.url
+ ')');
49 service_worker_unregister_and_done(t
, SCOPE
);
51 .catch(unreached_rejection(t
));
52 }, 'The headers of FetchEvent shouldn\'t contain freshness headers.');