content/base/test/test_bug422537.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/test/test_bug422537.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=422537
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for bug 422537</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.13 +</head>
    1.14 +
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=422537">Mozilla Bug 422537</a>
    1.17 +<p id="display"></p>
    1.18 +<div id="content" style="display: none">
    1.19 +  
    1.20 +</div>
    1.21 +<pre id="test">
    1.22 +<script class="testbody" type="text/javascript">
    1.23 +
    1.24 +/** Test for Bug 422537 **/
    1.25 +var isupports_string = SpecialPowers.Cc["@mozilla.org/supports-string;1"]
    1.26 +                                    .createInstance(SpecialPowers.Ci.nsISupportsString);
    1.27 +isupports_string.data = "foo";
    1.28 +
    1.29 +const url = "http://mochi.test:8888";
    1.30 +var body = [
    1.31 +  document,
    1.32 +  "foo",
    1.33 +  isupports_string
    1.34 +];
    1.35 +
    1.36 +for (var i of body) {
    1.37 +  var xhr = new XMLHttpRequest();
    1.38 +  xhr.open("POST", url, true);
    1.39 +  if (i == isupports_string)
    1.40 +    SpecialPowers.wrap(xhr).send(i);
    1.41 +  else
    1.42 +    xhr.send(i);
    1.43 +  var chan = SpecialPowers.wrap(xhr).channel;
    1.44 +  if (!SpecialPowers.call_Instanceof(chan, SpecialPowers.Ci.nsIUploadChannel))
    1.45 +    throw "Must be an upload channel";
    1.46 +  var stream = chan.uploadStream;
    1.47 +  if (!stream || !SpecialPowers.call_Instanceof(stream, SpecialPowers.Ci.nsISeekableStream))
    1.48 +    throw "Stream must be seekable";
    1.49 +  // the following is a no-op, but should not throw an exception
    1.50 +  stream.seek(SpecialPowers.Ci.nsISeekableStream.NS_SEEK_CUR, 0);
    1.51 +}
    1.52 +
    1.53 +ok(true, "xhr is seekable");
    1.54 +
    1.55 +</script>
    1.56 +</pre>
    1.57 +</body>
    1.58 +</html>

mercurial