summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/dom-level0/file_separate_post_message_queue.html
blob: ce1494e3d255170f8a9fb367046ae051375dd625 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<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>