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 promise_test(() => { | 9 promise_test(() => { |
10 const ws = new WritableStream({ | 10 const ws = new WritableStream({ |
(...skipping 14 matching lines...) Expand all Loading... |
25 let controller; | 25 let controller; |
26 const ws = new WritableStream({ | 26 const ws = new WritableStream({ |
27 close(c) { | 27 close(c) { |
28 controller = c; | 28 controller = c; |
29 return delay(50); | 29 return delay(50); |
30 } | 30 } |
31 }); | 31 }); |
32 | 32 |
33 const writer = ws.getWriter(); | 33 const writer = ws.getWriter(); |
34 | 34 |
35 writer.close(); | |
36 | |
37 return Promise.all([ | 35 return Promise.all([ |
| 36 writer.close(), |
38 delay(10).then(() => controller.error(passedError)), | 37 delay(10).then(() => controller.error(passedError)), |
39 promise_rejects(t, passedError, writer.closed, | 38 promise_rejects(t, passedError, writer.closed, |
40 'closed promise should be rejected with the passed error'), | 39 'closed promise should be rejected with the passed error'), |
41 delay(70).then(() => promise_rejects(t, passedError, writer.closed, 'closed
should stay rejected')) | 40 delay(70).then(() => promise_rejects(t, passedError, writer.closed, 'closed
should stay rejected')) |
42 ]); | 41 ]); |
43 }, 'when sink calls error asynchronously while closing, the stream should become
errored'); | 42 }, 'when sink calls error asynchronously while closing, the stream should become
errored'); |
44 | 43 |
45 promise_test(t => { | 44 promise_test(t => { |
46 const passedError = new Error('error me'); | 45 const passedError = new Error('error me'); |
47 const ws = new WritableStream({ | 46 const ws = new WritableStream({ |
48 close(controller) { | 47 close(controller) { |
49 controller.error(passedError); | 48 controller.error(passedError); |
50 } | 49 } |
51 }); | 50 }); |
52 | 51 |
53 const writer = ws.getWriter(); | 52 const writer = ws.getWriter(); |
54 | 53 |
55 return promise_rejects(t, passedError, writer.close(), 'close promise should b
e rejected with the passed error') | 54 return writer.close().then(() => promise_rejects(t, passedError, writer.closed
, 'closed should stay rejected')); |
56 .then(() => promise_rejects(t, passedError, writer.closed, 'closed should
stay rejected')); | |
57 }, 'when sink calls error synchronously while closing, the stream should become
errored'); | 55 }, 'when sink calls error synchronously while closing, the stream should become
errored'); |
58 | 56 |
59 promise_test(() => { | 57 promise_test(() => { |
60 const ws = recordingWritableStream(); | 58 const ws = recordingWritableStream(); |
61 | 59 |
62 const writer = ws.getWriter(); | 60 const writer = ws.getWriter(); |
63 | 61 |
64 return writer.ready.then(() => { | 62 return writer.ready.then(() => { |
65 assert_equals(writer.desiredSize, 1, 'desiredSize should be 1'); | 63 assert_equals(writer.desiredSize, 1, 'desiredSize should be 1'); |
66 | 64 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 const ws = new WritableStream({ | 131 const ws = new WritableStream({ |
134 close() { | 132 close() { |
135 return { | 133 return { |
136 then(onFulfilled, onRejected) { onRejected(rejection); } | 134 then(onFulfilled, onRejected) { onRejected(rejection); } |
137 }; | 135 }; |
138 } | 136 } |
139 }); | 137 }); |
140 return promise_rejects(t, rejection, ws.getWriter().close(), 'close() should r
eturn a rejection'); | 138 return promise_rejects(t, rejection, ws.getWriter().close(), 'close() should r
eturn a rejection'); |
141 }, 'returning a thenable from close() should work'); | 139 }, 'returning a thenable from close() should work'); |
142 | 140 |
| 141 promise_test(t => { |
| 142 const ws = new WritableStream(); |
| 143 const writer = ws.getWriter(); |
| 144 return writer.ready.then(() => { |
| 145 const closePromise = writer.close(); |
| 146 const closedPromise = writer.closed; |
| 147 writer.releaseLock(); |
| 148 return Promise.all([ |
| 149 closePromise, |
| 150 promise_rejects(t, new TypeError(), closedPromise, '.closed promise should
be rejected') |
| 151 ]); |
| 152 }); |
| 153 }, 'releaseLock() should not change the result of sync close()'); |
| 154 |
| 155 promise_test(t => { |
| 156 const ws = new WritableStream({ |
| 157 close() { |
| 158 return flushAsyncEvents(); |
| 159 } |
| 160 }); |
| 161 const writer = ws.getWriter(); |
| 162 return writer.ready.then(() => { |
| 163 const closePromise = writer.close(); |
| 164 const closedPromise = writer.closed; |
| 165 writer.releaseLock(); |
| 166 return Promise.all([ |
| 167 closePromise, |
| 168 promise_rejects(t, new TypeError(), closedPromise, '.closed promise should
be rejected') |
| 169 ]); |
| 170 }); |
| 171 }, 'releaseLock() should not change the result of async close()'); |
| 172 |
143 done(); | 173 done(); |
OLD | NEW |