open-after-abort.htm (2695B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>XMLHttpRequest: open() after abort()</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <link rel="help" href="https://xhr.spec.whatwg.org/#the-open()-method" data-tested-assertations="following::ol/li[15] following::ol/li[15]/ol/li[1] following::ol/li[15]/ol/li[2]" /> 8 </head> 9 <body> 10 <div id="log"></div> 11 <script> 12 test(function(t) { 13 var client = new XMLHttpRequest(), 14 result = [], 15 expected = [ 16 'readystatechange', 0, 1, // open() 17 'readystatechange', 2, 4, // abort() 18 'abort', 2, 4, // abort() 19 'loadend', 2, 4, // abort() 20 'readystatechange', 3, 1, // open() 21 ] 22 23 var state = 0 24 25 client.onreadystatechange = t.step_func(function() { 26 result.push('readystatechange', state, client.readyState) 27 }) 28 client.onabort = t.step_func(function() { 29 // abort event must be fired synchronously from abort(). 30 assert_equals(state, 2) 31 32 // readystatechange should be fired before abort. 33 assert_array_equals(result, [ 34 'readystatechange', 0, 1, // open() 35 'readystatechange', 2, 4, // abort() 36 ]) 37 38 // readyState should be set to unsent (0) at the very end of abort(), 39 // after this (and onloadend) is called. 40 assert_equals(client.readyState, 4) 41 42 result.push('abort', state, client.readyState) 43 }) 44 client.onloadend = t.step_func(function() { 45 // abort event must be fired synchronously from abort(). 46 assert_equals(state, 2) 47 48 // readystatechange should be fired before abort. 49 assert_array_equals(result, [ 50 'readystatechange', 0, 1, // open() 51 'readystatechange', 2, 4, // abort() 52 'abort', 2, 4, // abort() 53 ]) 54 55 // readyState should be set to unsent (0) at the very end of abort(), 56 // after this is called. 57 assert_equals(client.readyState, 4) 58 59 result.push('loadend', state, client.readyState) 60 }) 61 62 client.open("GET", "resources/well-formed.xml") 63 assert_equals(client.readyState, 1) 64 65 state = 1 66 client.send(null) 67 state = 2 68 client.abort() 69 assert_equals(client.readyState, 0) 70 state = 3 71 client.open("GET", "resources/well-formed.xml") 72 assert_equals(client.readyState, 1) 73 assert_array_equals(result, expected) 74 }) 75 </script> 76 </body> 77 </html>