OLD | NEW |
1 <sky> | 1 <sky> |
2 <import src="/sky/tests/resources/chai.sky" /> | 2 <import src="../../resources/chai.sky" /> |
3 <import src="/sky/tests/resources/mocha.sky" /> | 3 <import src="../../resources/mocha.sky" /> |
4 <import src="/sky/framework/xmlhttprequest.sky" as="XMLHttpRequest" /> | 4 <import src="/sky/framework/xmlhttprequest.sky" as="XMLHttpRequest" /> |
5 <script> | 5 <script> |
6 describe("xmlhttprequest", function() { | 6 describe("xmlhttprequest", function() { |
7 it("should call onerror when endpoint does not exist", function(done) { | 7 it("should call onerror when endpoint does not exist", function(done) { |
8 var xhr = new XMLHttpRequest(); | 8 var xhr = new XMLHttpRequest(); |
9 xhr.open("GET", "does_not_exist.html"); | 9 xhr.open("GET", "does_not_exist.html"); |
10 xhr.onerror = function() { | 10 xhr.onerror = function() { |
11 assert.fail("onload", "onerror", "onerror should not be called."); | 11 assert.fail("onload", "onerror", "onerror should not be called."); |
12 done(); | 12 done(); |
13 } | 13 } |
14 xhr.onload = function() { | 14 xhr.onload = function() { |
15 // Missing files are application-level errors, not network errors | 15 // Missing files are application-level errors, not network errors |
16 // so onload fires, not onerror. | 16 // so onload fires, not onerror. |
17 assert.equal(xhr.status, 404); | 17 assert.equal(xhr.status, 404); |
18 assert.equal(xhr.statusText, "HTTP/1.1 404 Not Found", | 18 assert.equal(xhr.statusText, "HTTP/1.1 404 Not Found", |
19 "status text should also be 404"); | 19 "status text should also be 404"); |
20 done(); | 20 done(); |
21 } | 21 } |
22 xhr.send(); | 22 xhr.send(); |
23 }); | 23 }); |
24 }); | 24 }); |
25 </script> | 25 </script> |
26 </sky> | 26 </sky> |
OLD | NEW |