-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from ronkorving/submissions/ronkorving
Test that XHR abort() should not fire an "abort" event after a timeout happens. (reviewed by annevk)
- Loading branch information
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>XMLHttpRequest: abort() after a timeout should not fire "abort" event</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-abort()-method" /> | ||
</head> | ||
<body> | ||
<div id="log"></div> | ||
<script> | ||
var test = async_test(); | ||
|
||
test.step(function() { | ||
// timeout is 100ms | ||
// the download would otherwise take 500ms | ||
// we check after 300ms to make sure abort does not fire an "abort" event | ||
|
||
var timeoutFired = false; | ||
|
||
var client = new XMLHttpRequest(); | ||
|
||
assert_true('timeout' in client, 'xhr.timeout is not supported in this user agent'); | ||
|
||
client.timeout = 100; | ||
|
||
setTimeout(test.step_func(function() { | ||
assert_true(timeoutFired); | ||
|
||
// abort should not cause the "abort" event to fire | ||
|
||
client.abort(); | ||
|
||
assert_equals(client.readyState, 0); | ||
|
||
test.done(); | ||
}), 300); | ||
|
||
client.ontimeout = function () { | ||
timeoutFired = true; | ||
}; | ||
|
||
client.onabort = test.step_func(function () { | ||
// this should not fire! | ||
|
||
assert_unreached("abort() should not cause the abort event to fire"); | ||
}); | ||
|
||
client.open("GET", "resources/delay.php?ms=500000", true); | ||
client.send(null); | ||
}); | ||
</script> | ||
</body> | ||
</html> |