fetch-header-visibility.https.html (1723B)
1 <!DOCTYPE html> 2 <title>Service Worker: Visibility of headers during fetch.</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/common/get-host-info.sub.js"></script> 6 <script src="resources/test-helpers.sub.js"></script> 7 <body> 8 <script> 9 var worker = 'resources/fetch-rewrite-worker.js'; 10 var path = base_path() + 'resources/fetch-access-control.py'; 11 var host_info = get_host_info(); 12 var frame; 13 14 promise_test(function(t) { 15 var scope = 'resources/fetch-header-visibility-iframe.html'; 16 return service_worker_unregister_and_register(t, worker, scope) 17 .then(function(reg) { 18 t.add_cleanup(function() { 19 return service_worker_unregister(t, scope); 20 }); 21 22 return wait_for_state(t, reg.installing, 'activated'); 23 }) 24 .then(function() { 25 frame = document.createElement('iframe'); 26 frame.src = scope; 27 document.body.appendChild(frame); 28 29 // Resolve a promise when we recieve 2 success messages 30 return new Promise(function(resolve, reject) { 31 var remaining = 4; 32 function onMessage(e) { 33 if (e.data == 'PASS') { 34 remaining--; 35 if (remaining == 0) { 36 resolve(); 37 } else { 38 return; 39 } 40 } else { 41 reject(e.data); 42 } 43 44 window.removeEventListener('message', onMessage); 45 } 46 window.addEventListener('message', onMessage); 47 }); 48 }) 49 .then(function(result) { 50 frame.remove(); 51 }); 52 }, 'Visibility of defaulted headers during interception'); 53 </script> 54 </body>