content/base/test/test_xhr_send.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/test/test_xhr_send.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,83 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=1096263
     1.8 +-->
     1.9 +<head>
    1.10 +  <meta charset="utf-8">
    1.11 +  <title>Test for Bug 1096263</title>
    1.12 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.14 +  <script type="application/javascript">
    1.15 +
    1.16 +  /** Test for Bug 1096263 **/
    1.17 +
    1.18 +SimpleTest.waitForExplicitFinish();
    1.19 +
    1.20 +function simpleGetTest() {
    1.21 +  var x = new XMLHttpRequest();
    1.22 +  x.open("GET", "echo.sjs");
    1.23 +  x.onload = function() {
    1.24 +      ok(true, "Should have processed GET");
    1.25 +      simplePostTest();
    1.26 +    }
    1.27 +  x.send({});
    1.28 +}
    1.29 +
    1.30 +function simplePostTest() {
    1.31 +  var x = new XMLHttpRequest();
    1.32 +  x.open("POST", "echo.sjs");
    1.33 +  x.onload = function() {
    1.34 +      ise(x.responseText, "somedata", "Should have processed POST");
    1.35 +      undefinedPostTest();
    1.36 +    }
    1.37 +    x.send({toString: function() { return "somedata"; }});
    1.38 +}
    1.39 +
    1.40 +function undefinedPostTest() {
    1.41 +  var x = new XMLHttpRequest();
    1.42 +  x.open("POST", "echo.sjs");
    1.43 +  x.onload = function() {
    1.44 +      ise(x.responseText, "undefined", "Should have processed POST");
    1.45 +      nullPostTest();
    1.46 +    }
    1.47 +    x.send({toString: function() { return undefined; }});
    1.48 +}
    1.49 +
    1.50 +function nullPostTest() {
    1.51 +  var x = new XMLHttpRequest();
    1.52 +  x.open("POST", "echo.sjs");
    1.53 +  x.onload = function() {
    1.54 +      ise(x.responseText, "null", "Should have processed POST");
    1.55 +      testExceptionInToString();
    1.56 +    }
    1.57 +    x.send({toString: function() { return null; }});
    1.58 +}
    1.59 +
    1.60 +function testExceptionInToString() {
    1.61 +  var x = new XMLHttpRequest();
    1.62 +  x.open("GET", "echo.sjs");
    1.63 +  x.onload = function() {
    1.64 +    ok(false);
    1.65 +    SimpleTest.finish();
    1.66 +  }
    1.67 +  try {
    1.68 +    x.send({toString: function() { throw "dummy"; }});
    1.69 +  } catch(ex) {
    1.70 +    ise(ex, "dummy");
    1.71 +    SimpleTest.finish();
    1.72 +  }
    1.73 +}
    1.74 +
    1.75 +  </script>
    1.76 +</head>
    1.77 +<body onload="simpleGetTest()">
    1.78 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1096263">Mozilla Bug 1096263</a>
    1.79 +<p id="display"></p>
    1.80 +<div id="content">
    1.81 +
    1.82 +</div>
    1.83 +<pre id="test">
    1.84 +</pre>
    1.85 +</body>
    1.86 +</html>

mercurial