testing/talos/talos/tests/cpstartup/cpstartup.html
author Butkovits Atila <abutkovits@mozilla.com>
Sat, 13 Aug 2022 12:21:24 +0300
changeset 627090 cbd753d186199d816e1d097631573f601932b96e
parent 442648 e19cd8da255dd2fedd21c69a99545d4b5f0f1ef3
permissions -rw-r--r--
Merge autoland to mozilla-central. a=merge

<html>
<head>
<script>

function init() {
  window.addEventListener("CPStartup:FinalResults", function onResults(event) {
    let results = event.detail;
    tpRecordTime(results, 0, "content-process-startup");
  }, {once: true});

  async function tryPing() {
    let pingPromise = new Promise(resolve => {
      window.addEventListener("CPStartup:Pong", resolve, {once: true});
      dispatchEvent(new CustomEvent("CPStartup:Ping", {bubbles: true}));
    });
    let timeoutPromise = new Promise((resolve, reject) => setTimeout(reject, 500));

    try {
      await Promise.race([pingPromise, timeoutPromise]);
    } catch (e) {
      return tryPing();
    }
    return null;
  }

  let target = document.location.href.replace(/cpstartup.html$/, "target.html");
  tryPing().then(() => {
    dispatchEvent(new CustomEvent("CPStartup:Go", {
      bubbles: true,
      detail: {target},
    }));
  });
}

</script>
</head>

<body onload="init();">
  Hello, Talos!

  <a href="#" id="target" target="_blank">I'll open a new tab</a>
</body>
</html>