Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test that XHR abort() should not fire an "abort" event after a timeout happens. #161

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>