blob: 303ee9612abc2c1a3efd3498cabc2e5eda1ff873 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>XMLHttpRequest: make timeouts bigger than default timeout</title>
<script src="/js-test-resources/testharness.js"></script>
<script src="/js-test-resources/testharnessreport.js"></script>
</head>
<body>
<script type="text/javascript">
promise_test((test) => {
return new Promise((resolve, reject) => {
var xhr = new XMLHttpRequest();
var startTime = new Date();
xhr.open('GET', "/misc/resources/delayed-log.php?delay=10000000", true);
xhr.timeout = 70000; // time in milliseconds
xhr.onabort = () => { reject("onabort is called"); }
xhr.onload = () => { reject("onload is called"); };
xhr.onerror = () => { reject("onerror is called"); };
xhr.onloadend = () => { reject("onloadend is called but ontimeout was not"); };
xhr.ontimeout = function (e) {
var elapsed = new Date() - startTime;
if (elapsed > 65000 || elapsed < 55000) {
reject("elapsed time should be close to 60000 but is " + elapsed);
return;
}
resolve();
};
xhr.send(null);
xhr.timeout = 0;
});
}, "Resetting a timeout to zero after sending the request");
</script>
</body>
</html>