Revision control

1
<!DOCTYPE html>
2
<script src='../resources/testharness.js'></script>
3
<script src='../resources/testharnessreport.js'></script>
4
<script>
5
function printMethodError(method, target)
6
{
7
try {
8
method.call(target);
9
assert_unreached();
10
} catch(e) {
11
console.log(e);
12
}
13
}
14
15
function printPromiseMethodError(method, target)
16
{
17
return method.call(target).then(assert_unreached, (e) => {
18
console.log(e);
19
});
20
}
21
22
function printGetterError(object, getterName, target)
23
{
24
const getter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(object), getterName).get;
25
printMethodError(getter, target);
26
}
27
28
function printPromiseGetterError(object, getterName, target)
29
{
30
const getter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(object), getterName).get;
31
printPromiseMethodError(getter, target);
32
}
33
34
promise_test(function(test) {
35
// This test prints exceptions to check the format of their messages.
36
var controller;
37
var stream = new ReadableStream({
38
start: (c) => {
39
controller = c;
40
}
41
});
42
var reader = stream.getReader();
43
44
var results = [];
45
46
results.push(printPromiseMethodError(stream.cancel, controller));
47
results.push(printMethodError(stream.getReader, controller));
48
results.push(printMethodError(stream.tee, controller));
49
results.push(printGetterError(stream, "locked", controller));
50
51
results.push(printMethodError(controller.enqueue, reader));
52
results.push(printMethodError(controller.error, reader));
53
results.push(printMethodError(controller.close, reader));
54
results.push(printGetterError(controller, "desiredSize", reader));
55
56
results.push(printPromiseMethodError(reader.cancel, stream));
57
results.push(printPromiseMethodError(reader.read, stream));
58
results.push(printMethodError(reader.releaseLock, stream));
59
results.push(printPromiseGetterError(reader, "closed", stream));
60
61
return Promise.all(results);
62
}, "Exercising TypeError messages in ReadableStream, ReadableStreamDefaultController and ReadableStreamDefaultReader");
63
</script>