content/base/test/test_xhr_send.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:bf02610eea0f
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=1096263
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 1096263</title>
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 <script type="application/javascript">
12
13 /** Test for Bug 1096263 **/
14
15 SimpleTest.waitForExplicitFinish();
16
17 function simpleGetTest() {
18 var x = new XMLHttpRequest();
19 x.open("GET", "echo.sjs");
20 x.onload = function() {
21 ok(true, "Should have processed GET");
22 simplePostTest();
23 }
24 x.send({});
25 }
26
27 function simplePostTest() {
28 var x = new XMLHttpRequest();
29 x.open("POST", "echo.sjs");
30 x.onload = function() {
31 ise(x.responseText, "somedata", "Should have processed POST");
32 undefinedPostTest();
33 }
34 x.send({toString: function() { return "somedata"; }});
35 }
36
37 function undefinedPostTest() {
38 var x = new XMLHttpRequest();
39 x.open("POST", "echo.sjs");
40 x.onload = function() {
41 ise(x.responseText, "undefined", "Should have processed POST");
42 nullPostTest();
43 }
44 x.send({toString: function() { return undefined; }});
45 }
46
47 function nullPostTest() {
48 var x = new XMLHttpRequest();
49 x.open("POST", "echo.sjs");
50 x.onload = function() {
51 ise(x.responseText, "null", "Should have processed POST");
52 testExceptionInToString();
53 }
54 x.send({toString: function() { return null; }});
55 }
56
57 function testExceptionInToString() {
58 var x = new XMLHttpRequest();
59 x.open("GET", "echo.sjs");
60 x.onload = function() {
61 ok(false);
62 SimpleTest.finish();
63 }
64 try {
65 x.send({toString: function() { throw "dummy"; }});
66 } catch(ex) {
67 ise(ex, "dummy");
68 SimpleTest.finish();
69 }
70 }
71
72 </script>
73 </head>
74 <body onload="simpleGetTest()">
75 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1096263">Mozilla Bug 1096263</a>
76 <p id="display"></p>
77 <div id="content">
78
79 </div>
80 <pre id="test">
81 </pre>
82 </body>
83 </html>

mercurial