Merge pull request #591 from NativeScript/ligaz/fix-xhr-statusText

Fix XHR statusText property to return just the text
This commit is contained in:
Vladimir Enchev
2015-08-25 11:34:22 +03:00
2 changed files with 19 additions and 1 deletions

View File

@ -221,6 +221,24 @@ export function test_raises_onload_Event(done) {
xhr.send(); xhr.send();
} }
export function test_sets_status_and_statusText(done) {
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState > 3) {
try {
TKUnit.assertEqual(xhr.status, 200);
TKUnit.assertEqual(xhr.statusText, 'OK');
done(null);
}
catch (err) {
done(err);
}
}
};
xhr.open("GET", "https://httpbin.org/get");
xhr.send();
}
export function test_raises_onerror_Event(done) { export function test_raises_onerror_Event(done) {
let xhr = new XMLHttpRequest(); let xhr = new XMLHttpRequest();
xhr.onerror = () => { xhr.onerror = () => {

View File

@ -197,7 +197,7 @@ export class XMLHttpRequest {
if (this._readyState === this.UNSENT || this._readyState === this.OPENED || this._errorFlag) { if (this._readyState === this.UNSENT || this._readyState === this.OPENED || this._errorFlag) {
return ""; return "";
} }
return this._status + " " + statuses[this._status]; return statuses[this._status];
} }
} }