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