[setup] console logging for niceurl tests
This commit is contained in:
parent
069fb92f54
commit
ac123317d8
1 changed files with 8 additions and 2 deletions
|
@ -5,25 +5,31 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
if(checkbox !== null && out_span !== null) {
|
if(checkbox !== null && out_span !== null) {
|
||||||
checkbox.disabled = true;
|
checkbox.disabled = true;
|
||||||
out_span.innerHTML = '(testing...)';
|
out_span.innerHTML = '(testing...)';
|
||||||
|
const test_url = document.body.getAttribute('data-base-href') + "/nicetest";
|
||||||
|
console.log("NiceURL testing with", test_url);
|
||||||
|
|
||||||
fetch(document.body.getAttribute('data-base-href') + "/nicetest").then(response => {
|
fetch(test_url).then(response => {
|
||||||
if(!response.ok) {
|
if(!response.ok) {
|
||||||
checkbox.disabled = true;
|
checkbox.disabled = true;
|
||||||
out_span.innerHTML = '(http error)';
|
out_span.innerHTML = '(http error)';
|
||||||
|
console.log("NiceURL test got HTTP error:", response.status, response.statusText);
|
||||||
} else {
|
} else {
|
||||||
response.text().then(text => {
|
response.text().then(text => {
|
||||||
if(text === 'ok') {
|
if(text === 'ok') {
|
||||||
checkbox.disabled = false;
|
checkbox.disabled = false;
|
||||||
out_span.innerHTML = '(test passed)';
|
out_span.innerHTML = '(test passed)';
|
||||||
|
console.log("NiceURL test passed");
|
||||||
} else {
|
} else {
|
||||||
checkbox.disabled = true;
|
checkbox.disabled = true;
|
||||||
out_span.innerHTML = '(test failed)';
|
out_span.innerHTML = '(test failed)';
|
||||||
|
console.log("NiceURL test got wrong content:", text);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch((e) => {
|
||||||
checkbox.disabled = true;
|
checkbox.disabled = true;
|
||||||
out_span.innerHTML = '(request failed)';
|
out_span.innerHTML = '(request failed)';
|
||||||
|
console.log("NiceURL test hit an exception:", e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Reference in a new issue