Streams tests try to call ReadableStream.prototype.pipeThrough.call generically
https://bugs.webkit.org/show_bug.cgi?id=235560

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2022-01-26
Reviewed by Youenn Fablet.

ReadableStream methods are nowadays defined to accept only ReadableStream instances.
Tests sometimes assert that an exception is thrown. However, the exception being actually thrown is different.
Future testharness.js will check the exception and the test will fail.

* TestExpectations:
* platform/win/TestExpectations:
* streams/brand-checks-expected.txt: Removed.
* streams/brand-checks.html: Removed.
* streams/readable-stream-pipeThrough-expected.txt: Removed.
* streams/readable-stream-pipeThrough.html: Removed.
* streams/reference-implementation/brand-checks-expected.txt: Removed.
* streams/reference-implementation/brand-checks.html: Removed.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@288611 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index efe65d11..b09bad5 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,23 @@
+2022-01-26  Kimmo Kinnunen  <kkinnunen@apple.com>
+
+        Streams tests try to call ReadableStream.prototype.pipeThrough.call generically
+        https://bugs.webkit.org/show_bug.cgi?id=235560
+
+        Reviewed by Youenn Fablet.
+
+        ReadableStream methods are nowadays defined to accept only ReadableStream instances.
+        Tests sometimes assert that an exception is thrown. However, the exception being actually thrown is different.
+        Future testharness.js will check the exception and the test will fail.
+
+        * TestExpectations:
+        * platform/win/TestExpectations:
+        * streams/brand-checks-expected.txt: Removed.
+        * streams/brand-checks.html: Removed.
+        * streams/readable-stream-pipeThrough-expected.txt: Removed.
+        * streams/readable-stream-pipeThrough.html: Removed.
+        * streams/reference-implementation/brand-checks-expected.txt: Removed.
+        * streams/reference-implementation/brand-checks.html: Removed.
+
 2022-01-25  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         [WinCairo] Unreviewed test gardening
diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations
index 8a2e7ee..eda57a7 100644
--- a/LayoutTests/TestExpectations
+++ b/LayoutTests/TestExpectations
@@ -1530,7 +1530,6 @@
 http/tests/loading/text-content-type-with-binary-extension.html [ Pass Failure ]
 
 # Tests that are flakey due to unhandled promise rejection error messages
-webkit.org/b/171094 streams/brand-checks.html [ Pass Failure ]
 webkit.org/b/171094 streams/reference-implementation/abstract-ops.html [ Pass Failure ]
 
 # WPT tests that fail after doing full test repository reimport and need further investigation
diff --git a/LayoutTests/platform/win/TestExpectations b/LayoutTests/platform/win/TestExpectations
index 1399de8..a2e9f50 100644
--- a/LayoutTests/platform/win/TestExpectations
+++ b/LayoutTests/platform/win/TestExpectations
@@ -3545,7 +3545,6 @@
 streams/readable-stream-byob-request-worker.html [ Failure ]
 streams/reference-implementation/bad-strategies.html [ Failure ]
 streams/reference-implementation/bad-underlying-sinks.html [ Failure ]
-streams/reference-implementation/brand-checks.html [ Failure ]
 streams/reference-implementation/byte-length-queuing-strategy.html [ Failure ]
 streams/reference-implementation/count-queuing-strategy.html [ Failure ]
 streams/reference-implementation/readable-stream-templated.html [ Failure ]
diff --git a/LayoutTests/streams/brand-checks-expected.txt b/LayoutTests/streams/brand-checks-expected.txt
deleted file mode 100644
index 0c87de9..0000000
--- a/LayoutTests/streams/brand-checks-expected.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-
-PASS ReadableStream.prototype.pipeThrough works generically on its this and its arguments
-PASS ReadableStream.prototype.pipeTo works generically on its this and its arguments
-PASS ByteLengthQueuingStrategy.prototype.size should work generically on its this and its arguments
-PASS CountQueuingStrategy.prototype.size should work generically on its this and its arguments
-
diff --git a/LayoutTests/streams/brand-checks.html b/LayoutTests/streams/brand-checks.html
deleted file mode 100644
index 6b2289b..0000000
--- a/LayoutTests/streams/brand-checks.html
+++ /dev/null
@@ -1,77 +0,0 @@
-<!DOCTYPE html>
-<script src='../resources/testharness.js'></script>
-<script src='../resources/testharnessreport.js'></script>
-<script src='reference-implementation/resources/streams-utils.js'></script>
-<script>
-// This is updated till https://github.com/whatwg/streams/commit/4ba861e6f60c248060811830e11271c84b439cc3
-
-let ReadableStreamDefaultReader = (new ReadableStream()).getReader().constructor;
-
-function fakeWritableStream() {
-  return {
-    get closed() { return Promise.resolve(); },
-    get ready() { return Promise.resolve(); },
-    get state() { return 'closed' },
-    abort(reason) { return Promise.resolve(); },
-    close() { return Promise.resolve(); },
-    write(chunk) { return Promise.resolve(); }
-  };
-}
-
-function realReadableStream() {
-    return new ReadableStream();
-}
-
-function fakeReadableStream() {
-    return {
-        cancel: function(reason) { return Promise.resolve(); },
-        getReader: function() { return new ReadableStreamDefaultReader(new ReadableStream()); },
-        pipeThrough: function(obj, options) { return obj.readable; },
-        pipeTo: function() { return Promise.resolve(); },
-        tee: function() { return [realReadableStream(), realReadableStream()]; }
-    };
-}
-
-test(function() {
-    var pipeToArguments;
-    var thisValue = {
-        pipeTo: function() {
-            pipeToArguments = arguments;
-        }
-    };
-
-    var input = { readable: {}, writable: {} };
-    var options = {};
-    var result = ReadableStream.prototype.pipeThrough.call(thisValue, input, options);
-
-    assert_array_equals(pipeToArguments, [input.writable, options], 'correct arguments should be passed to thisValue.pipeTo');
-    assert_equals(result, input.readable, 'return value should be the passed readable property');
-}, 'ReadableStream.prototype.pipeThrough works generically on its this and its arguments');
-
-test(function() {
-    ReadableStream.prototype.pipeTo.call(fakeReadableStream(), fakeWritableStream()); // Check it does not throw.
-}, 'ReadableStream.prototype.pipeTo works generically on its this and its arguments');
-
-test(function() {
-    var thisValue = null;
-    var returnValue = { 'returned from': 'byteLength getter' };
-    var chunk = {
-        get byteLength() {
-            return returnValue;
-        }
-    };
-
-    assert_equals(ByteLengthQueuingStrategy.prototype.size.call(thisValue, chunk), returnValue);
-}, 'ByteLengthQueuingStrategy.prototype.size should work generically on its this and its arguments');
-
-test(function() {
-    var thisValue = null;
-    var chunk = {
-        get byteLength() {
-            throw new TypeError('shouldn\'t be called');
-        }
-    };
-
-    assert_equals(CountQueuingStrategy.prototype.size.call(thisValue, chunk), 1);
-}, 'CountQueuingStrategy.prototype.size should work generically on its this and its arguments');
-</script>
diff --git a/LayoutTests/streams/readable-stream-pipeThrough-expected.txt b/LayoutTests/streams/readable-stream-pipeThrough-expected.txt
deleted file mode 100644
index 52614ca..0000000
--- a/LayoutTests/streams/readable-stream-pipeThrough-expected.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-
-PASS ReadableStream.prototype.pipeThrough should throw when "this" has no pipeTo method
-PASS ReadableStream.prototype.pipeThrough should throw when passed argument is not an object
-PASS ReadableStream.prototype.pipeThrough should throw when called getters are throwing
-
diff --git a/LayoutTests/streams/readable-stream-pipeThrough.html b/LayoutTests/streams/readable-stream-pipeThrough.html
deleted file mode 100644
index 4fddb57..0000000
--- a/LayoutTests/streams/readable-stream-pipeThrough.html
+++ /dev/null
@@ -1,67 +0,0 @@
-<!DOCTYPE html>
-<script src='../resources/testharness.js'></script>
-<script src='../resources/testharnessreport.js'></script>
-<script src='../resources/gc.js'></script>
-<script>
-// This is updated till https://github.com/whatwg/streams/commit/4ba861e6f60c248060811830e11271c84b439cc3
-
-test(function() {
-    var input = {
-        readable: { },
-        writable: { }
-    };
-    var options = { };
-    assert_throws(new TypeError(), function() { ReadableStream.prototype.pipeThrough.call(undefined, input, options); });
-    assert_throws(new TypeError(), function() { ReadableStream.prototype.pipeThrough.call(null, input, options); });
-    assert_throws(new TypeError(), function() { ReadableStream.prototype.pipeThrough.call(1, input, options); });
-    assert_throws(new TypeError(), function() { ReadableStream.prototype.pipeThrough.call({ "pipeTo": "test" }, input, options); });
-}, 'ReadableStream.prototype.pipeThrough should throw when "this" has no pipeTo method');
-
-test(function() {
-    var options = { };
-    var thisValue = {
-        pipeTo: function() {
-            assert_unreached();
-        }
-    };
-
-    assert_throws(new TypeError(), function() { ReadableStream.prototype.pipeThrough.call(thisValue, null, options); });
-    assert_throws(new TypeError(), function() { ReadableStream.prototype.pipeThrough.call(thisValue, undefined, options); });
-}, 'ReadableStream.prototype.pipeThrough should throw when passed argument is not an object');
-
-test(function() {
-    var options = { };
-    var error = new TypeError("potato");
-
-    var thisWrongValue = {
-        get pipeTo() {
-            throw error;
-        }
-    };
-    assert_throws(error, function() { ReadableStream.prototype.pipeThrough.call(thisWrongValue, { readable: { }, writable: { } }, options); });
-
-    var thisValue = {
-        pipeTo: function() {
-            assert_unreached();
-        }
-    };
-    var wrongInput = {
-        readable: { },
-        get writable() {
-            throw error;
-        }
-    };
-    assert_throws(error, function() { ReadableStream.prototype.pipeThrough.call(thisValue, wrongInput, options); });
-
-    var wrongInput2 = {
-        get readable() {
-            throw error;
-        },
-        writable: { }
-    };
-    var thisValue2 = {
-        pipeTo: function() { }
-    };
-    assert_throws(error, function() { ReadableStream.prototype.pipeThrough.call(thisValue2, wrongInput2, options); });
-}, 'ReadableStream.prototype.pipeThrough should throw when called getters are throwing');
-</script>
diff --git a/LayoutTests/streams/reference-implementation/brand-checks-expected.txt b/LayoutTests/streams/reference-implementation/brand-checks-expected.txt
deleted file mode 100644
index 43003bd..0000000
--- a/LayoutTests/streams/reference-implementation/brand-checks-expected.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-
-FAIL WritableStream.prototype.closed enforces a brand check undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(obj, getterName).get')
-FAIL WritableStream.prototype.ready enforces a brand check undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(obj, getterName).get')
-FAIL WritableStream.prototype.state enforces a brand check undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(obj, getterName).get')
-PASS WritableStream.prototype.abort enforces a brand check
-FAIL WritableStream.prototype.write enforces a brand check undefined is not an object (evaluating 'method.call')
-PASS WritableStream.prototype.close enforces a brand check
-
diff --git a/LayoutTests/streams/reference-implementation/brand-checks.html b/LayoutTests/streams/reference-implementation/brand-checks.html
deleted file mode 100644
index 1243994..0000000
--- a/LayoutTests/streams/reference-implementation/brand-checks.html
+++ /dev/null
@@ -1,89 +0,0 @@
-<!DOCTYPE html>
-<script src='../../resources/testharness.js'></script>
-<script src='../../resources/testharnessreport.js'></script>
-<script src='resources/streams-utils.js'></script>
-<script>
-// This is updated till https://github.com/whatwg/streams/commit/4ba861e6f60c248060811830e11271c84b439cc3
-
-function fakeWritableStream() {
-  return {
-    get closed() { return Promise.resolve(); },
-    get ready() { return Promise.resolve(); },
-    get state() { return 'closed' },
-    abort(reason) { return Promise.resolve(); },
-    close() { return Promise.resolve(); },
-    write(chunk) { return Promise.resolve(); }
-  };
-}
-
-function realReadableStream() {
-    return new ReadableStream();
-}
-
-function getterRejects(test, obj, getterName, target, endTest) {
-    var getter = Object.getOwnPropertyDescriptor(obj, getterName).get;
-
-    getter.call(target).then(
-        test.step_func(function() { assert_unreached(getterName + ' should not fulfill'); }),
-        test.step_func(function(e) {
-            assert_throws(new TypeError(), function() { throw e; }, getterName + ' should reject with a TypeError');
-            if (endTest === true) {
-                test.done();
-            }
-        }));
-}
-
-function methodRejects(test, obj, methodName, target, endTest) {
-    var method = obj[methodName];
-
-    method.call(target).then(
-        test.step_func(function() { assert_unreached(methodName + ' should not fulfill'); }),
-        test.step_func(function(e) {
-            assert_throws(new TypeError(), function() { throw e; }, methodName + ' should reject with a TypeError');
-            if (endTest === true) {
-                test.done();
-            }
-        }));
-}
-
-function getterThrows(obj, getterName, target) {
-  var getter = Object.getOwnPropertyDescriptor(obj, getterName).get;
-
-    assert_throws(new TypeError(), function() { getter.call(target); }, getterName + ' should throw a TypeError');
-}
-
-var test1 = async_test('WritableStream.prototype.closed enforces a brand check');
-test1.step(function() {
-    getterRejects(test1, WritableStream.prototype, 'closed', fakeWritableStream());
-    getterRejects(test1, WritableStream.prototype, 'closed', realReadableStream(), true);
-});
-
-var test2 = async_test('WritableStream.prototype.ready enforces a brand check');
-test2.step(function() {
-    getterRejects(test2, WritableStream.prototype, 'ready', fakeWritableStream());
-    getterRejects(test2, WritableStream.prototype, 'ready', realReadableStream(), true);
-});
-
-test(function() {
-    getterThrows(WritableStream.prototype, 'state', fakeWritableStream());
-    getterThrows(WritableStream.prototype, 'state', realReadableStream());
-}, 'WritableStream.prototype.state enforces a brand check');
-
-var test3 = async_test('WritableStream.prototype.abort enforces a brand check');
-test3.step(function() {
-    methodRejects(test3, WritableStream.prototype, 'abort', fakeWritableStream());
-    methodRejects(test3, WritableStream.prototype, 'abort', realReadableStream(), true);
-});
-
-var test4 = async_test('WritableStream.prototype.write enforces a brand check');
-test4.step(function() {
-    methodRejects(test4, WritableStream.prototype, 'write', fakeWritableStream());
-    methodRejects(test4, WritableStream.prototype, 'write', realReadableStream(), true);
-});
-
-var test5 = async_test('WritableStream.prototype.close enforces a brand check');
-test5.step(function() {
-    methodRejects(test5, WritableStream.prototype, 'close', fakeWritableStream());
-    methodRejects(test5, WritableStream.prototype, 'close', realReadableStream(), true);
-});
-</script>