Bug 1509773 [wpt PR 14228] - Add tests that subclassing {Transform,Writable}Stream works, a=testonly
authorBlink WPT Bot <blink-w3c-test-autoroller@chromium.org>
Fri, 30 Nov 2018 18:02:10 +0000
changeset 450014 06b31322e40b59526efd66541d8db408358655f7
parent 450013 c5a2229b7580be67f1c00ad9651867b993b12743
child 450015 d8c8e7d9c2b4c41a790b1660f3bfda3f4aa4f017
push id35189
push userccoroiu@mozilla.com
push dateTue, 11 Dec 2018 21:33:05 +0000
treeherdermozilla-central@ac7f3beb6333 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1509773, 14228
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1509773 [wpt PR 14228] - Add tests that subclassing {Transform,Writable}Stream works, a=testonly Automatic update from web-platform-tests Add tests that subclassing {Transform,Writable}Stream works (#14228) Change-Id: Iba151bf31367c06c94311402a9fc550d7bb87a6d -- wpt-commits: a994b494fa6f821a7fe390d07a72aa1b41e2d3e0 wpt-pr: 14228
testing/web-platform/tests/streams/transform-streams/general.any.js
testing/web-platform/tests/streams/writable-streams/general.any.js
--- a/testing/web-platform/tests/streams/transform-streams/general.any.js
+++ b/testing/web-platform/tests/streams/transform-streams/general.any.js
@@ -432,8 +432,32 @@ promise_test(() => {
 
 test(() => {
   assert_throws(new RangeError(), () => new TransformStream({ readableType: 'bytes' }), 'constructor should throw');
 }, 'specifying a defined readableType should throw');
 
 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');
--- a/testing/web-platform/tests/streams/writable-streams/general.any.js
+++ b/testing/web-platform/tests/streams/writable-streams/general.any.js
@@ -239,8 +239,32 @@ promise_test(() => {
       // Stop the writer promise hanging around after the test has finished.
       return Promise.all([
         writerPromise,
         ws.abort()
       ]);
     });
   });
 }, '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');