Commit ecfee12e authored by Adam Rice's avatar Adam Rice Committed by Commit Bot

Add tests that subclassing {Transform,Writable}Stream works

Change-Id: Iba151bf31367c06c94311402a9fc550d7bb87a6d
Reviewed-on: https://chromium-review.googlesource.com/c/1350550
Commit-Queue: Adam Rice <ricea@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610779}
parent f449fc78
...@@ -437,3 +437,27 @@ test(() => { ...@@ -437,3 +437,27 @@ test(() => {
test(() => { test(() => {
assert_throws(new RangeError(), () => new TransformStream({ writableType: 'bytes' }), 'constructor should throw'); assert_throws(new RangeError(), () => new TransformStream({ writableType: 'bytes' }), 'constructor should throw');
}, 'specifying a defined writableType should throw'); }, 'specifying a defined writableType should throw');
test(() => {
class Subclass extends TransformStream {
extraFunction() {
return true;
}
}
assert_equals(
Object.getPrototypeOf(Subclass.prototype), TransformStream.prototype,
'Subclass.prototype\'s prototype should be TransformStream.prototype');
assert_equals(Object.getPrototypeOf(Subclass), TransformStream,
'Subclass\'s prototype should be TransformStream');
const sub = new Subclass();
assert_true(sub instanceof TransformStream,
'Subclass object should be an instance of TransformStream');
assert_true(sub instanceof Subclass,
'Subclass object should be an instance of Subclass');
const readableGetter = Object.getOwnPropertyDescriptor(
TransformStream.prototype, 'readable').get;
assert_equals(readableGetter.call(sub), sub.readable,
'Subclass object should pass brand check');
assert_true(sub.extraFunction(),
'extraFunction() should be present on Subclass object');
}, 'Subclassing TransformStream should work');
...@@ -244,3 +244,27 @@ promise_test(() => { ...@@ -244,3 +244,27 @@ promise_test(() => {
}); });
}); });
}, 'ready promise should fire before closed on releaseLock'); }, 'ready promise should fire before closed on releaseLock');
test(() => {
class Subclass extends WritableStream {
extraFunction() {
return true;
}
}
assert_equals(
Object.getPrototypeOf(Subclass.prototype), WritableStream.prototype,
'Subclass.prototype\'s prototype should be WritableStream.prototype');
assert_equals(Object.getPrototypeOf(Subclass), WritableStream,
'Subclass\'s prototype should be WritableStream');
const sub = new Subclass();
assert_true(sub instanceof WritableStream,
'Subclass object should be an instance of WritableStream');
assert_true(sub instanceof Subclass,
'Subclass object should be an instance of Subclass');
const lockedGetter = Object.getOwnPropertyDescriptor(
WritableStream.prototype, 'locked').get;
assert_equals(lockedGetter.call(sub), sub.locked,
'Subclass object should pass brand check');
assert_true(sub.extraFunction(),
'extraFunction() should be present on Subclass object');
}, 'Subclassing WritableStream should work');
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment