summaryrefslogtreecommitdiffstats
path: root/dom/xhr/tests/test_nestedSyncXHR.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /dom/xhr/tests/test_nestedSyncXHR.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
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.html101
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>