Revision control

1
<!DOCTYPE html>
2
<script src='../resources/testharness.js'></script>
3
<script src='../resources/testharnessreport.js'></script>
4
<script>
6
7
var test1 = async_test('Erroring a ReadableStream after checking closed should reject ReadableStreamDefaultReader closed promise');
8
test1.step(function() {
9
var controller;
10
var rs = new ReadableStream({
11
start: function(c) {
12
controller = c;
13
}
14
});
15
16
rs.getReader().closed.then(test1.step_func(function() {
17
assert_unreached("closed promise should not be resolved when stream is errored");
18
}), test1.step_func(function(err) {
19
assert_equals(rsError, err);
20
test1.done();
21
}));
22
23
var rsError = "my error";
24
controller.error(rsError);
25
});
26
27
var test2 = async_test('Erroring a ReadableStream before checking closed should reject ReadableStreamDefaultReader closed promise');
28
test2.step(function() {
29
var controller;
30
var rs = new ReadableStream({
31
start: function(c) {
32
controller = c;
33
}
34
});
35
36
var rsError = "my error";
37
controller.error(rsError);
38
39
// Let's call getReader twice to ensure that stream is not locked to a reader.
40
rs.getReader().releaseLock();
41
rs.getReader().closed.then(test2.step_func(function() {
42
assert_unreached("closed promise should not be resolved when stream is errored");
43
}), test2.step_func(function(err) {
44
assert_equals(rsError, err);
45
test2.done();
46
}));
47
});
48
</script>