OLD | NEW |
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 if (self.importScripts) { | 3 if (self.importScripts) { |
4 self.importScripts('/resources/testharness.js'); | 4 self.importScripts('/resources/testharness.js'); |
5 self.importScripts('../resources/test-utils.js'); | 5 self.importScripts('../resources/test-utils.js'); |
6 self.importScripts('../resources/recording-streams.js'); | 6 self.importScripts('../resources/recording-streams.js'); |
7 } | 7 } |
8 | 8 |
9 function writeArrayToStream(array, writableStreamWriter) { | 9 function writeArrayToStream(array, writableStreamWriter) { |
10 array.forEach(chunk => writableStreamWriter.write(chunk)); | 10 array.forEach(chunk => writableStreamWriter.write(chunk)); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 158 } |
159 }); | 159 }); |
160 | 160 |
161 const writer = ws.getWriter(); | 161 const writer = ws.getWriter(); |
162 | 162 |
163 return promise_rejects(t, thrownError, writer.write('a'), 'write() should reje
ct with thrownError') | 163 return promise_rejects(t, thrownError, writer.write('a'), 'write() should reje
ct with thrownError') |
164 .then(() => promise_rejects(t, new TypeError(), writer.close(), 'close() s
hould be rejected')); | 164 .then(() => promise_rejects(t, new TypeError(), writer.close(), 'close() s
hould be rejected')); |
165 }, 'when sink\'s write throws an error, the stream should become errored and the
promise should reject'); | 165 }, 'when sink\'s write throws an error, the stream should become errored and the
promise should reject'); |
166 | 166 |
167 promise_test(() => { | 167 promise_test(() => { |
168 const numberOfWrites = 10000; | 168 const numberOfWrites = 1000; |
169 | 169 |
170 let resolveFirstWritePromise; | 170 let resolveFirstWritePromise; |
171 let writeCount = 0; | 171 let writeCount = 0; |
172 const ws = new WritableStream({ | 172 const ws = new WritableStream({ |
173 write() { | 173 write() { |
174 ++writeCount; | 174 ++writeCount; |
175 if (!resolveFirstWritePromise) { | 175 if (!resolveFirstWritePromise) { |
176 return new Promise(resolve => { | 176 return new Promise(resolve => { |
177 resolveFirstWritePromise = resolve; | 177 resolveFirstWritePromise = resolve; |
178 }); | 178 }); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 thenCalled = true; | 219 thenCalled = true; |
220 onFulfilled(); | 220 onFulfilled(); |
221 } | 221 } |
222 }; | 222 }; |
223 } | 223 } |
224 }); | 224 }); |
225 return ws.getWriter().write('a').then(() => assert_true(thenCalled, 'thenCalle
d should be true')); | 225 return ws.getWriter().write('a').then(() => assert_true(thenCalled, 'thenCalle
d should be true')); |
226 }, 'returning a thenable from write() should work'); | 226 }, 'returning a thenable from write() should work'); |
227 | 227 |
228 done(); | 228 done(); |
OLD | NEW |