abort-event-abort.any.js (1176B)
1 // META: title=XMLHttpRequest: The abort() method: do not fire abort event in OPENED state when send() flag is unset. 2 3 var test = async_test() 4 5 test.step(function() 6 { 7 var xhr = new XMLHttpRequest() 8 9 xhr.onreadystatechange = function() 10 { 11 test.step(function() 12 { 13 if (xhr.readyState == 1) 14 { 15 xhr.abort(); 16 assert_equals(xhr.readyState, 1, "abort() cannot change readyState when readyState is 1 and send() flag is unset") 17 } 18 }); 19 }; 20 21 xhr.onabort = function(e) 22 { 23 test.step(function() 24 { 25 assert_unreached('when abort() is called, state is OPENED with the send() flag being unset, must not fire abort event per spec') 26 }); 27 }; 28 29 xhr.open("GET", "./resources/content.py", true); // This should cause a readystatechange event that calls abort() 30 xhr.send() // should not throw since abort() was a no-op 31 test.done() 32 });