Chromium Code Reviews| 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?pipe=sub"></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 return wait_for_update(t, registration); | |
| 14 }) | |
| 15 .then(function(sw) { | |
| 16 worker = sw; | |
| 17 return wait_for_state(t, sw, 'activated'); | |
|
nhiroki
2014/11/05 07:38:35
wait_for_activated()?
horo
2014/11/05 08:48:03
We have to use wait_for_update to get the servicew
| |
| 18 }) | |
| 19 .then(function() { return with_iframe(SCOPE); }) | |
| 20 .then(function(frame) { | |
| 21 return new Promise(function(resolve) { | |
| 22 frame.onload = function() { | |
| 23 resolve(frame); | |
| 24 }; | |
| 25 frame.contentWindow.location.reload(); | |
| 26 }); | |
| 27 }) | |
| 28 .then(function(frame) { | |
| 29 return new Promise(function(resolve) { | |
| 30 var channel = new MessageChannel(); | |
| 31 channel.port1.onmessage = t.step_func(function(msg) { | |
| 32 unload_iframe(frame); | |
| 33 resolve(msg); | |
| 34 }); | |
|
nhiroki
2014/11/05 07:38:35
nit: one more 2-space indent?
horo
2014/11/05 08:48:03
Done.
| |
| 35 worker.postMessage( | |
| 36 {port: channel.port2}, [channel.port2]); | |
| 37 }); | |
| 38 }) | |
| 39 .then(function(msg) { | |
| 40 var freshness_headers = { | |
| 41 'if-none-match': true, | |
| 42 'if-modified-since': true | |
| 43 }; | |
| 44 msg.data.requests.forEach(t.step_func(function(request) { | |
| 45 request.headers.forEach(t.step_func(function(header) { | |
| 46 assert_false( | |
| 47 !!freshness_headers[header[0]], | |
| 48 header[0] + ' header must not be set in the ' + | |
| 49 'FetchEvent\'s request. (url = ' + request.url + ')'); | |
| 50 })); | |
| 51 })) | |
| 52 service_worker_unregister_and_done(t, SCOPE); | |
| 53 }) | |
| 54 .catch(unreached_rejection(t)); | |
| 55 }, 'The headers of FetchEvent shouldn\'t contain freshness headers.'); | |
| 56 </script> | |
| OLD | NEW |