Closed Bug 1526596 Opened 9 months ago Closed 9 months ago

[wpt-sync] Sync PR 15097 - ReadableStream @@asyncIterator

Categories

(Core :: DOM: Core & HTML, enhancement, P4)

enhancement

Tracking

()

RESOLVED FIXED
mozilla67
Tracking Status
firefox67 --- fixed

People

(Reporter: wptsync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 15097 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/15097
Details from upstream follow.

Gus Caplan <me@gus.host> wrote:

ReadableStream @@asyncIterator

Add tests for async-iterating a ReadableStream. See whatwg/streams#980 for the accompanying spec change.

This PR continues from @devsnek's work in #13362.

The tests are based on Domenic's comment in whatwg/streams#954. So far, the following tests have been implemented:

  • [x] Basic test of a stream with a few chunks that closes
    • [x] Using a "push" underlying source (calls c.enqueue() in start) that enqueues all at once
    • [x] Using a "push" underlying source where you call c.enqueue() "just in time" (i.e. inside the loop body)
    • [x] Using a "pull" underlying source (calls c.enqueue() in pull) using recordingReadableStream to verify the correct underlying source method calls
  • [x] Degenerate streams
    • [x] Async-iterating an errored stream throws
    • [x] Async-iterating a closed stream never executes the loop body, but works fine
    • [x] Async-iterating an empty but not closed/errored stream never executes the loop body and stalls the async function (end the test if 50 ms pass without the promise resolving)
  • [x] @@asyncIterator() method is === to getIterator() method
  • [x] Cancellation behavior (use recordingReadableStream)
    • [x] Manually calling return() causes a cancel
    • [x] throwing inside the loop body causes a cancel
    • [x] breaking inside the loop body causes a cancel
    • [x] returning inside the loop body causes a cancel
    • [x] All of the above, but with preventCancel: true and the pass conditions reversed
  • [x] Manual manipulation
    • [x] double-return rejects (#954 (comment))
    • [x] next()'s fulfillment values have exactly the right shape (Object.prototype, only two properties, correct property descriptors)
    • [x] throw method does not exist
    • [x] Calling next() or return() on non-ReadableStreamDefaultReaderAsyncIterator instances rejects with TypeError (there are existing brand check tests you can add to)
    • [x] Calling return() while there are pending reads (i.e. unsettled promises returned by next()) rejects the return Promise (#950 (comment))
  • [x] Interaction with existing infrastructure
    • [x] getIterator/@@asyncIterator throw if there's already a lock
    • [x] Monkey-patch getReader and default reader's prototype methods and ensure this does not interfere with async iteration (e.g. using one of the basic test cases)
    • [x] Basic test with a few chunks but you've already consumed one or two via a normal reader (which you then released)
  • [x] Auto-release
    • [x] You can still acquire a reader and successfully use its .closed promise after exhausting the async iterator via for-await-of
    • [x] You can still acquire a reader and successfully use its .closed promise after return()ing from the async iterator (either manually or via break; take your pick)
Component: web-platform-tests → DOM
Product: Testing → Core
Ran 20 tests and 336 subtests
OK     : 16
PASS   : 224
FAIL   : 112

New tests that have failures or other problems:
/streams/readable-streams/async-iterator.any.html
    Acquiring a reader after exhaustively async-iterating a stream: FAIL
    Acquiring a reader after partially async-iterating a stream: FAIL
    Acquiring a reader and reading the remaining chunks after partially async-iterating a stream with preventCancel = true: FAIL
    Async iterator instances should have the correct list of properties: FAIL
    Async-iterating a closed stream never executes the loop body, but works fine: FAIL
    Async-iterating a partially consumed stream: FAIL
    Async-iterating a pull source: FAIL
    Async-iterating a pull source manually: FAIL
    Async-iterating a push source: FAIL
    Async-iterating an empty but not closed/errored stream never executes the loop body and stalls the async function: FAIL
    Async-iterating an errored stream throws: FAIL
    Calling return() twice rejects: FAIL
    Cancellation behavior when breaking inside loop body; preventCancel = false: FAIL
    Cancellation behavior when breaking inside loop body; preventCancel = true: FAIL
    Cancellation behavior when manually calling return(); preventCancel = false: FAIL
    Cancellation behavior when manually calling return(); preventCancel = true: FAIL
    Cancellation behavior when returning inside loop body; preventCancel = false: FAIL
    Cancellation behavior when returning inside loop body; preventCancel = true: FAIL
    Cancellation behavior when throwing inside loop body; preventCancel = false: FAIL
    Cancellation behavior when throwing inside loop body; preventCancel = true: FAIL
    calling return() while there are pending reads rejects: FAIL
    getIterator() throws if there's already a lock: FAIL
    next()'s fulfillment value has the right shape: FAIL
/streams/readable-streams/async-iterator.any.js: SKIP
/streams/readable-streams/async-iterator.any.serviceworker.html
    Acquiring a reader after exhaustively async-iterating a stream: FAIL
    Acquiring a reader after partially async-iterating a stream: FAIL
    Acquiring a reader and reading the remaining chunks after partially async-iterating a stream with preventCancel = true: FAIL
    Async iterator instances should have the correct list of properties: FAIL
    Async-iterating a closed stream never executes the loop body, but works fine: FAIL
    Async-iterating a partially consumed stream: FAIL
    Async-iterating a pull source: FAIL
    Async-iterating a pull source manually: FAIL
    Async-iterating a push source: FAIL
    Async-iterating an empty but not closed/errored stream never executes the loop body and stalls the async function: FAIL
    Async-iterating an errored stream throws: FAIL
    Calling return() twice rejects: FAIL
    Cancellation behavior when breaking inside loop body; preventCancel = false: FAIL
    Cancellation behavior when breaking inside loop body; preventCancel = true: FAIL
    Cancellation behavior when manually calling return(); preventCancel = false: FAIL
    Cancellation behavior when manually calling return(); preventCancel = true: FAIL
    Cancellation behavior when returning inside loop body; preventCancel = false: FAIL
    Cancellation behavior when returning inside loop body; preventCancel = true: FAIL
    Cancellation behavior when throwing inside loop body; preventCancel = false: FAIL
    Cancellation behavior when throwing inside loop body; preventCancel = true: FAIL
    calling return() while there are pending reads rejects: FAIL
    getIterator() throws if there's already a lock: FAIL
    next()'s fulfillment value has the right shape: FAIL
/streams/readable-streams/async-iterator.any.sharedworker.html
    Acquiring a reader after exhaustively async-iterating a stream: FAIL
    Acquiring a reader after partially async-iterating a stream: FAIL
    Acquiring a reader and reading the remaining chunks after partially async-iterating a stream with preventCancel = true: FAIL
    Async iterator instances should have the correct list of properties: FAIL
    Async-iterating a closed stream never executes the loop body, but works fine: FAIL
    Async-iterating a partially consumed stream: FAIL
    Async-iterating a pull source: FAIL
    Async-iterating a pull source manually: FAIL
    Async-iterating a push source: FAIL
    Async-iterating an empty but not closed/errored stream never executes the loop body and stalls the async function: FAIL
    Async-iterating an errored stream throws: FAIL
    Calling return() twice rejects: FAIL
    Cancellation behavior when breaking inside loop body; preventCancel = false: FAIL
    Cancellation behavior when breaking inside loop body; preventCancel = true: FAIL
    Cancellation behavior when manually calling return(); preventCancel = false: FAIL
    Cancellation behavior when manually calling return(); preventCancel = true: FAIL
    Cancellation behavior when returning inside loop body; preventCancel = false: FAIL
    Cancellation behavior when returning inside loop body; preventCancel = true: FAIL
    Cancellation behavior when throwing inside loop body; preventCancel = false: FAIL
    Cancellation behavior when throwing inside loop body; preventCancel = true: FAIL
    calling return() while there are pending reads rejects: FAIL
    getIterator() throws if there's already a lock: FAIL
    next()'s fulfillment value has the right shape: FAIL
/streams/readable-streams/async-iterator.any.worker.html
    Acquiring a reader after exhaustively async-iterating a stream: FAIL
    Acquiring a reader after partially async-iterating a stream: FAIL
    Acquiring a reader and reading the remaining chunks after partially async-iterating a stream with preventCancel = true: FAIL
    Async iterator instances should have the correct list of properties: FAIL
    Async-iterating a closed stream never executes the loop body, but works fine: FAIL
    Async-iterating a partially consumed stream: FAIL
    Async-iterating a pull source: FAIL
    Async-iterating a pull source manually: FAIL
    Async-iterating a push source: FAIL
    Async-iterating an empty but not closed/errored stream never executes the loop body and stalls the async function: FAIL
    Async-iterating an errored stream throws: FAIL
    Calling return() twice rejects: FAIL
    Cancellation behavior when breaking inside loop body; preventCancel = false: FAIL
    Cancellation behavior when breaking inside loop body; preventCancel = true: FAIL
    Cancellation behavior when manually calling return(); preventCancel = false: FAIL
    Cancellation behavior when manually calling return(); preventCancel = true: FAIL
    Cancellation behavior when returning inside loop body; preventCancel = false: FAIL
    Cancellation behavior when returning inside loop body; preventCancel = true: FAIL
    Cancellation behavior when throwing inside loop body; preventCancel = false: FAIL
    Cancellation behavior when throwing inside loop body; preventCancel = true: FAIL
    calling return() while there are pending reads rejects: FAIL
    getIterator() throws if there's already a lock: FAIL
    next()'s fulfillment value has the right shape: FAIL
/streams/readable-streams/brand-checks.any.html
    Can get ReadableStreamAsyncIteratorPrototype object indirectly: FAIL
    ReadableStreamAsyncIteratorPrototype.next enforces a brand check: FAIL
    ReadableStreamAsyncIteratorPrototype.return enforces a brand check: FAIL
/streams/readable-streams/brand-checks.any.serviceworker.html
    Can get ReadableStreamAsyncIteratorPrototype object indirectly: FAIL
    ReadableStreamAsyncIteratorPrototype.next enforces a brand check: FAIL
    ReadableStreamAsyncIteratorPrototype.return enforces a brand check: FAIL
/streams/readable-streams/brand-checks.any.sharedworker.html
    Can get ReadableStreamAsyncIteratorPrototype object indirectly: FAIL
    ReadableStreamAsyncIteratorPrototype.next enforces a brand check: FAIL
    ReadableStreamAsyncIteratorPrototype.return enforces a brand check: FAIL
/streams/readable-streams/brand-checks.any.worker.html
    Can get ReadableStreamAsyncIteratorPrototype object indirectly: FAIL
    ReadableStreamAsyncIteratorPrototype.next enforces a brand check: FAIL
    ReadableStreamAsyncIteratorPrototype.return enforces a brand check: FAIL
/streams/readable-streams/patched-global.any.html
    ReadableStream getIterator() should use the original values of getReader() and ReadableStreamDefaultReader methods: FAIL
/streams/readable-streams/patched-global.any.serviceworker.html
    ReadableStream getIterator() should use the original values of getReader() and ReadableStreamDefaultReader methods: FAIL
/streams/readable-streams/patched-global.any.sharedworker.html
    ReadableStream getIterator() should use the original values of getReader() and ReadableStreamDefaultReader methods: FAIL
/streams/readable-streams/patched-global.any.worker.html
    ReadableStream getIterator() should use the original values of getReader() and ReadableStreamDefaultReader methods: FAIL

Tests that are disabled for instability:
/streams/readable-streams/brand-checks.any.js
/streams/readable-streams/general.any.js
/streams/readable-streams/patched-global.any.js
Pushed by wptsync@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/a3f2954c055c
[wpt PR 15097] - ReadableStream @@asyncIterator, a=testonly
https://hg.mozilla.org/integration/mozilla-inbound/rev/7fd619e9d874
[wpt PR 15097] - Update wpt metadata, a=testonly
Pushed by james@hoppipolla.co.uk:
https://hg.mozilla.org/integration/mozilla-inbound/rev/daffa4526e18
[wpt PR 15097] - ReadableStream @@asyncIterator, a=testonly
https://hg.mozilla.org/integration/mozilla-inbound/rev/ebae3e84214d
[wpt PR 15097] - Update wpt metadata, a=testonly
Status: NEW → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla67
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.