OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <meta http-equiv="Content-Security-Policy" content="treat-as-public-address"
> |
| 5 <script src="/resources/testharness.js"></script> |
| 6 <script src="/resources/testharnessreport.js"></script> |
| 7 <script src="./resources/preflight.js"></script> |
| 8 </head> |
| 9 <body> |
| 10 <script> |
| 11 async_test(function (t) { |
| 12 var xhr = new XMLHttpRequest; |
| 13 xhr.onload = t.unreached_func("The load should fail."); |
| 14 xhr.onerror = t.step_func_done(function (e) { |
| 15 assert_equals(0, e.loaded); |
| 16 }); |
| 17 |
| 18 xhr.open("GET", preflightURL('fail-with-500', 'json'), true); |
| 19 xhr.send(); |
| 20 }, "XHR should fail on failed preflight: 500 status"); |
| 21 |
| 22 async_test(function (t) { |
| 23 var xhr = new XMLHttpRequest; |
| 24 xhr.onload = t.unreached_func("The load should fail."); |
| 25 xhr.onerror = t.step_func_done(function (e) { |
| 26 assert_equals(0, e.loaded); |
| 27 }); |
| 28 |
| 29 xhr.open("GET", preflightURL('fail-without-allow', 'json'), true); |
| 30 xhr.send(); |
| 31 }, "XHR should fail on failed preflight: no allow-external"); |
| 32 |
| 33 |
| 34 async_test(function (t) { |
| 35 var xhr = new XMLHttpRequest; |
| 36 xhr.responseType = "json"; |
| 37 xhr.onload = t.step_func_done(function (e) { |
| 38 assert_equals('success', xhr.response.jsonpResult); |
| 39 }); |
| 40 xhr.onerror = t.unreached_func("The load should not fail."); |
| 41 |
| 42 xhr.open("GET", preflightURL('pass', 'json'), true); |
| 43 xhr.send(); |
| 44 }, "XHR should pass on successful preflight"); |
| 45 </script> |
| 46 </body> |
| 47 </html> |
OLD | NEW |