| <!doctype html> |
| <html> |
| <head> |
| <title>XMLHttpRequest: send() during onloadstart</title> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| </head> |
| <body> |
| <script> |
| var testAsync = async_test("Attempting a send() during onloadstart"); |
| testAsync.step(() => { |
| var xhr = new XMLHttpRequest(); |
| xhr.open("POST", "resources/delay.php?iteration=1&delay=1000"); |
| xhr.onloadstart = testAsync.step_func(() => { |
| assert_equals(xhr.readyState, XMLHttpRequest.OPENED); |
| // Step 2 of send(): "If the send() flag is set, throw an InvalidStateError exception." |
| assert_throws_dom('InvalidStateError', () => { xhr.send(); }); |
| }); |
| xhr.onloadend = testAsync.step_func(() => { |
| assert_equals(xhr.readyState, XMLHttpRequest.DONE); |
| testAsync.done(); |
| }); |
| xhr.send(); |
| }); |
| </script> |
| </body> |
| </html> |