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