| <sky> |
| <import src="../../resources/chai.sky" /> |
| <import src="../../resources/mocha.sky" /> |
| <import src="/sky/framework/xmlhttprequest.sky" as="XMLHttpRequest" /> |
| <script> |
| describe("xmlhttprequest", function() { |
| it("should call onerror when endpoint does not exist", function(done) { |
| var xhr = new XMLHttpRequest(); |
| xhr.open("GET", "does_not_exist.html"); |
| xhr.onerror = function() { |
| assert.fail("onload", "onerror", "onerror should not be called."); |
| done(); |
| } |
| xhr.onload = function() { |
| // Missing files are application-level errors, not network errors |
| // so onload fires, not onerror. |
| assert.equal(xhr.status, 404); |
| assert.equal(xhr.statusText, "HTTP/1.1 404 Not Found", |
| "status text should also be 404"); |
| done(); |
| } |
| xhr.send(); |
| }); |
| }); |
| </script> |
| </sky> |