summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/scheduler/task-controller-abort2.any.js
blob: 075715b565912c128b7cc234c64d29ef79cb1220 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// META: title=Scheduler: TaskController.abort() Aborts Correct Task
// META: global=window,worker
'use strict';

promise_test(async t => {
  const taskControllers = [];
  const taskResults = [];

  for (let i = 0; i < 5; i++) {
    const controller = new TaskController();
    taskControllers.push(controller);

    const signal = controller.signal;
    taskResults.push(scheduler.postTask(() => i, {signal}));
  }

  const abortedTask = taskResults.splice(2, 1)[0];
  taskControllers[2].abort();
  await promise_rejects_dom(t, 'AbortError', abortedTask);

  const result = await Promise.all(taskResults);
  assert_equals(result.toString(), '0,1,3,4');
}, 'Test aborting a task aborts the appropriate task');