tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

post-task-multiple-scheduler-order.window.js (1302B)


      1 // META: title=Scheduler: Tasks run order when multiple scheduler interfere the same event loop
      2 promise_test(async t => {
      3 
      4  const iframe = document.createElement("iframe");
      5 
      6  iframe.onload = async function() {
      7    const runOrder = [];
      8    const tasks = [];
      9 
     10    tasks.push(window.scheduler.postTask(function(){runOrder.push("outer")}));
     11    tasks.push(iframe.contentWindow.scheduler.postTask(function(){runOrder.push("inner")}));
     12 
     13    await Promise.all(tasks);
     14 
     15    assert_equals(runOrder.toString(),'outer,inner');
     16  }
     17 
     18  document.body.appendChild(iframe);
     19 }, 'Test scheduler.postTask() from two different schedulers with the same priority will run based on their enqueue order.');
     20 
     21 promise_test(async t => {
     22  const iframe = document.createElement("iframe");
     23 
     24  iframe.onload = async function() {
     25    const runOrder = [];
     26    const tasks = [];
     27 
     28    tasks.push(window.scheduler.postTask(function(){runOrder.push("outer")}));
     29    tasks.push(iframe.contentWindow.scheduler.postTask(function(){runOrder.push("inner")}, {priority: "user-blocking"}));
     30 
     31    await Promise.all(tasks);
     32 
     33    assert_equals(runOrder.toString(),'inner,outer');
     34  }
     35 
     36  document.body.appendChild(iframe);
     37 }, 'Test scheduler.postTask() from two different schedulers with different priorities will run based on their priorities');