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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/streams/piping/multiple-propagation.js

Issue 2642393002: Import wpt@40665266227e475bc4a56884247d8c09d78dfb6a (Closed)
Patch Set: rebaseline-cl Created 3 years, 11 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 promise_test(t => {
67 const rs = recordingReadableStream({
68 start(c) {
69 c.error(error1);
70 }
71 });
72 const ws = recordingWritableStream();
73 const writer = ws.getWriter();
74 writer.close();
75 writer.releaseLock();
76
77 return promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the readable stream\'s error').then(() => {
78 assert_array_equals(rs.events, []);
79 assert_array_equals(ws.events, ['close']);
80
81 return Promise.all([
82 promise_rejects(t, error1, rs.getReader().closed, 'the readable stream mus t be errored with error1'),
83 ws.getWriter().closed
84 ]);
85 });
86
87 }, 'Piping from an errored readable stream to a closed writable stream');
88
89 promise_test(t => {
90 const rs = recordingReadableStream({
91 start(c) {
92 c.close();
93 }
94 });
95 const ws = recordingWritableStream({
96 start(c) {
97 c.error(error1);
98 }
99 });
100
101 return promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the writable stream\'s error').then(() => {
102 assert_array_equals(rs.events, []);
103 assert_array_equals(ws.events, []);
104
105 return Promise.all([
106 rs.getReader().closed,
107 promise_rejects(t, error1, ws.getWriter().closed, 'the writable stream mus t be errored with error1')
108 ]);
109 });
110
111 }, 'Piping from a closed readable stream to an errored writable stream');
112
113 promise_test(() => {
114 const rs = recordingReadableStream({
115 start(c) {
116 c.close();
117 }
118 });
119 const ws = recordingWritableStream();
120 const writer = ws.getWriter();
121 writer.close();
122 writer.releaseLock();
123
124 return rs.pipeTo(ws).then(() => {
125 assert_array_equals(rs.events, []);
126 assert_array_equals(ws.events, ['close']);
127
128 return Promise.all([
129 rs.getReader().closed,
130 ws.getWriter().closed
131 ]);
132 });
133
134 }, 'Piping from a closed readable stream to a closed writable stream');
135
136 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698