summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/scheduler/post-task-with-abort-signal-in-handler.any.js
blob: 1fd416c775dcdd03286024ace3d61d929afb7282 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// META: title=Scheduler: postTask with a signal and abort the signal when running the callback
// META: global=window,worker
'use strict';

promise_test(t => {
  const controller = new TaskController();
  const signal = controller.signal;
  return promise_rejects_dom(t, 'AbortError', scheduler.postTask(() => {
    controller.abort();
  }, { signal }));
}, 'Posting a task with a signal and abort the signal when running the sync callback');

promise_test(t => {
  const controller = new TaskController();
  const signal = controller.signal;
  return scheduler.postTask(async () => {
    await new Promise(resolve => t.step_timeout(resolve, 0));
    controller.abort();
  }, { signal });
}, 'Posting a task with a signal and abort the signal when running the async callback');