1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
'use strict';
promise_test(t => {
const signal = AbortSignal.abort();
return scheduler.postTask(async () => {
const p = scheduler.yield({signal});
await promise_rejects_dom(t, 'AbortError', p);
});
}, 'yield() with an aborted signal');
promise_test(t => {
const controller = new TaskController();
const signal = controller.signal;
const task = scheduler.postTask(async () => {
controller.abort();
const p = scheduler.yield({signal: 'inherit'});
await promise_rejects_dom(t, 'AbortError', p);
}, {signal});
return promise_rejects_dom(t, 'AbortError', task);
}, 'yield() with an aborted signal (inherit signal)');
promise_test(t => {
const controller = new TaskController();
const signal = controller.signal;
const task = scheduler.postTask(async () => {
controller.abort();
const p = scheduler.yield({signal: 'inherit', priority: 'background'});
await promise_rejects_dom(t, 'AbortError', p);
}, {signal});
return promise_rejects_dom(t, 'AbortError', task);
}, 'yield() with an aborted signal (inherit signal priority override)');
promise_test(t => {
const controller = new TaskController();
const signal = controller.signal;
const task = scheduler.postTask(async () => {
controller.abort();
await scheduler.yield({priority: 'inherit'});
}, {signal});
return promise_rejects_dom(t, 'AbortError', task);
}, 'yield() with an aborted signal (inherit priority only)');
promise_test(t => {
const controller = new TaskController();
const signal = controller.signal;
return scheduler.postTask(async () => {
scheduler.postTask(async () => {controller.abort();}, {priority: 'user-blocking'});
t.step(() => assert_false(signal.aborted));
const p = scheduler.yield({signal});
await promise_rejects_dom(t, 'AbortError', p);
});
}, 'yield() aborted in a separate task');
promise_test(t => {
const controller = new TaskController();
const signal = controller.signal;
return scheduler.postTask(async () => {
scheduler.postTask(async () => {controller.abort();}, {priority: 'user-blocking'});
t.step(() => assert_false(signal.aborted));
const p = scheduler.yield({signal: 'inherit'});
await promise_rejects_dom(t, 'AbortError', p);
}, {signal});
}, 'yield() aborted in a separate task (inherit)');
promise_test(t => {
const controller = new TaskController();
const signal = controller.signal;
return scheduler.postTask(async () => {
scheduler.postTask(async () => {controller.abort();}, {priority: 'user-blocking'});
t.step(() => assert_false(signal.aborted));
const p = scheduler.yield({signal: 'inherit', priority: 'background'});
await promise_rejects_dom(t, 'AbortError', p);
}, {signal});
}, 'yield() aborted in a separate task (inherit signal priority override)');
promise_test(t => {
const controller = new TaskController();
const signal = controller.signal;
return scheduler.postTask(async () => {
scheduler.postTask(async () => {controller.abort();}, {priority: 'user-blocking'});
t.step(() => assert_false(signal.aborted));
await scheduler.yield({priority: 'inherit'});
t.step(() => assert_true(signal.aborted));
}, {signal});
}, 'yield() aborted in a separate task (inherit priority only)');
|