Skip to content

Commit c3980dc

Browse files
add description to function
1 parent 9863115 commit c3980dc

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tests/index.html

+13-3
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,25 @@
6868
});
6969
}
7070

71-
function checkIn(type) {
71+
/**
72+
* checkIn
73+
*
74+
* This function uses two global flags to ensure that both, the runner and the html page, are ready to run the tests.
75+
*
76+
* In certain scenarios, the runner may dispatch the 'start-test' event before the HTML page has the opportunity to add its listener.
77+
* To prevent the HTML page from waiting indefinitely and never initiating its tests, the runner proactively sets a global flag to true.
78+
* This ensures that even if the 'start-test' event precedes the listener's addition, the necessary check-in process occurs, enabling the tests to proceed as expected.
79+
*
80+
**/
81+
function checkIn() {
7282
if (window.runnerReady && window.domReady) startTest();
7383
}
7484

75-
window.addEventListener("start-test", () => checkIn("runner"));
85+
window.addEventListener("start-test", () => checkIn());
7686
document.addEventListener("readystatechange", () => {
7787
if (document.readyState === "complete") {
7888
window.domReady = true;
79-
checkIn("dom");
89+
checkIn();
8090
}
8191
});
8292
</script>

0 commit comments

Comments
 (0)