function assert(value,desc) {
var li = document.createElement("li");
li.className = value ? "pass" : "fail";
li.appendChild(document.createTextNode(desc));
document.getElementById("results").appendChild(li);
}
function pass(desc) {
var li = document.createElement("li");
li.className = "pass";
li.appendChild(document.createTextNode(desc));
document.getElementById("results").appendChild(li);
}
function fail(desc) {
var li = document.createElement("li");
li.className = "fail";
li.appendChild(document.createTextNode(desc));
document.getElementById("results").appendChild(li);
}
function report(text) {
assert(true,text);
}
function getJSON(url){
return new Promise((resolve,reject)=>{
const request = new XMLHttpRequest();
request.open("GET",url);
request.onload = function() {
try{
if (this.status ===200) {
resolve(JSON.parse(this.response));
} else {
reject(this.status + " " + this.statusText);
}
} catch (en) {
reject(en.message);
}
}
request.onerror = function() {
reject(this.status + " " + this.statusText);
}
request.send();
});
}