| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 assert_equals(value, undefined, 'writePromise should be fulfilled with u
ndefined'); | 89 assert_equals(value, undefined, 'writePromise should be fulfilled with u
ndefined'); |
| 90 }), | 90 }), |
| 91 writer.ready.then(value => { | 91 writer.ready.then(value => { |
| 92 assert_equals(resolveSinkWritePromise, undefined, 'sinkWritePromise shou
ld be fulfilled before writer.ready'); | 92 assert_equals(resolveSinkWritePromise, undefined, 'sinkWritePromise shou
ld be fulfilled before writer.ready'); |
| 93 assert_true(writePromiseResolved, 'writePromise should be fulfilled befo
re writer.ready'); | 93 assert_true(writePromiseResolved, 'writePromise should be fulfilled befo
re writer.ready'); |
| 94 | 94 |
| 95 assert_equals(writer.desiredSize, 1, 'desiredSize should be 1 again'); | 95 assert_equals(writer.desiredSize, 1, 'desiredSize should be 1 again'); |
| 96 | 96 |
| 97 assert_equals(value, undefined, 'writePromise should be fulfilled with u
ndefined'); | 97 assert_equals(value, undefined, 'writePromise should be fulfilled with u
ndefined'); |
| 98 }), | 98 }), |
| 99 delay(100).then(() => { | 99 flushAsyncEvents().then(() => { |
| 100 resolveSinkWritePromise(); | 100 resolveSinkWritePromise(); |
| 101 resolveSinkWritePromise = undefined; | 101 resolveSinkWritePromise = undefined; |
| 102 }) | 102 }) |
| 103 ]); | 103 ]); |
| 104 }); | 104 }); |
| 105 }, 'WritableStream should transition to waiting until write is acknowledged'); | 105 }, 'WritableStream should transition to waiting until write is acknowledged'); |
| 106 | 106 |
| 107 promise_test(t => { | 107 promise_test(t => { |
| 108 let sinkWritePromiseRejectors = []; | 108 let sinkWritePromiseRejectors = []; |
| 109 const ws = new WritableStream({ | 109 const ws = new WritableStream({ |
| (...skipping 25 matching lines...) Expand all Loading... |
| 135 return Promise.all([ | 135 return Promise.all([ |
| 136 promise_rejects(t, passedError, closedPromise, 'closedPromise should rejec
t with passedError') | 136 promise_rejects(t, passedError, closedPromise, 'closedPromise should rejec
t with passedError') |
| 137 .then(() => assert_equals(sinkWritePromiseRejectors.length, 0, | 137 .then(() => assert_equals(sinkWritePromiseRejectors.length, 0, |
| 138 'sinkWritePromise should reject before close
dPromise')), | 138 'sinkWritePromise should reject before close
dPromise')), |
| 139 promise_rejects(t, passedError, writePromise, 'writePromise should reject
with passedError') | 139 promise_rejects(t, passedError, writePromise, 'writePromise should reject
with passedError') |
| 140 .then(() => assert_equals(sinkWritePromiseRejectors.length, 0, | 140 .then(() => assert_equals(sinkWritePromiseRejectors.length, 0, |
| 141 'sinkWritePromise should reject before write
Promise')), | 141 'sinkWritePromise should reject before write
Promise')), |
| 142 promise_rejects(t, passedError, writePromise2, 'writePromise2 should rejec
t with passedError') | 142 promise_rejects(t, passedError, writePromise2, 'writePromise2 should rejec
t with passedError') |
| 143 .then(() => assert_equals(sinkWritePromiseRejectors.length, 0, | 143 .then(() => assert_equals(sinkWritePromiseRejectors.length, 0, |
| 144 'sinkWritePromise should reject before write
Promise2')), | 144 'sinkWritePromise should reject before write
Promise2')), |
| 145 delay(100).then(() => { | 145 flushAsyncEvents().then(() => { |
| 146 sinkWritePromiseRejectors[0](passedError); | 146 sinkWritePromiseRejectors[0](passedError); |
| 147 sinkWritePromiseRejectors = []; | 147 sinkWritePromiseRejectors = []; |
| 148 }) | 148 }) |
| 149 ]); | 149 ]); |
| 150 }); | 150 }); |
| 151 }, 'when write returns a rejected promise, queued writes and close should be cle
ared'); | 151 }, 'when write returns a rejected promise, queued writes and close should be cle
ared'); |
| 152 | 152 |
| 153 promise_test(t => { | 153 promise_test(t => { |
| 154 const thrownError = new Error('throw me'); | 154 const thrownError = new Error('throw me'); |
| 155 const ws = new WritableStream({ | 155 const ws = new WritableStream({ |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 writer.write('a'); | 187 writer.write('a'); |
| 188 } | 188 } |
| 189 const writePromise = writer.write('a'); | 189 const writePromise = writer.write('a'); |
| 190 | 190 |
| 191 assert_equals(writeCount, 1, 'should have called sink\'s write once'); | 191 assert_equals(writeCount, 1, 'should have called sink\'s write once'); |
| 192 | 192 |
| 193 resolveFirstWritePromise(); | 193 resolveFirstWritePromise(); |
| 194 | 194 |
| 195 return writePromise | 195 return writePromise |
| 196 .then(() => | 196 .then(() => |
| 197 assert_equals(writeCount, numberOfWrites, `should have called sink's w
rite ${numberOfWrites} times`)); | 197 assert_equals(writeCount, numberOfWrites, `should have called sink's wri
te ${numberOfWrites} times`)); |
| 198 }); | 198 }); |
| 199 }, 'a large queue of writes should be processed completely'); | 199 }, 'a large queue of writes should be processed completely'); |
| 200 | 200 |
| 201 promise_test(() => { | 201 promise_test(() => { |
| 202 const stream = recordingWritableStream(); | 202 const stream = recordingWritableStream(); |
| 203 const w = stream.getWriter(); | 203 const w = stream.getWriter(); |
| 204 const WritableStreamDefaultWriter = w.constructor; | 204 const WritableStreamDefaultWriter = w.constructor; |
| 205 w.releaseLock(); | 205 w.releaseLock(); |
| 206 const writer = new WritableStreamDefaultWriter(stream); | 206 const writer = new WritableStreamDefaultWriter(stream); |
| 207 return writer.ready.then(() => { | 207 return writer.ready.then(() => { |
| (...skipping 11 matching lines...) Expand all 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 |