1 <script src=
"../../resources/get-host-info.js"></script>
3 function check_referer(url
, expected_referer
) {
5 .then(function(res
) { return res
.json(); })
6 .then(function(headers
) {
7 if (headers
['Referer'] === expected_referer
) {
8 return Promise
.resolve();
10 return Promise
.reject('Referer for ' + url
+ ' must be ' +
11 expected_referer
+ ' but got ' +
17 window
.addEventListener('message', function(evt
) {
18 var host_info
= get_host_info();
19 var port
= evt
.ports
[0];
20 check_referer('request-headers.php?ignore=true',
21 host_info
['HTTP_ORIGIN'] +
22 '/serviceworker/resources/referer-iframe.html')
25 'request-headers.php',
26 host_info
['HTTP_ORIGIN'] +
27 '/serviceworker/resources/referer-iframe.html');
31 'request-headers.php?url=request-headers.php',
32 host_info
['HTTP_ORIGIN'] +
33 '/serviceworker/resources/fetch-rewrite-worker.js');
35 .then(function() { port
.postMessage({results
: 'finish'}); })
36 .catch(function(e
) { port
.postMessage({results
: 'failure:' + e
}); });