diff --git a/Tests/LibWeb/Text/input/get-bounding-client-rect.html b/Tests/LibWeb/Text/input/get-bounding-client-rect.html
index eb7da97d5d3..89d78cf6dcb 100644
--- a/Tests/LibWeb/Text/input/get-bounding-client-rect.html
+++ b/Tests/LibWeb/Text/input/get-bounding-client-rect.html
@@ -13,12 +13,10 @@
diff --git a/Tests/LibWeb/Text/input/include.js b/Tests/LibWeb/Text/input/include.js
index 41d9ba674b6..ee1e976412a 100644
--- a/Tests/LibWeb/Text/input/include.js
+++ b/Tests/LibWeb/Text/input/include.js
@@ -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);
});