Skip to content

Commit

Permalink
Add tests that subclassing {Transform,Writable}Stream works
Browse files Browse the repository at this point in the history
Change-Id: Iba151bf31367c06c94311402a9fc550d7bb87a6d
  • Loading branch information
ricea authored and chromium-wpt-export-bot committed Nov 26, 2018
1 parent 817ed89 commit 1245636
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
24 changes: 24 additions & 0 deletions streams/transform-streams/general.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,3 +437,27 @@ test(() => {
test(() => {
assert_throws(new RangeError(), () => new TransformStream({ writableType: 'bytes' }), 'constructor 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');
24 changes: 24 additions & 0 deletions streams/writable-streams/general.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,27 @@ promise_test(() => {
});
});
}, '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');

0 comments on commit 1245636

Please sign in to comment.