file_separate_post_message_queue.html (785B)
1 <script> 2 3 let runnable1 = { 4 run() { 5 window.opener.callOrder.push("Runnable1"); 6 } 7 } 8 9 let runnable2 = { 10 run() { 11 window.opener.callOrder.push("Runnable2"); 12 } 13 } 14 15 let runnable3 = { 16 run() { 17 window.opener.callOrder.push("Runnable3"); 18 } 19 } 20 21 window.onmessage = function () { 22 window.opener.callOrder.push("PostMessage"); 23 if (window.loadCount == 1) { 24 window.loadCount += 1; 25 location.reload(); 26 } else { 27 window.opener.onDone(); 28 } 29 }; 30 31 // Pushed to normal queue 32 SpecialPowers.Services.tm.dispatchToMainThread(runnable1); 33 // Pushed to idle queue 34 window.postMessage("bar", "*"); 35 // Pushed to normal queue 36 SpecialPowers.Services.tm.dispatchToMainThread(runnable2); 37 // Pushed to normal queue 38 SpecialPowers.Services.tm.dispatchToMainThread(runnable3); 39 </script>