|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=804395 |
|
5 --> |
|
6 <head> |
|
7 <meta charset="utf-8"> |
|
8 <title>Test for Bug 804395</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 </head> |
|
12 <body> |
|
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=804395">Mozilla Bug 804395</a> |
|
14 <p id="display"></p> |
|
15 <div id="content" style="display: none"> |
|
16 |
|
17 </div> |
|
18 <pre id="test"> |
|
19 <script type="application/javascript"> |
|
20 |
|
21 function test200() { |
|
22 var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true}); |
|
23 xhr.open('GET', 'jar:http://example.org/tests/content/base/test/file_bug804395.jar!/foo.bar', true); |
|
24 xhr.onreadystatechange = function() { |
|
25 if (xhr.readyState == 4) { |
|
26 ok(xhr.status == 200, "Existing file must have Status 200!"); |
|
27 runTests(); |
|
28 } |
|
29 } |
|
30 xhr.send(null); |
|
31 } |
|
32 |
|
33 function test404() { |
|
34 var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true}); |
|
35 xhr.open('GET', 'jar:http://example.org/tests/content/base/test/file_bug804395.jar!/foo.do_not_exist', true); |
|
36 xhr.onreadystatechange = function() { |
|
37 if (xhr.readyState == 4) { |
|
38 ok(xhr.status == 404, "Non existing file must have Status 404!"); |
|
39 runTests(); |
|
40 } |
|
41 } |
|
42 xhr.send(null); |
|
43 } |
|
44 |
|
45 function test0() { |
|
46 var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true}); |
|
47 xhr.open('GET', 'jar:http://example.org/tests/content/base/test/file_bug804395.jar!/foo.bar', true); |
|
48 ok(xhr.status == 0, "Not Sent request must have status 0"); |
|
49 runTests(); |
|
50 } |
|
51 |
|
52 var tests = [ test200, test404, test0 ]; |
|
53 function runTests() { |
|
54 if (!tests.length) { |
|
55 SimpleTest.finish(); |
|
56 return; |
|
57 } |
|
58 |
|
59 var test = tests.shift(); |
|
60 test(); |
|
61 } |
|
62 |
|
63 /** Test for Bug 804395 **/ |
|
64 SimpleTest.waitForExplicitFinish(); |
|
65 |
|
66 addLoadEvent(function() { |
|
67 SpecialPowers.pushPermissions([{'type': 'systemXHR', 'allow': true, 'context': document}], runTests); |
|
68 }); |
|
69 </script> |
|
70 </pre> |
|
71 </body> |
|
72 </html> |