<script>

let runnable1 = {
  run() {
    window.opener.callOrder.push("Runnable1");
  }
}

let runnable2 = {
  run() {
    window.opener.callOrder.push("Runnable2");
  }
}

let runnable3 = {
  run() {
    window.opener.callOrder.push("Runnable3");
  }
}

window.onmessage = function () {
  window.opener.callOrder.push("PostMessage");
  if (window.loadCount == 1) {
    window.loadCount += 1;
    location.reload();
  } else {
    window.opener.onDone();
  }
};

// Pushed to normal queue
SpecialPowers.Services.tm.dispatchToMainThread(runnable1);
// Pushed to idle queue
window.postMessage("bar", "*");
// Pushed to normal queue
SpecialPowers.Services.tm.dispatchToMainThread(runnable2);
// Pushed to normal queue
SpecialPowers.Services.tm.dispatchToMainThread(runnable3);
</script>
