|
@@ -1,4 +1,11 @@
|
|
|
var __outputElement = null;
|
|
|
+let __alreadyCalledTest = false;
|
|
|
+function __preventMultipleTestFunctions() {
|
|
|
+ if (__alreadyCalledTest) {
|
|
|
+ throw new Error("You must only call test() or asyncTest() once per page");
|
|
|
+ }
|
|
|
+ __alreadyCalledTest = true;
|
|
|
+}
|
|
|
|
|
|
if (globalThis.internals === undefined) {
|
|
|
internals = {
|
|
@@ -17,6 +24,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
|
|
});
|
|
|
|
|
|
function test(f) {
|
|
|
+ __preventMultipleTestFunctions();
|
|
|
document.addEventListener("DOMContentLoaded", f);
|
|
|
window.addEventListener("load", () => {
|
|
|
internals.signalTextTestIsDone();
|
|
@@ -24,7 +32,10 @@ function test(f) {
|
|
|
}
|
|
|
|
|
|
function asyncTest(f) {
|
|
|
- const done = () => internals.signalTextTestIsDone();
|
|
|
+ const done = () => {
|
|
|
+ __preventMultipleTestFunctions();
|
|
|
+ internals.signalTextTestIsDone();
|
|
|
+ };
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
|
f(done);
|
|
|
});
|