| OLD | NEW |
| 1 'use strict'; | 1 'use strict'; |
| 2 | 2 |
| 3 // These tests can be run against any readable stream produced by the web platfo
rm that meets the given descriptions. | 3 // These tests can be run against any readable stream produced by the web platfo
rm that meets the given descriptions. |
| 4 // For readable stream tests, the factory should return the stream. For reader t
ests, the factory should return a | 4 // For readable stream tests, the factory should return the stream. For reader t
ests, the factory should return a |
| 5 // { stream, reader } object. (You can use this to vary the time at which you ac
quire a reader.) | 5 // { stream, reader } object. (You can use this to vary the time at which you ac
quire a reader.) |
| 6 | 6 |
| 7 self.templatedRSEmpty = (label, factory) => { | 7 self.templatedRSEmpty = (label, factory) => { |
| 8 test(() => {}, 'Running templatedRSEmpty with ' + label); | 8 test(() => {}, 'Running templatedRSEmpty with ' + label); |
| 9 | 9 |
| 10 test(() => { | 10 test(() => { |
| 11 | 11 |
| 12 const rs = factory(); | 12 const rs = factory(); |
| 13 | 13 |
| 14 assert_equals(typeof rs.locked, 'boolean', 'has a boolean locked getter'); | 14 assert_equals(typeof rs.locked, 'boolean', 'has a boolean locked getter'); |
| 15 assert_equals(typeof rs.cancel, 'function', 'has a cancel method'); | 15 assert_equals(typeof rs.cancel, 'function', 'has a cancel method'); |
| 16 assert_equals(typeof rs.getReader, 'function', 'has a getReader method'); | 16 assert_equals(typeof rs.getReader, 'function', 'has a getReader method'); |
| 17 assert_equals(typeof rs.tee, 'function', 'has a tee method'); | 17 assert_equals(typeof rs.tee, 'function', 'has a tee method'); |
| 18 | 18 |
| 19 }, 'instances have the correct methods and properties'); | 19 }, 'instances have the correct methods and properties'); |
| 20 |
| 21 test(() => { |
| 22 const rs = factory(); |
| 23 |
| 24 assert_throws(new RangeError(), () => rs.getReader({ mode: '' }), 'empty str
ing mode should throw'); |
| 25 assert_throws(new RangeError(), () => rs.getReader({ mode: null }), 'null mo
de should throw'); |
| 26 assert_throws(new RangeError(), () => rs.getReader({ mode: 'asdf' }), 'asdf
mode should throw'); |
| 27 assert_throws(new TypeError(), () => rs.getReader(null), 'null should throw'
); |
| 28 |
| 29 }, 'calling getReader with invalid arguments should throw appropriate errors')
; |
| 20 }; | 30 }; |
| 21 | 31 |
| 22 self.templatedRSClosed = (label, factory) => { | 32 self.templatedRSClosed = (label, factory) => { |
| 23 test(() => {}, 'Running templatedRSClosed with ' + label); | 33 test(() => {}, 'Running templatedRSClosed with ' + label); |
| 24 | 34 |
| 25 promise_test(() => { | 35 promise_test(() => { |
| 26 | 36 |
| 27 const rs = factory(); | 37 const rs = factory(); |
| 28 const cancelPromise1 = rs.cancel(); | 38 const cancelPromise1 = rs.cancel(); |
| 29 const cancelPromise2 = rs.cancel(); | 39 const cancelPromise2 = rs.cancel(); |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 const newReader = stream.getReader(); | 623 const newReader = stream.getReader(); |
| 614 return newReader.read(); | 624 return newReader.read(); |
| 615 }); | 625 }); |
| 616 | 626 |
| 617 assert_equals(reader.closed, readerClosed, 'reader.closed is the same after
calling read()'); | 627 assert_equals(reader.closed, readerClosed, 'reader.closed is the same after
calling read()'); |
| 618 | 628 |
| 619 return promise; | 629 return promise; |
| 620 | 630 |
| 621 }, 'reader\'s closed property always returns the same promise'); | 631 }, 'reader\'s closed property always returns the same promise'); |
| 622 }; | 632 }; |
| OLD | NEW |