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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 const closePromise = writer.close(); | 163 const closePromise = writer.close(); |
164 const closedPromise = writer.closed; | 164 const closedPromise = writer.closed; |
165 writer.releaseLock(); | 165 writer.releaseLock(); |
166 return Promise.all([ | 166 return Promise.all([ |
167 closePromise, | 167 closePromise, |
168 promise_rejects(t, new TypeError(), closedPromise, '.closed promise should
be rejected') | 168 promise_rejects(t, new TypeError(), closedPromise, '.closed promise should
be rejected') |
169 ]); | 169 ]); |
170 }); | 170 }); |
171 }, 'releaseLock() should not change the result of async close()'); | 171 }, 'releaseLock() should not change the result of async close()'); |
172 | 172 |
| 173 promise_test(() => { |
| 174 let resolveClose; |
| 175 const ws = new WritableStream({ |
| 176 close() { |
| 177 const promise = new Promise(resolve => { |
| 178 resolveClose = resolve; |
| 179 }); |
| 180 return promise; |
| 181 } |
| 182 }); |
| 183 const writer = ws.getWriter(); |
| 184 const closePromise = writer.close(); |
| 185 writer.releaseLock(); |
| 186 return delay(0).then(() => { |
| 187 resolveClose(); |
| 188 return closePromise.then(() => { |
| 189 assert_equals(ws.getWriter().desiredSize, 0, 'desiredSize should be 0'); |
| 190 }); |
| 191 }); |
| 192 }, 'close() should set state to CLOSED even if writer has detached'); |
| 193 |
| 194 promise_test(() => { |
| 195 let resolveClose; |
| 196 const ws = new WritableStream({ |
| 197 close() { |
| 198 const promise = new Promise(resolve => { |
| 199 resolveClose = resolve; |
| 200 }); |
| 201 return promise; |
| 202 } |
| 203 }); |
| 204 const writer = ws.getWriter(); |
| 205 writer.close(); |
| 206 writer.releaseLock(); |
| 207 return delay(0).then(() => { |
| 208 const abortingWriter = ws.getWriter(); |
| 209 const abortPromise = abortingWriter.abort(); |
| 210 abortingWriter.releaseLock(); |
| 211 resolveClose(); |
| 212 return abortPromise; |
| 213 }); |
| 214 }, 'the promise returned by async abort during close should resolve'); |
| 215 |
173 done(); | 216 done(); |
OLD | NEW |