1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:38:11 +00:00
serenity/Tests/LibWeb/Text/input/include.js
Andrew Kaster 79fa892ca1 Tests: Add stub for the internals object when not running in test mode
This allows developers to open LibWeb test html files in Ladybird or in
other browsers to observe their behavior without the internals object.
2023-11-24 08:41:38 +01:00

31 lines
787 B
JavaScript

var __outputElement = null;
if (globalThis.internals === undefined) {
internals = {
signalTextTestIsDone: function () {},
};
}
function println(s) {
__outputElement.appendChild(document.createTextNode(s + "\n"));
}
document.addEventListener("DOMContentLoaded", function () {
__outputElement = document.createElement("pre");
__outputElement.setAttribute("id", "out");
document.body.appendChild(__outputElement);
});
function test(f) {
document.addEventListener("DOMContentLoaded", f);
window.addEventListener("load", () => {
internals.signalTextTestIsDone();
});
}
function asyncTest(f) {
const done = () => internals.signalTextTestIsDone();
document.addEventListener("DOMContentLoaded", () => {
f(done);
});
}