Bug 1885602 - Part 2: Add a MozillaAccountMenuButton composable for the menu redesign...
[gecko.git] / dom / xhr / tests / test_nestedSyncXHR.html
bloba2e10ad9e5448511f95c0dc4dab187d09b3b12c6
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>Test for sync XHR into sync XHRs</title>
6 <script src="/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
8 </head>
9 <body>
10 <script type="application/javascript">
13 let xhr = new XMLHttpRequest();
14 let testCompleted = false;
16 let frame = document.createElement('frame');
17 frame.addEventListener('load', function() {
18 if (testCompleted) {
19 return;
22 try {
23 xhr.responseType = "blob";
24 ok(false, "xhr.responseType cannot be settable");
25 } catch(e) {
26 ok(true, "xhr.responseType cannot be settable");
29 try {
30 xhr.abort();
31 ok(false, "xhr.abort should throw");
32 } catch(e) {
33 ok(true, "xhr.abort should throw");
36 try {
37 xhr.getAllResponseHeaders();
38 ok(false, "xhr.getAllResponseHeaders should throw");
39 } catch(e) {
40 ok(true, "xhr.getAllResponseHeaders should throw");
43 try {
44 xhr.getResponseHeader("foo");
45 ok(false, "xhr.getResponseHeader should throw");
46 } catch(e) {
47 ok(true, "xhr.getResponseHeader should throw");
50 try {
51 xhr.open('POST', location, false);
52 ok(false, "xhr.open should throw");
53 } catch(e) {
54 ok(true, "xhr.open should throw");
57 try {
58 xhr.send();
59 ok(false, "xhr.send should throw");
60 } catch(e) {
61 ok(true, "xhr.send should throw");
64 try {
65 xhr.timeout = 42;
66 ok(false, "xhr.timeout cannot be settable");
67 } catch(e) {
68 ok(true, "xhr.timeout cannot be settable");
71 try {
72 xhr.withCredentials = false;
73 ok(false, "xhr.withCredentials cannot be settable");
74 } catch(e) {
75 ok(true, "xhr.withCredentials cannot be settable");
78 try {
79 xhr.overrideMimeType("wow")
80 ok(false, "xhr.overrideMimeType should throw");
81 } catch(e) {
82 ok(true, "xhr.overrideMimeType should throw");
84 }, { once: true });
86 // This test is racy because we try to check that the loading of the frame
87 // happens during a sync XHR. If the loading happens after, we still need to
88 // consider the test passed.
89 ok(xhr, "We have an XHR.");
91 document.documentElement.appendChild(frame);
92 xhr.open('POST', location, false);
93 xhr.send('X');
95 // Nothing can guarantee that the frame is loaded during the sync XHR.
96 testCompleted = true;
98 frame.remove();
99 </script>
100 </body>
101 </html>