chromium/third_party/wpt_tools/wpt/tools/wptrunner/wptrunner/executors/window-loaded.js

const [resolve] = arguments;

if (document.readyState != "complete") {
  window.addEventListener("load", () => {
    resolve();
  }, { once: true });
} else {
  resolve();
}