content/base/test/test_xhr_send.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial