OLD | NEW |
(Empty) | |
| 1 <script src="../resources/get-host-info.sub.js"></script> |
| 2 <script src="test-helpers.sub.js?pipe=sub"></script> |
| 3 <script> |
| 4 var host_info = get_host_info(); |
| 5 |
| 6 function boilerplate_test(msg) { |
| 7 return new Promise(function(resolve, reject) { |
| 8 var worker = new Worker("load_worker.js"); |
| 9 worker.onmessage = function(e) { resolve(e.data) }; |
| 10 worker.onerror = function(e) { reject(e) }; |
| 11 worker.postMessage(msg); |
| 12 }) |
| 13 .then(function(data) { |
| 14 window.parent.postMessage({results: data}, host_info['HTTPS_ORIGIN']); |
| 15 }); |
| 16 } |
| 17 |
| 18 function xhr_test() { |
| 19 return boilerplate_test("xhr"); |
| 20 } |
| 21 |
| 22 function fetch_test() { |
| 23 return boilerplate_test("fetch"); |
| 24 } |
| 25 |
| 26 function importScripts_test() { |
| 27 return boilerplate_test("importScripts"); |
| 28 } |
| 29 |
| 30 window.addEventListener('message', function(evt) { |
| 31 var port = evt.ports[0]; |
| 32 xhr_test() |
| 33 .then(fetch_test) |
| 34 .then(importScripts_test) |
| 35 .then(function() { port.postMessage({results: 'finish'}); }) |
| 36 .catch(function(e) { port.postMessage({results: 'failure:' + e}); }); |
| 37 }); |
| 38 |
| 39 </script> |
OLD | NEW |