Skip to content

Commit

Permalink
Merge pull request #161 from ronkorving/submissions/ronkorving
Browse files Browse the repository at this point in the history
Test that XHR abort() should not fire an "abort" event after a timeout happens. (reviewed by annevk)
  • Loading branch information
dontcallmedom committed Jun 8, 2013
2 parents 37fe22a + 7c58d19 commit f27eaa9
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion XMLHttpRequest/abort-after-receive.htm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
client.onabort = test.step_func(function () {
// this should not fire!

assert_unreached("abort should not cause the about event to fire");
assert_unreached("abort() should not cause the abort event to fire");
});

client.open("GET", "resources/well-formed.xml", true);
Expand Down
54 changes: 54 additions & 0 deletions XMLHttpRequest/abort-after-timeout.htm
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>

0 comments on commit f27eaa9

Please sign in to comment.