From 94a27f11bce860b280568dd5751a19125b45a3af Mon Sep 17 00:00:00 2001 From: thorn0 Date: Tue, 8 Sep 2015 14:51:39 +0300 Subject: [PATCH] 1) add events 'error' and 'abort' 2) the status property must return 0 if the error flag is set --- lib/XMLHttpRequest.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/XMLHttpRequest.js b/lib/XMLHttpRequest.js index 949fdf9..1358173 100644 --- a/lib/XMLHttpRequest.js +++ b/lib/XMLHttpRequest.js @@ -509,11 +509,12 @@ exports.XMLHttpRequest = function() { * Called when an error is encountered to deal with it. */ this.handleError = function(error) { - this.status = 503; + this.status = 0; this.statusText = error; this.responseText = error.stack; errorFlag = true; setState(this.DONE); + this.dispatchEvent('error'); }; /** @@ -526,6 +527,7 @@ exports.XMLHttpRequest = function() { } headers = defaultHeaders; + this.status = 0; this.responseText = ""; this.responseXML = ""; @@ -538,6 +540,7 @@ exports.XMLHttpRequest = function() { setState(this.DONE); } this.readyState = this.UNSENT; + this.dispatchEvent('abort'); }; /**