| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 assert_equals(writer.desiredSize, 0, 'desiredSize should be 0'); | 89 assert_equals(writer.desiredSize, 0, 'desiredSize should be 0'); |
| 90 | 90 |
| 91 let calledClose = false; | 91 let calledClose = false; |
| 92 return Promise.all([ | 92 return Promise.all([ |
| 93 writer.ready.then(v => { | 93 writer.ready.then(v => { |
| 94 assert_equals(v, undefined, 'ready promise should be fulfilled with unde
fined'); | 94 assert_equals(v, undefined, 'ready promise should be fulfilled with unde
fined'); |
| 95 assert_true(calledClose, 'ready should not be fulfilled before writer.cl
ose() is called'); | 95 assert_true(calledClose, 'ready should not be fulfilled before writer.cl
ose() is called'); |
| 96 assert_array_equals(ws.events, ['write', 'a'], 'sink abort() should not
be called'); | 96 assert_array_equals(ws.events, ['write', 'a'], 'sink abort() should not
be called'); |
| 97 }), | 97 }), |
| 98 delay(100).then(() => { | 98 flushAsyncEvents().then(() => { |
| 99 writer.close(); | 99 writer.close(); |
| 100 calledClose = true; | 100 calledClose = true; |
| 101 }) | 101 }) |
| 102 ]); | 102 ]); |
| 103 }); | 103 }); |
| 104 }, 'when close is called on a WritableStream in waiting state, ready promise sho
uld be fulfilled'); | 104 }, 'when close is called on a WritableStream in waiting state, ready promise sho
uld be fulfilled'); |
| 105 | 105 |
| 106 promise_test(() => { | 106 promise_test(() => { |
| 107 let asyncCloseFinished = false; | 107 let asyncCloseFinished = false; |
| 108 const ws = recordingWritableStream({ | 108 const ws = recordingWritableStream({ |
| 109 close() { | 109 close() { |
| 110 return delay(50).then(() => { | 110 return flushAsyncEvents().then(() => { |
| 111 asyncCloseFinished = true; | 111 asyncCloseFinished = true; |
| 112 }); | 112 }); |
| 113 } | 113 } |
| 114 }); | 114 }); |
| 115 | 115 |
| 116 const writer = ws.getWriter(); | 116 const writer = ws.getWriter(); |
| 117 return writer.ready.then(() => { | 117 return writer.ready.then(() => { |
| 118 writer.write('a'); | 118 writer.write('a'); |
| 119 | 119 |
| 120 writer.close(); | 120 writer.close(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 134 close() { | 134 close() { |
| 135 return { | 135 return { |
| 136 then(onFulfilled, onRejected) { onRejected(rejection); } | 136 then(onFulfilled, onRejected) { onRejected(rejection); } |
| 137 }; | 137 }; |
| 138 } | 138 } |
| 139 }); | 139 }); |
| 140 return promise_rejects(t, rejection, ws.getWriter().close(), 'close() should r
eturn a rejection'); | 140 return promise_rejects(t, rejection, ws.getWriter().close(), 'close() should r
eturn a rejection'); |
| 141 }, 'returning a thenable from close() should work'); | 141 }, 'returning a thenable from close() should work'); |
| 142 | 142 |
| 143 done(); | 143 done(); |
| OLD | NEW |