| OLD | NEW |
| 1 <script src="test-helpers.js?pipe=sub"></script> | 1 <script src="test-helpers.js?pipe=sub"></script> |
| 2 <script> | 2 <script> |
| 3 var path = base_path() + 'fetch-access-control.php'; | 3 var path = base_path() + 'fetch-access-control.php'; |
| 4 var host_info = get_host_info(); | 4 var host_info = get_host_info(); |
| 5 | 5 |
| 6 function create_success_test_promise(url, with_credentials) { | 6 function create_success_test_promise(url, with_credentials) { |
| 7 return new Promise(function(resolve, reject) { | 7 return new Promise(function(resolve, reject) { |
| 8 var xhr = new XMLHttpRequest(); | 8 var xhr = new XMLHttpRequest(); |
| 9 xhr.onload = resolve; | 9 xhr.onload = resolve; |
| 10 xhr.onerror = function() { | 10 xhr.onerror = function() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 window.addEventListener('message', function(evt) { | 36 window.addEventListener('message', function(evt) { |
| 37 var port = evt.ports[0]; | 37 var port = evt.ports[0]; |
| 38 create_success_test_promise(host_info['HTTP_ORIGIN'] + path, false) | 38 create_success_test_promise(host_info['HTTP_ORIGIN'] + path, false) |
| 39 .then(function() { | 39 .then(function() { |
| 40 return create_failure_test_promise( | 40 return create_failure_test_promise( |
| 41 host_info['HTTP_REMOTE_ORIGIN'] + path, | 41 host_info['HTTP_REMOTE_ORIGIN'] + path, |
| 42 false); | 42 false); |
| 43 }) | 43 }) |
| 44 .then(function() { | 44 .then(function() { |
| 45 return create_failure_test_promise('./dummy?reject', false); |
| 46 }) |
| 47 .then(function() { |
| 48 return create_failure_test_promise('./dummy?resolve-null', false); |
| 49 }) |
| 50 .then(function() { |
| 45 return create_success_test_promise( | 51 return create_success_test_promise( |
| 46 './dummy?url=' + | 52 './dummy?url=' + |
| 47 encodeURIComponent(host_info['HTTP_ORIGIN'] + path), | 53 encodeURIComponent(host_info['HTTP_ORIGIN'] + path), |
| 48 false); | 54 false); |
| 49 }) | 55 }) |
| 50 .then(function() { | 56 .then(function() { |
| 51 return create_failure_test_promise( | 57 return create_failure_test_promise( |
| 52 './dummy?mode=no-cors&url=' + | 58 './dummy?mode=no-cors&url=' + |
| 53 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path), | 59 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path), |
| 54 false); | 60 false); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 76 true); | 82 true); |
| 77 }) | 83 }) |
| 78 .then(function() { | 84 .then(function() { |
| 79 port.postMessage({results: 'finish'}); | 85 port.postMessage({results: 'finish'}); |
| 80 }) | 86 }) |
| 81 .catch(function(e) { | 87 .catch(function(e) { |
| 82 port.postMessage({results: 'failure:' + e}); | 88 port.postMessage({results: 'failure:' + e}); |
| 83 }); | 89 }); |
| 84 }, false); | 90 }, false); |
| 85 </script> | 91 </script> |
| OLD | NEW |