Revision control

1
<!DOCTYPE html>
2
<script src='../resources/testharness.js'></script>
3
<script src='../resources/testharnessreport.js'></script>
4
<script>
5
promise_test(async () => {
6
const chunks = [];
7
const stream = new ReadableStream({
8
start : (controller) => {
9
controller.close();
10
}
11
});
12
await new Promise(resolve => setTimeout(resolve, 0));
13
const reader = stream.getReader();
14
15
Object.prototype.then = function(chunk) {
16
chunks.push(chunk);
17
}
18
await reader.read();
19
delete Object.prototype.then;
20
21
assert_array_equals(chunks, []);
22
}, 'close synchronously');
23
24
promise_test(async () => {
25
const chunks = [];
26
const stream = new ReadableStream({
27
start : (controller) => {
28
controller.close();
29
}
30
});
31
await new Promise(resolve => setTimeout(resolve, 0));
32
const reader = stream.getReader();
33
34
Object.prototype.then = function(chunk) {
35
chunks.push(chunk);
36
}
37
await reader.read();
38
delete Object.prototype.then;
39
40
assert_array_equals(chunks, []);
41
}, 'close asynchronously');
42
43
promise_test(async () => {
44
const chunks = [];
45
const stream = new ReadableStream({
46
start : async (controller) => {
47
await new Promise(resolve => setTimeout(resolve, 0));
48
controller.enqueue('chunk');
49
}
50
});
51
const reader = stream.getReader();
52
53
Object.prototype.then = function(chunk) {
54
chunks.push(chunk);
55
}
56
await reader.read();
57
delete Object.prototype.then;
58
59
assert_array_equals(chunks, []);
60
}, 'enqueue synchronously');
61
62
promise_test(async () => {
63
const chunks = [];
64
const stream = new ReadableStream({
65
start : async (controller) => {
66
await new Promise(resolve => setTimeout(resolve, 0));
67
controller.enqueue('chunk');
68
}
69
});
70
const reader = stream.getReader();
71
72
Object.prototype.then = function(chunk) {
73
chunks.push(chunk);
74
}
75
await reader.read();
76
delete Object.prototype.then;
77
78
assert_array_equals(chunks, []);
79
}, 'enqueue asynchronously');
80
</script>