abort-event-order.htm (1956B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <link rel="help" href="https://xhr.spec.whatwg.org/#the-abort()-method" data-tested-assertations="following-sibling::ol/li[4]/ol/li[3] following-sibling::ol/li[4]/ol/li[5] following-sibling::ol/li[4]/ol/li[6] following-sibling::ol/li[4]/ol/li[7]/ol/li[3] following-sibling::ol/li[4]/ol/li[7]/ol/li[4] following-sibling::ol/li[5]" /> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="resources/xmlhttprequest-event-order.js"></script> 8 <title>XMLHttpRequest: The abort() method: abort and loadend events</title> 9 </head> 10 11 <body> 12 <div id="log"></div> 13 14 <script type="text/javascript"> 15 var test = async_test(); 16 17 test.step(function() 18 { 19 var xhr = new XMLHttpRequest(); 20 prepare_xhr_for_event_order_test(xhr); 21 22 xhr.addEventListener("loadstart", function() { 23 test.step(function() 24 { 25 var readyState = xhr.readyState; 26 if (readyState == 1) 27 { 28 xhr.abort(); 29 VerifyResult(); 30 } else { 31 assert_unreached('Loadstart event should not fire in readyState '+readyState); 32 } 33 }); 34 }); 35 36 function VerifyResult() 37 { 38 test.step(function() 39 { 40 assert_xhr_event_order_matches([1, "loadstart(0,0,false)", 4, "upload.abort(0,0,false)", "upload.loadend(0,0,false)", "abort(0,0,false)", "loadend(0,0,false)"]); 41 42 assert_equals(xhr.readyState, 0, 'state should be UNSENT'); 43 test.done(); 44 }); 45 }; 46 47 xhr.open("POST", "./resources/content.py", true); 48 xhr.send("Test Message"); 49 }); 50 </script> 51 </body> 52 </html>