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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/streams/piping/multiple-propagation.js

Issue 2823563002: Unified error handling for WritableStream (Closed)
Patch Set: remove local copy of piping/multiple-propagation test as it is fail Created 3 years, 8 months 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/testharness.js');
5 self.importScripts('../resources/test-utils.js');
6 self.importScripts('../resources/recording-streams.js');
7 }
8
9 const error1 = new Error('error1!');
10 error1.name = 'error1';
11
12 const error2 = new Error('error2!');
13 error2.name = 'error2';
14
15 promise_test(t => {
16 const rs = recordingReadableStream({
17 start(c) {
18 c.error(error1);
19 }
20 });
21 const ws = recordingWritableStream({
22 start(c) {
23 c.error(error2);
24 }
25 });
26
27 // Trying to abort a stream that was errored will give that error back
28 return promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the writable stream\'s error').then(() => {
29 assert_array_equals(rs.events, []);
30 assert_array_equals(ws.events, []);
31
32 return Promise.all([
33 promise_rejects(t, error1, rs.getReader().closed, 'the readable stream mus t be errored with error1'),
34 promise_rejects(t, error2, ws.getWriter().closed, 'the writable stream mus t be errored with error2')
35 ]);
36 });
37
38 }, 'Piping from an errored readable stream to an errored writable stream');
39
40 promise_test(t => {
41 const rs = recordingReadableStream({
42 start(c) {
43 c.error(error1);
44 }
45 });
46 const ws = recordingWritableStream({
47 start(c) {
48 c.error(error2);
49 }
50 });
51
52 return promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true }),
53 'pipeTo must reject with the readable stream\'s error')
54 .then(() => {
55 assert_array_equals(rs.events, []);
56 assert_array_equals(ws.events, []);
57
58 return Promise.all([
59 promise_rejects(t, error1, rs.getReader().closed, 'the readable stream mus t be errored with error1'),
60 promise_rejects(t, error2, ws.getWriter().closed, 'the writable stream mus t be errored with error2')
61 ]);
62 });
63
64 }, 'Piping from an errored readable stream to an errored writable stream; preven tAbort = true');
65
66 // TODO(ricea): Revert to the upstream version of this test once https://github. com/whatwg/streams/pull/634 is
67 // resolved and WritableStream.js has been updated to match.
68 promise_test(t => {
69 const rs = recordingReadableStream({
70 start(c) {
71 c.error(error1);
72 }
73 });
74 const ws = recordingWritableStream();
75 const writer = ws.getWriter();
76 const closePromise = writer.close();
77 writer.releaseLock();
78
79 return promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the readable stream\'s error').then(() => {
80 assert_array_equals(rs.events, []);
81 assert_array_equals(ws.events, ['abort', error1], 'ws.events should contain abort for the time being');
82
83 return Promise.all([
84 promise_rejects(t, error1, rs.getReader().closed, 'the readable stream mus t be errored with error1'),
85 promise_rejects(t, new TypeError(), ws.getWriter().closed, 'the writable s tream should be errored for the time being'),
86 promise_rejects(t, new TypeError(), closePromise, 'close() should reject f or the time being')
87 ]);
88 });
89
90 }, 'Piping from an errored readable stream to a closed writable stream');
91
92 promise_test(t => {
93 const rs = recordingReadableStream({
94 start(c) {
95 c.close();
96 }
97 });
98 const ws = recordingWritableStream({
99 start(c) {
100 c.error(error1);
101 }
102 });
103
104 return promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the writable stream\'s error').then(() => {
105 assert_array_equals(rs.events, []);
106 assert_array_equals(ws.events, []);
107
108 return Promise.all([
109 rs.getReader().closed,
110 promise_rejects(t, error1, ws.getWriter().closed, 'the writable stream mus t be errored with error1')
111 ]);
112 });
113
114 }, 'Piping from a closed readable stream to an errored writable stream');
115
116 promise_test(() => {
117 const rs = recordingReadableStream({
118 start(c) {
119 c.close();
120 }
121 });
122 const ws = recordingWritableStream();
123 const writer = ws.getWriter();
124 writer.close();
125 writer.releaseLock();
126
127 return rs.pipeTo(ws).then(() => {
128 assert_array_equals(rs.events, []);
129 assert_array_equals(ws.events, ['close']);
130
131 return Promise.all([
132 rs.getReader().closed,
133 ws.getWriter().closed
134 ]);
135 });
136
137 }, 'Piping from a closed readable stream to a closed writable stream');
138
139 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698