content/base/test/test_bug804395.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/test/test_bug804395.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=804395
     1.8 +-->
     1.9 +<head>
    1.10 +  <meta charset="utf-8">
    1.11 +  <title>Test for Bug 804395</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 +</head>
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=804395">Mozilla Bug 804395</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 type="application/javascript">
    1.23 +
    1.24 +function test200() {
    1.25 +  var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
    1.26 +  xhr.open('GET', 'jar:http://example.org/tests/content/base/test/file_bug804395.jar!/foo.bar', true);
    1.27 +  xhr.onreadystatechange = function() {
    1.28 +    if (xhr.readyState == 4) {
    1.29 +      ok(xhr.status == 200, "Existing file must have Status 200!");
    1.30 +      runTests();
    1.31 +    }
    1.32 +  }
    1.33 +  xhr.send(null);
    1.34 +}
    1.35 +
    1.36 +function test404() {
    1.37 +  var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
    1.38 +  xhr.open('GET', 'jar:http://example.org/tests/content/base/test/file_bug804395.jar!/foo.do_not_exist', true);
    1.39 +  xhr.onreadystatechange = function() {
    1.40 +    if (xhr.readyState == 4) {
    1.41 +      ok(xhr.status == 404, "Non existing file must have Status 404!");
    1.42 +      runTests();
    1.43 +    }
    1.44 +  }
    1.45 +  xhr.send(null);
    1.46 +}
    1.47 +
    1.48 +function test0() {
    1.49 +  var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
    1.50 +  xhr.open('GET', 'jar:http://example.org/tests/content/base/test/file_bug804395.jar!/foo.bar', true);
    1.51 +  ok(xhr.status == 0, "Not Sent request must have status 0");
    1.52 +  runTests();
    1.53 +}
    1.54 +
    1.55 +var tests = [ test200, test404, test0 ];
    1.56 +function runTests() {
    1.57 +  if (!tests.length) {
    1.58 +    SimpleTest.finish();
    1.59 +    return;
    1.60 +  }
    1.61 +
    1.62 +  var test = tests.shift();
    1.63 +  test();
    1.64 +}
    1.65 +
    1.66 +/** Test for Bug 804395 **/
    1.67 +SimpleTest.waitForExplicitFinish();
    1.68 +
    1.69 +addLoadEvent(function() {
    1.70 +   SpecialPowers.pushPermissions([{'type': 'systemXHR', 'allow': true, 'context': document}], runTests);
    1.71 +});
    1.72 +</script>
    1.73 +</pre>
    1.74 +</body>
    1.75 +</html>

mercurial