OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <body> |
| 4 <script src="../resources/testharness.js"></script> |
| 5 <script src="../resources/testharnessreport.js"></script> |
| 6 <script type="text/javascript"> |
| 7 // FIXME: Check loading from Stream after abort once loading API is ready. |
| 8 var testInLoadingState = async_test("Test aborting XMLHttpRequest with responseT
ype set to 'stream' in LOADING state."); |
| 9 |
| 10 testInLoadingState.step(function() |
| 11 { |
| 12 var xhr = new XMLHttpRequest; |
| 13 |
| 14 xhr.responseType = "stream"; |
| 15 |
| 16 var seenStates = []; |
| 17 |
| 18 xhr.onreadystatechange = testInLoadingState.step_func(function() { |
| 19 // onreadystatechange can be invoked multiple times in LOADING state. |
| 20 if (seenStates.length == 0 || xhr.readyState != seenStates[seenStates.le
ngth - 1]) |
| 21 seenStates.push(xhr.readyState); |
| 22 |
| 23 switch (xhr.readyState) { |
| 24 case xhr.UNSENT: |
| 25 assert_unreached('Unexpected readyState: UNSENT'); |
| 26 return; |
| 27 |
| 28 case xhr.OPENED: |
| 29 case xhr.HEADERS_RECEIVED: |
| 30 return; |
| 31 |
| 32 case xhr.LOADING: |
| 33 xhr.abort(); |
| 34 |
| 35 assert_equals(xhr.readyState, xhr.DONE, "xhr.readyState after abort(
) call"); |
| 36 assert_equals(xhr.response, null, "xhr.response after abort() call")
; |
| 37 return; |
| 38 |
| 39 case xhr.DONE: |
| 40 assert_array_equals(seenStates, [xhr.OPENED, xhr.HEADERS_RECEIVED, x
hr.LOADING, xhr.DONE]); |
| 41 testInLoadingState.done(); |
| 42 return; |
| 43 |
| 44 default: |
| 45 assert_unreached('Unexpected readyState: ' + xhr.readyState); |
| 46 return; |
| 47 } |
| 48 }); |
| 49 |
| 50 xhr.open('GET', '../resources/test.ogv', true); |
| 51 xhr.send(); |
| 52 }); |
| 53 |
| 54 var testInDoneState = async_test("Test aborting XMLHttpRequest with responseType
set to 'stream' in DONE state."); |
| 55 |
| 56 testInDoneState.step(function() |
| 57 { |
| 58 var xhr = new XMLHttpRequest; |
| 59 |
| 60 xhr.responseType = "stream"; |
| 61 |
| 62 var seenStates = []; |
| 63 |
| 64 xhr.onreadystatechange = testInDoneState.step_func(function() { |
| 65 // onreadystatechange can be invoked multiple times in LOADING state. |
| 66 if (seenStates.length == 0 || xhr.readyState != seenStates[seenStates.le
ngth - 1]) |
| 67 seenStates.push(xhr.readyState); |
| 68 |
| 69 switch (xhr.readyState) { |
| 70 case xhr.UNSENT: |
| 71 case xhr.OPENED: |
| 72 case xhr.HEADERS_RECEIVED: |
| 73 case xhr.LOADING: |
| 74 return; |
| 75 |
| 76 case xhr.DONE: |
| 77 assert_equals(xhr.status, 200, "xhr.status"); |
| 78 assert_not_equals(xhr.response, null, "xhr.response during DONE"); |
| 79 |
| 80 xhr.abort(); |
| 81 |
| 82 assert_equals(xhr.readyState, xhr.UNSENT, "xhr.readyState after abor
t() call"); |
| 83 assert_equals(xhr.response, null, "xhr.response after abort() call")
; |
| 84 |
| 85 assert_array_equals(seenStates, [xhr.OPENED, xhr.HEADERS_RECEIVED, x
hr.LOADING, xhr.DONE]); |
| 86 testInDoneState.done(); |
| 87 return; |
| 88 |
| 89 default: |
| 90 assert_unreached('Unexpected readyState: ' + xhr.readyState); |
| 91 return; |
| 92 } |
| 93 }); |
| 94 |
| 95 xhr.open('GET', '../resources/test.ogv', true); |
| 96 xhr.send(); |
| 97 }); |
| 98 </script> |
| 99 </body> |
| 100 </html> |
OLD | NEW |