1
0
Fork 0
firefox/testing/web-platform/tests/xhr/send-timeout-events.htm
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

62 lines
1.8 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<title>XMLHttpRequest: The send() method: timeout is not 0 </title>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">
async_test(t => {
const xhr = new XMLHttpRequest(),
expect = [4, "", "upload.timeout", "upload.loadend", "timeout", "loadend"];
let actual = [];
xhr.onreadystatechange = t.step_func(() => {
if (xhr.readyState == 4) {
actual.push(xhr.readyState, xhr.response);
}
});
xhr.onloadend = t.step_func_done(e => {
assert_equals(e.loaded, 0);
assert_equals(e.total, 0);
actual.push(e.type);
assert_array_equals(actual, expect);
});
xhr.ontimeout = t.step_func(e => {
assert_equals(e.loaded, 0);
assert_equals(e.total, 0);
actual.push(e.type);
});
xhr.upload.onloadend = t.step_func(e => {
assert_equals(e.loaded, 0);
assert_equals(e.total, 0);
actual.push("upload." + e.type);
});
xhr.upload.ontimeout = t.step_func(e => {
assert_equals(e.loaded, 0);
assert_equals(e.total, 0);
actual.push("upload." + e.type);
});
let content = "";
for (var i = 0; i < 121026; i++) {
content += "[" + i + "]";
}
xhr.open("POST", "./resources/trickle.py", true);
xhr.timeout = 1;
xhr.send(content);
});
</script>
</body>
</html>