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