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
|
// META: global=window,worker
'use strict';
// Tests which patch the global environment are kept separate to avoid
// interfering with other tests.
test(t => {
// eslint-disable-next-line no-extend-native, accessor-pairs
Object.defineProperty(Object.prototype, 'highWaterMark', {
set() { throw new Error('highWaterMark setter called'); },
configurable: true
});
// eslint-disable-next-line no-extend-native, accessor-pairs
Object.defineProperty(Object.prototype, 'size', {
set() { throw new Error('size setter called'); },
configurable: true
});
t.add_cleanup(() => {
delete Object.prototype.highWaterMark;
delete Object.prototype.size;
});
assert_not_equals(new TransformStream(), null, 'constructor should work');
}, 'TransformStream constructor should not call setters for highWaterMark or size');
test(t => {
const oldReadableStream = ReadableStream;
const oldWritableStream = WritableStream;
const getReader = ReadableStream.prototype.getReader;
const getWriter = WritableStream.prototype.getWriter;
// Replace ReadableStream and WritableStream with broken versions.
ReadableStream = function () {
throw new Error('Called the global ReadableStream constructor');
};
WritableStream = function () {
throw new Error('Called the global WritableStream constructor');
};
t.add_cleanup(() => {
ReadableStream = oldReadableStream;
WritableStream = oldWritableStream;
});
const ts = new TransformStream();
// Just to be sure, ensure the readable and writable pass brand checks.
assert_not_equals(getReader.call(ts.readable), undefined,
'getReader should work when called on ts.readable');
assert_not_equals(getWriter.call(ts.writable), undefined,
'getWriter should work when called on ts.writable');
}, 'TransformStream should use the original value of ReadableStream and WritableStream');
|