diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/xhr/tests/test_nestedSyncXHR.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/xhr/tests/test_nestedSyncXHR.html')
-rw-r--r-- | dom/xhr/tests/test_nestedSyncXHR.html | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/dom/xhr/tests/test_nestedSyncXHR.html b/dom/xhr/tests/test_nestedSyncXHR.html new file mode 100644 index 0000000000..a2e10ad9e5 --- /dev/null +++ b/dom/xhr/tests/test_nestedSyncXHR.html @@ -0,0 +1,101 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="utf-8"> + <title>Test for sync XHR into sync XHRs</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> + <script type="application/javascript"> + + +let xhr = new XMLHttpRequest(); +let testCompleted = false; + +let frame = document.createElement('frame'); +frame.addEventListener('load', function() { + if (testCompleted) { + return; + } + + try { + xhr.responseType = "blob"; + ok(false, "xhr.responseType cannot be settable"); + } catch(e) { + ok(true, "xhr.responseType cannot be settable"); + } + + try { + xhr.abort(); + ok(false, "xhr.abort should throw"); + } catch(e) { + ok(true, "xhr.abort should throw"); + } + + try { + xhr.getAllResponseHeaders(); + ok(false, "xhr.getAllResponseHeaders should throw"); + } catch(e) { + ok(true, "xhr.getAllResponseHeaders should throw"); + } + + try { + xhr.getResponseHeader("foo"); + ok(false, "xhr.getResponseHeader should throw"); + } catch(e) { + ok(true, "xhr.getResponseHeader should throw"); + } + + try { + xhr.open('POST', location, false); + ok(false, "xhr.open should throw"); + } catch(e) { + ok(true, "xhr.open should throw"); + } + + try { + xhr.send(); + ok(false, "xhr.send should throw"); + } catch(e) { + ok(true, "xhr.send should throw"); + } + + try { + xhr.timeout = 42; + ok(false, "xhr.timeout cannot be settable"); + } catch(e) { + ok(true, "xhr.timeout cannot be settable"); + } + + try { + xhr.withCredentials = false; + ok(false, "xhr.withCredentials cannot be settable"); + } catch(e) { + ok(true, "xhr.withCredentials cannot be settable"); + } + + try { + xhr.overrideMimeType("wow") + ok(false, "xhr.overrideMimeType should throw"); + } catch(e) { + ok(true, "xhr.overrideMimeType should throw"); + } +}, { once: true }); + +// This test is racy because we try to check that the loading of the frame +// happens during a sync XHR. If the loading happens after, we still need to +// consider the test passed. +ok(xhr, "We have an XHR."); + +document.documentElement.appendChild(frame); +xhr.open('POST', location, false); +xhr.send('X'); + +// Nothing can guarantee that the frame is loaded during the sync XHR. +testCompleted = true; + +frame.remove(); + </script> +</body> +</html> |