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