| 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 } | 5 } |
| 6 | 6 |
| 7 test(() => { | 7 test(() => { |
| 8 | 8 |
| 9 const theError = new Error('a unique string'); | 9 const theError = new Error('a unique string'); |
| 10 | 10 |
| 11 assert_throws(theError, () => { | 11 assert_throws(theError, () => { |
| 12 new ReadableStream({}, { | 12 new ReadableStream({}, { |
| 13 get size() { | 13 get size() { |
| 14 throw theError; | 14 throw theError; |
| 15 }, | 15 }, |
| 16 highWaterMark: 5 | 16 highWaterMark: 5 |
| 17 }); | 17 }); |
| 18 }, 'construction should re-throw the error'); | 18 }, 'construction should re-throw the error'); |
| 19 | 19 |
| 20 }, 'Readable stream: throwing strategy.size getter'); | 20 }, 'Readable stream: throwing strategy.size getter'); |
| 21 | 21 |
| 22 test(() => { | 22 promise_test(t => { |
| 23 | 23 |
| 24 const theError = new Error('a unique string'); | 24 const controllerError = { name: 'controller error' }; |
| 25 const thrownError = { name: 'thrown error' }; |
| 25 | 26 |
| 26 let controller; | 27 let controller; |
| 27 const rs = new ReadableStream( | 28 const rs = new ReadableStream( |
| 28 { | 29 { |
| 29 start(c) { | 30 start(c) { |
| 30 controller = c; | 31 controller = c; |
| 31 } | 32 } |
| 32 }, | 33 }, |
| 33 { | 34 { |
| 34 size() { | 35 size() { |
| 35 controller.error(theError); | 36 controller.error(controllerError); |
| 36 throw theError; | 37 throw thrownError; |
| 37 }, | 38 }, |
| 38 highWaterMark: 5 | 39 highWaterMark: 5 |
| 39 } | 40 } |
| 40 ); | 41 ); |
| 41 | 42 |
| 42 assert_throws(theError, () => { | 43 assert_throws(thrownError, () => controller.enqueue('a'), 'enqueue should re-t
hrow the error'); |
| 43 controller.enqueue('a'); | 44 |
| 44 }, 'enqueue should re-throw the error'); | 45 return promise_rejects(t, controllerError, rs.getReader().closed); |
| 45 | 46 |
| 46 }, 'Readable stream: strategy.size errors the stream and then throws'); | 47 }, 'Readable stream: strategy.size errors the stream and then throws'); |
| 47 | 48 |
| 48 test(() => { | 49 promise_test(t => { |
| 49 | 50 |
| 50 const theError = new Error('a unique string'); | 51 const theError = { name: 'my error' }; |
| 51 | 52 |
| 52 let controller; | 53 let controller; |
| 53 const rs = new ReadableStream( | 54 const rs = new ReadableStream( |
| 54 { | 55 { |
| 55 start(c) { | 56 start(c) { |
| 56 controller = c; | 57 controller = c; |
| 57 } | 58 } |
| 58 }, | 59 }, |
| 59 { | 60 { |
| 60 size() { | 61 size() { |
| 61 controller.error(theError); | 62 controller.error(theError); |
| 62 return Infinity; | 63 return Infinity; |
| 63 }, | 64 }, |
| 64 highWaterMark: 5 | 65 highWaterMark: 5 |
| 65 } | 66 } |
| 66 ); | 67 ); |
| 67 | 68 |
| 68 try { | 69 assert_throws(new RangeError(), () => controller.enqueue('a'), 'enqueue should
throw a RangeError'); |
| 69 controller.enqueue('a'); | 70 |
| 70 } catch (error) { | 71 return promise_rejects(t, theError, rs.getReader().closed, 'closed should reje
ct with the error'); |
| 71 assert_equals(error.name, 'RangeError', 'enqueue should throw a RangeError')
; | |
| 72 } | |
| 73 | 72 |
| 74 }, 'Readable stream: strategy.size errors the stream and then returns Infinity')
; | 73 }, 'Readable stream: strategy.size errors the stream and then returns Infinity')
; |
| 75 | 74 |
| 76 promise_test(() => { | 75 promise_test(() => { |
| 77 | 76 |
| 78 const theError = new Error('a unique string'); | 77 const theError = new Error('a unique string'); |
| 79 const rs = new ReadableStream( | 78 const rs = new ReadableStream( |
| 80 { | 79 { |
| 81 start(c) { | 80 start(c) { |
| 82 assert_throws(theError, () => c.enqueue('a'), 'enqueue should throw the
error'); | 81 assert_throws(theError, () => c.enqueue('a'), 'enqueue should throw the
error'); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 promises.push(rs.getReader().closed.catch(e => { | 166 promises.push(rs.getReader().closed.catch(e => { |
| 168 assert_equals(e, theError, 'closed should reject with the error for ' + si
ze); | 167 assert_equals(e, theError, 'closed should reject with the error for ' + si
ze); |
| 169 })); | 168 })); |
| 170 } | 169 } |
| 171 | 170 |
| 172 return Promise.all(promises); | 171 return Promise.all(promises); |
| 173 | 172 |
| 174 }, 'Readable stream: invalid strategy.size return value'); | 173 }, 'Readable stream: invalid strategy.size return value'); |
| 175 | 174 |
| 176 done(); | 175 done(); |
| OLD | NEW |