summaryrefslogtreecommitdiffstats
path: root/test/wpt/tests/xhr/timeout-cors-async.htm
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 20:56:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 20:56:19 +0000
commit0b6210cd37b68b94252cb798598b12974a20e1c1 (patch)
treee371686554a877842d95aa94f100bee552ff2a8e /test/wpt/tests/xhr/timeout-cors-async.htm
parentInitial commit. (diff)
downloadnode-undici-upstream.tar.xz
node-undici-upstream.zip
Adding upstream version 5.28.2+dfsg1+~cs23.11.12.3.upstream/5.28.2+dfsg1+_cs23.11.12.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/wpt/tests/xhr/timeout-cors-async.htm')
-rw-r--r--test/wpt/tests/xhr/timeout-cors-async.htm43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/wpt/tests/xhr/timeout-cors-async.htm b/test/wpt/tests/xhr/timeout-cors-async.htm
new file mode 100644
index 0000000..74397ba
--- /dev/null
+++ b/test/wpt/tests/xhr/timeout-cors-async.htm
@@ -0,0 +1,43 @@
+<!doctype html>
+<html>
+ <head>
+ <title>XMLHttpRequest: timeout event and cross-origin request</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <link rel="help" href="https://xhr.spec.whatwg.org/#the-timeout-attribute" data-tested-assertations="following::ol[1]/li[2]" />
+ <link rel="help" href="https://xhr.spec.whatwg.org/#handler-xhr-ontimeout" data-tested-assertations="../.."/>
+ <link rel="help" href="https://xhr.spec.whatwg.org/#timeout-error" data-tested-assertations=".."/>
+ <link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[4] following::ol[1]/li[9]"/>
+ <link rel="help" href="https://xhr.spec.whatwg.org/#cross-origin-request-event-rules" data-tested-assertations="following::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/.. following::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/../following-sibling::dd following::dt[1] following::dd[1]" />
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ var test = async_test()
+ var client = new XMLHttpRequest()
+ var gotTimeout = false
+ client.open("GET", "http://www2." + location.hostname + (location.port ? ":" + location.port : "") +(location.pathname.replace(/[^\/]+$/, '')+'resources/corsenabled.py')+"?delay=2&code=200")
+ client.timeout = 100
+ client.addEventListener('timeout', function (e) {
+ test.step(function() {
+ assert_equals(e.type, 'timeout')
+ assert_equals(client.status, 0)
+ gotTimeout = true
+ })
+ })
+ client.addEventListener('load', function (e) {
+ test.step(function() {
+ assert_unreached('load event should not fire')
+ })
+ })
+ client.addEventListener('loadend', function (e) {
+ test.step(function() {
+ assert_true(gotTimeout, "timeout event should fire")
+ test.done()
+ })
+ })
+
+ client.send(null)
+ </script>
+ </body>
+</html>