invalid-header-iframe.https.html (699B)
1 <script src="test-helpers.sub.js"></script> 2 <script> 3 4 function xhr_send(method, data) { 5 return new Promise(function(resolve, reject) { 6 var xhr = new XMLHttpRequest(); 7 xhr.onload = function() { 8 reject('XHR must fail.'); 9 }; 10 xhr.onerror = function() { 11 resolve(); 12 }; 13 xhr.responseType = 'text'; 14 xhr.open(method, './sample?test', true); 15 xhr.send(data); 16 }); 17 } 18 19 window.addEventListener('message', function(evt) { 20 var port = evt.ports[0]; 21 xhr_send('POST', 'test string') 22 .then(function() { port.postMessage({results: 'finish'}); }) 23 .catch(function(e) { port.postMessage({results: 'failure:' + e}); }); 24 }); 25 </script>