diff --git a/index.bs b/index.bs index a45953a45..35808e914 100644 --- a/index.bs +++ b/index.bs @@ -509,7 +509,6 @@ it would look like constructor(stream) get closed() - get isActive() cancel(reason) read() @@ -580,19 +579,6 @@ Instances of ReadableStreamReader are created with the internal slo
  • Return this@\[[closedPromise]]. -
    get isActive
    - -
    - The isActive getter returns whether or not the stream reader is currently - active. -
    - -
      -
    1. If IsReadableStreamReader(this) is false, throw a TypeError exception. -
    2. If this@\[[ownerReadableStream]] is undefined, return false; otherwise, return - true. -
    -
    cancel(reason)
    diff --git a/reference-implementation/lib/readable-stream.js b/reference-implementation/lib/readable-stream.js index 4b6f38979..43097e717 100644 --- a/reference-implementation/lib/readable-stream.js +++ b/reference-implementation/lib/readable-stream.js @@ -180,14 +180,6 @@ class ReadableStreamReader { return this._closedPromise; } - get isActive() { - if (IsReadableStreamReader(this) === false) { - throw new TypeError('ReadableStreamReader.prototype.isActive can only be used on a ReadableStreamReader'); - } - - return this._ownerReadableStream !== undefined; - } - cancel(reason) { if (IsReadableStreamReader(this) === false) { return Promise.reject( diff --git a/reference-implementation/test/brand-checks.js b/reference-implementation/test/brand-checks.js index 665376a1b..e98705efa 100644 --- a/reference-implementation/test/brand-checks.js +++ b/reference-implementation/test/brand-checks.js @@ -41,7 +41,6 @@ function realWritableStream() { function fakeReadableStreamReader() { return { get closed() { return Promise.resolve(); }, - get isActive() { return false; }, cancel(reason) { return Promise.resolve(); }, read() { return Promise.resolve({ value: undefined, done: true }); }, releaseLock() { return; } @@ -161,12 +160,6 @@ test('ReadableStreamReader.prototype.closed enforces a brand check', t => { getterRejects(t, ReadableStreamReader.prototype, 'closed', realReadableStream()); }); -test('ReadableStreamReader.prototype.isActive enforces a brand check', t => { - t.plan(2); - getterThrows(t, ReadableStreamReader.prototype, 'isActive', fakeReadableStreamReader()); - getterThrows(t, ReadableStreamReader.prototype, 'isActive', realReadableStream()); -}); - test('ReadableStreamReader.prototype.cancel enforces a brand check', t => { t.plan(2); methodRejects(t, ReadableStreamReader.prototype, 'cancel', fakeReadableStreamReader()); diff --git a/reference-implementation/test/readable-stream-reader.js b/reference-implementation/test/readable-stream-reader.js index 9223a7f87..c67f9ee01 100644 --- a/reference-implementation/test/readable-stream-reader.js +++ b/reference-implementation/test/readable-stream-reader.js @@ -68,11 +68,8 @@ test('Reading from a reader for an empty stream will wait until a chunk is avail }); const reader = rs.getReader(); - t.equal(reader.isActive, true, 'reader is active to start with'); - reader.read().then(result => { t.deepEqual(result, { value: 'a', done: false }, 'read() should fulfill with the enqueued chunk'); - t.equal(reader.isActive, true, 'reader is still active'); t.end(); }); @@ -85,7 +82,7 @@ test('cancel() on a reader releases the reader before calling through', t => { const passedReason = new Error('it wasn\'t the right time, sorry'); const rs = new ReadableStream({ cancel(reason) { - t.equal(reader.isActive, false, 'reader should be released by the time underlying source cancel is called'); + t.doesNotThrow(() => rs.getReader(), 'should be able to get another reader without error'); t.equal(reason, passedReason, 'the cancellation reason is passed through to the underlying source'); } }); @@ -109,14 +106,14 @@ test('closed should be fulfilled after stream is closed (.closed access before a const reader = rs.getReader(); reader.closed.then(() => { - t.equal(reader.isActive, false, 'reader is no longer active when reader closed is fulfilled'); + t.pass('reader closed should be fulfilled'); }); doClose(); }); test('closed should be fulfilled after reader releases its lock (multiple stream locks)', t => { - t.plan(4); + t.plan(2); let doClose; const rs = new ReadableStream({ @@ -133,13 +130,11 @@ test('closed should be fulfilled after reader releases its lock (multiple stream doClose(); reader1.closed.then(() => { - t.equal(reader1.isActive, false, 'reader1 is no longer active when reader1 closed is fulfilled'); - t.equal(reader2.isActive, false, 'reader2 is no longer active when reader1 closed is fulfilled'); + t.pass('reader1 closed should be fulfilled'); }); reader2.closed.then(() => { - t.equal(reader1.isActive, false, 'reader1 is no longer active when reader2 closed is fulfilled'); - t.equal(reader2.isActive, false, 'reader2 is no longer active when reader2 closed is fulfilled'); + t.pass('reader2 closed should be fulfilled'); }); }); @@ -164,18 +159,24 @@ test('Multiple readers can access the stream in sequence', t => { }); test('Cannot use an already-released reader to unlock a stream again', t => { - t.plan(2); + t.plan(1); - const rs = new ReadableStream(); + const rs = new ReadableStream({ + start(enqueue) { + enqueue('a'); + } + }); const reader1 = rs.getReader(); reader1.releaseLock(); const reader2 = rs.getReader(); - t.equal(reader2.isActive, true, 'reader2 state is active before releasing reader1'); reader1.releaseLock(); - t.equal(reader2.isActive, true, 'reader2 state is still active after releasing reader1 again'); + reader2.read().then(result => { + t.deepEqual(result, { value: 'a', done: false }, + 'read() should still work on reader2 even after reader1 is released'); + }); }); test('cancel() on a released reader is a no-op and does not pass through', t => { diff --git a/reference-implementation/test/templated/readable-stream-empty-reader.js b/reference-implementation/test/templated/readable-stream-empty-reader.js index c4d6fc0a9..795363e67 100644 --- a/reference-implementation/test/templated/readable-stream-empty-reader.js +++ b/reference-implementation/test/templated/readable-stream-empty-reader.js @@ -78,17 +78,15 @@ export default (label, factory) => { ); t.throws(() => reader.releaseLock(), /TypeError/, 'releaseLock should throw a TypeError'); - t.equal(reader.isActive, true, 'the reader should still be active'); setTimeout(() => t.end(), 50); }); test('releasing the lock should cause further read() calls to resolve as if the stream is closed', t => { - t.plan(3); + t.plan(2); const { reader } = factory(); reader.releaseLock(); - t.equal(reader.isActive, false, 'the reader should no longer be active'); reader.read().then(r => t.deepEqual(r, { value: undefined, done: true }, 'first read() should return closed result')); @@ -97,34 +95,29 @@ export default (label, factory) => { }); test('releasing the lock should cause closed to fulfill', t => { - t.plan(3); + t.plan(2); const { reader } = factory(); reader.closed.then(v => t.equal(v, undefined, 'reader.closed got before release should fulfill with undefined')); reader.releaseLock(); - t.equal(reader.isActive, false, 'the reader should no longer be active'); reader.closed.then(v => t.equal(v, undefined, 'reader.closed got after release should fulfill with undefined')); }); - test('canceling via the reader should cause the reader to become inactive', t => { - t.plan(3); + test('canceling via the reader should cause the reader to act closed', t => { + t.plan(1); const { reader } = factory(); - t.equal(reader.isActive, true, 'the reader should be active before releasing it'); reader.cancel(); - t.equal(reader.isActive, false, 'the reader should no longer be active'); reader.read().then(r => t.deepEqual(r, { value: undefined, done: true }, 'read()ing from the reader should give a done result')) }); test('canceling via the stream should fail', t => { - t.plan(3); + t.plan(1); const { stream, reader } = factory(); - t.equal(reader.isActive, true, 'the reader should be active before releasing it'); stream.cancel().catch(e => t.equal(e.constructor, TypeError, 'cancel() should reject with a TypeError')); - t.equal(reader.isActive, true, 'the reader should still be active'); }); };