content/base/test/test_xhr_send.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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">
    13   /** Test for Bug 1096263 **/
    15 SimpleTest.waitForExplicitFinish();
    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 }
    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 }
    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 }
    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 }
    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 }
    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">
    79 </div>
    80 <pre id="test">
    81 </pre>
    82 </body>
    83 </html>

mercurial