tor-browser

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

post-task-with-abort-signal-in-handler.any.js (779B)


      1 // META: title=Scheduler: postTask with a signal and abort the signal when running the callback
      2 // META: global=window,worker
      3 'use strict';
      4 
      5 promise_test(t => {
      6  const controller = new TaskController();
      7  const signal = controller.signal;
      8  return promise_rejects_dom(t, 'AbortError', scheduler.postTask(() => {
      9    controller.abort();
     10  }, { signal }));
     11 }, 'Posting a task with a signal and abort the signal when running the sync callback');
     12 
     13 promise_test(t => {
     14  const controller = new TaskController();
     15  const signal = controller.signal;
     16  return scheduler.postTask(async () => {
     17    await new Promise(resolve => t.step_timeout(resolve, 0));
     18    controller.abort();
     19  }, { signal });
     20 }, 'Posting a task with a signal and abort the signal when running the async callback');