Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1121)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/streams/readable-streams/pipe-through.js

Issue 2495873002: Manually import wpt@359815a0ff565cb6ca89349f6e9e154789267d8b (Closed)
Patch Set: Add Crash/Timeout expectation for bitmaprenderer-as-imagesource.html Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 'use strict';
2
3 if (self.importScripts) {
4 self.importScripts('../resources/test-utils.js');
5 self.importScripts('/resources/testharness.js');
6 }
7
8 test(() => {
9
10 let pipeToArguments;
11 const thisValue = {
12 pipeTo() {
13 pipeToArguments = arguments;
14 }
15 };
16
17 const input = { readable: {}, writable: {} };
18 const options = {};
19 const result = ReadableStream.prototype.pipeThrough.call(thisValue, input, opt ions);
20
21 assert_array_equals(pipeToArguments, [input.writable, options],
22 'correct arguments should be passed to thisValue.pipeTo');
23 assert_equals(result, input.readable, 'return value should be the passed reada ble property');
24
25 }, 'ReadableStream.prototype.pipeThrough should work generically on its this and its arguments');
26
27 test(() => {
28
29 const thisValue = {
30 pipeTo() {
31 assert_unreached('pipeTo should not be called');
32 }
33 };
34
35 methodThrows(ReadableStream.prototype, 'pipeThrough', thisValue, [undefined, { }]);
36 methodThrows(ReadableStream.prototype, 'pipeThrough', thisValue, [null, {}]);
37
38 }, 'ReadableStream.prototype.pipeThrough should throw when its first argument is not convertible to an object');
39
40 test(() => {
41
42 const args = [{ readable: {}, writable: {} }, {}];
43
44 methodThrows(ReadableStream.prototype, 'pipeThrough', undefined, args);
45 methodThrows(ReadableStream.prototype, 'pipeThrough', null, args);
46 methodThrows(ReadableStream.prototype, 'pipeThrough', 1, args);
47 methodThrows(ReadableStream.prototype, 'pipeThrough', { pipeTo: 'test' }, args );
48
49 }, 'ReadableStream.prototype.pipeThrough should throw when "this" has no pipeTo method');
50
51 test(() => {
52 const error = new Error('potato');
53
54 const throwingPipeTo = {
55 get pipeTo() {
56 throw error;
57 }
58 };
59 assert_throws(error,
60 () => ReadableStream.prototype.pipeThrough.call(throwingPipeTo, { readable: { }, writable: { } }, {}),
61 'pipeThrough should rethrow the error thrown by pipeTo');
62
63 const thisValue = {
64 pipeTo() {
65 assert_unreached('pipeTo should not be called');
66 }
67 };
68
69 const throwingWritable = {
70 readable: {},
71 get writable() {
72 throw error;
73 }
74 };
75 assert_throws(error,
76 () => ReadableStream.prototype.pipeThrough.call(thisValue, throwingWritable, {}),
77 'pipeThrough should rethrow the error thrown by the writable getter');
78
79 const throwingReadable = {
80 get readable() {
81 throw error;
82 },
83 writable: {}
84 };
85 assert_throws(error,
86 () => ReadableStream.prototype.pipeThrough.call(thisValue, throwingReadable, {}),
87 'pipeThrough should rethrow the error thrown by the readable getter');
88
89 }, 'ReadableStream.prototype.pipeThrough should rethrow errors from accessing pi peTo, readable, or writable');
90
91 test(() => {
92
93 let count = 0;
94 const thisValue = {
95 pipeTo() {
96 ++count;
97 }
98 };
99
100 ReadableStream.prototype.pipeThrough.call(thisValue, { readable: {}, writable: {} });
101 ReadableStream.prototype.pipeThrough.call(thisValue, { readable: {} }, {});
102 ReadableStream.prototype.pipeThrough.call(thisValue, { writable: {} }, {});
103
104 assert_equals(count, 3, 'pipeTo was called 3 times');
105
106 }, 'ReadableStream.prototype.pipeThrough should work with missing readable, writ able, or options');
107
108 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698