<!DOCTYPE html>
<meta charset="utf8">
<script>
window.onload = async () => {
  parent.postMessage("ready", "*");
}

window.addEventListener("message", async function listener(event) {
  if (event.data[0] == "gimme") {
  	var iframe = document.createElement("iframe");
    iframe.src = "about:blank?foo";
    document.body.append(iframe);

    function test() {
      let result = {
        hardwareConcurrency : navigator.hardwareConcurrency
      };

      window.parent.document.querySelector("#result").textContent = JSON.stringify(result);
    }

    iframe.contentWindow.eval(`(${test})()`);

    parent.postMessage(JSON.parse(document.querySelector("#result").textContent), "*")
  }
});
</script>
<output id="result"></output>
