make tests pass in the test runner as well by not checking for status code

This commit is contained in:
Bart van den Eijnden
2013-11-08 20:59:58 +01:00
parent cc4c0bda60
commit ffc2277c68
+10 -13
View File
@@ -2,26 +2,23 @@
(function(global) { (function(global) {
function afterLoad(type, path, next) { function afterLoad(type, path, next) {
var xhr = new XMLHttpRequest(); var client = new XMLHttpRequest();
xhr.open('GET', path, true); client.open('GET', path, true);
xhr.onload = function() { client.onload = function() {
var data; var data;
if (xhr.status == 200) { if (type === 'xml') {
if (type === 'xml') { data = client.responseXML;
data = xhr.responseXML;
} else {
data = xhr.responseText;
}
} else { } else {
throw new Error(path + ' loading failed: ' + xhr.status); data = client.responseText;
}
if (!data) {
throw new Error(path + ' loading failed: ' + client.status);
} }
next(data); next(data);
xhr = null;
}; };
xhr.send(); client.send();
} }
/** /**
* @param {string} path Relative path to file (e.g. 'spec/ol/foo.json'). * @param {string} path Relative path to file (e.g. 'spec/ol/foo.json').
* @param {function(Object)} next Function to call with response object on * @param {function(Object)} next Function to call with response object on