diff options
Diffstat (limited to 'testing/web-platform/tests/scheduler/task-controller-abort2.any.js')
-rw-r--r-- | testing/web-platform/tests/scheduler/task-controller-abort2.any.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/testing/web-platform/tests/scheduler/task-controller-abort2.any.js b/testing/web-platform/tests/scheduler/task-controller-abort2.any.js new file mode 100644 index 0000000000..075715b565 --- /dev/null +++ b/testing/web-platform/tests/scheduler/task-controller-abort2.any.js @@ -0,0 +1,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'); |