summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/scheduler/task-controller-abort1.any.js
blob: fc7e02ce375953d206ddf6dc75b29b1b8f91b7be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// META: title=Scheduler: TaskController.abort() Basic Functionality
// META: global=window,worker
'use strict';

promise_test(async t => {
  const controller = new TaskController();
  const signal = controller.signal;

  let didRun = false;
  const taskResult = scheduler.postTask(() => { didRun = true; }, {signal});

  controller.abort();

  await promise_rejects_dom(t, 'AbortError', taskResult);
  assert_false(didRun);
}, 'Test that TaskController.abort() prevents a task from running and rejects the promise');