summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/defer-script/resources/helper.js
blob: 89c6d1e8282097b5258588f688ae9fd2cbd69ad7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
window.result = [];
function log(msg) {
  window.result.push(msg);
}
function checkIfReachedBodyEnd() {
  const endelement = document.getElementById("bodyend");
  // `<pre id="bodyend">End</pre>` is needed at the end of HTML.
  if (endelement && endelement.textContent === "End") {
    log("EndOfBody");
    endelement.textContent = "Detected";
  }
}
function logScript(msg) {
  checkIfReachedBodyEnd();
  log(msg);
}
document.addEventListener("DOMContentLoaded", function() { logScript("DOMContentLoaded"); });