Gregory Terzian
af5d665efa
MessagePort: implement disentanglement ( #36654 )
...
Implement
[disentangle](https://html.spec.whatwg.org/multipage/#disentangle )
Remove bespoke gc logic which now becomes unnecessary.
Adds a wpt test that hits the "disentangle while in transfer" logic.
Updates streams code, fixing an error where disentanglement is
conditional on an error.
Test coverage: there are existing tests in
`/webmessaging/message-channels/close-event/explicitly-closed.tentative.window.js`
for the no transfer case, and the simple completed transfer case, and
this PR adds a test for the more complicated transfer in progress case.
Fix https://github.com/servo/servo/issues/36465
---------
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-04-30 10:49:38 +00:00
Taym Haddadi
4d975e947b
Start adding support for transforms in readable and writable streams ( #36470 )
...
Start adding support for transforms in readable and writable streams.
Part of https://github.com/servo/servo/issues/34676
2025-04-28 11:02:55 +00:00
Gregory Terzian
57b0a3f231
Streams: fix writable transfer sink abort steps ( #36638 )
...
Fixes an error where a promise was rejected where it should have been
resolved.
Follow-up to
https://github.com/servo/servo/pull/36588/files#r2049437506 ; the initial
diagnosis was wrong.
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-04-22 06:49:18 +00:00
Taym Haddadi
f2ee40e40b
fix writablestream assertion crash when getting chunk size following spec change ( #36566 )
...
One-line change to align with the new spec and avoid a crash.
fix #36565
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-04-16 18:26:38 +00:00
Gregory Terzian
f8b6b9f7b6
Transfer ReadableStream ( #36181 )
...
<!-- Please describe your changes on the following line: -->
Add transfer support to ReadableStream. Part of
https://github.com/servo/servo/issues/34676
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___
<!-- Also, please make sure that "Allow edits from maintainers" checkbox
is checked, so that we can help you if you get stuck somewhere along the
way.-->
<!-- Pull requests that do not address these steps are welcome, but they
will require additional verification as part of the review process. -->
---------
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-04-15 07:39:26 +00:00
Gregory Terzian
a5c547259f
Streams: add an underlying sink type ( #36385 )
...
Introduces the concept of different types of underlying sinks for the
writable controller, and a minor fix to the abort algorithm.
The dead code is already used in the wip at
https://github.com/servo/servo/pull/36181/ , and will also be used in a
another wip in parallel to implement transform stream, so the concept is
introduced here with dead code to facilitate the work in parallel and
prevent too much merge conflicts down the road.
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-04-07 16:48:42 +00:00
Arya Nair
94d12de7fd
feat: add CanGc argument to Error::to_jsval ( #36014 )
...
* feat: add CanGc argument to Error::to_jsval
Signed-off-by: Arya Nair <aryaajitnair@gmail.com>
* feat: pass CanGc to gen_type_error
Signed-off-by: Arya Nair <aryaajitnair@gmail.com>
* fix: linting issues
Signed-off-by: Arya Nair <aryaajitnair@gmail.com>
---------
Signed-off-by: Arya Nair <aryaajitnair@gmail.com>
2025-03-17 22:29:41 +00:00
Josh Matthews
5650fa2e79
script: Mark callback methods with CanGc. ( #35753 )
...
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-03-03 12:17:25 +00:00
Simon Wülker
3d320fa96a
Update rustfmt to the 2024 style edition ( #35764 )
...
* Use 2024 style edition
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Reformat all code
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-03-03 11:26:53 +00:00
Yerkebulan Tulibergenov
38b71087bd
refactor: add CanGc as argument to Promise::reject_error ( #35646 )
...
Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
2025-02-25 10:12:58 +00:00
Josh Matthews
381e168877
Move more bindings types to script_bindings ( #35620 )
...
* Move weak references implementation to script_bindings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Move maplike/setlike definitions to script_bindings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Move base error types to script_bindings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Formatting.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-02-23 14:25:46 +00:00
Yerkebulan Tulibergenov
0383ba9a5b
refactor: add CanGc as argument to Promise::resolve ( #35616 )
...
Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
2025-02-23 12:12:21 +00:00
Gae24
adb831eefe
script: add CanGc
argument to Promise::new_resolved
and Promise::new_rejected
( #35605 )
...
* add CanGc to new_resolved and use it where possible
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* add CanGc to new_rejected
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2025-02-23 04:45:47 +00:00
Yerkebulan Tulibergenov
245a39c07e
refactor: add CanGc as argument to create_buffer_source ( #35597 )
...
Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
2025-02-22 05:42:55 +00:00
Auguste Baum
863d2ce871
Propagate CanGc
arguments through callers in constructors ( #35541 )
...
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
2025-02-20 16:17:45 +00:00
Gregory Terzian
df6d636168
dom: Implement WritableStream
( #34844 )
...
* add basic interface for writable stream
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* add stubs for pipeTo and pipeThrough methods
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* add stubs for writable stream defautl writer
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* add stubs for writable stream controller
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* add underlying source dict
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* add underlying source dict
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement constructor
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement init writable stream
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* impl setup default controller
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement controller setup
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement controller advance queue if neededd
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement stream finish erroring
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement stream reject close and closed promise if needed
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* finish implementation of stream finish erroring
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* call into controller setup from stream constructor
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement stream mark first write request in flight
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement controller process write
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* call into advance queue if needed at various points
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement stream deal with rejection, use from_safe_context
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement controller clear algorithms
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove unused todo
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement stream start erroring
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* finish writer ensure ready promise rejected
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement stream finish in flight write request
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement write constructor and setup
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement controller error
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove unnecessary unsafe code
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* finish implementing process write
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement close sentinel
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement public locked
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement stream abort
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement stream close
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement controller close
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix use of crown
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove unnecessary options around writer promises
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement writer get desired size
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement writer ready
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement writer abort
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement writer close
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement writer release lock
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement writer public write
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement private writer write
Uses ai
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement writer release.
Uses ai
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* impl controller process close
Uses ai
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* finish controller process close
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* root promise handlers
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* handler errors in stream and writer constructor
finish implementation of stream finish in flight close
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix warnings
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement controller get chunk size
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* tidy the webidls
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* implement stream get writer
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix assertion of stream state when advancing queue if needed
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* add docs for value with size
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* use reject_error in abort
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove unnecessary allowances of unsafe code
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* turn writable-streams test suite on
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* update encodings test expectations
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* properly check if type is set on sink in stream constructor
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix double borrow in controller advance queue if needed
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* make the queue aware of the close sentinel when dequeuing a value
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix assertion of no backpressure in update backpressure
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* also clear strategy size when clearing algorithms
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove this object arg when calling into strategy size
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix has operations marked in flight
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix typo in has in flight write request
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* turn error into no-op when aborting a stream, if the stream is closed or errored.
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix error handling of calling into abort algorithm
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix error handling of calling into close and write algorithms
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix double borrow on queue
fix logic in update_backpressure
fix logic in get_desired_size
fix logic in writer setup
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* update test expectations for aborting suite
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix controller get_backpressure
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix clippy
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* update test expectations to expect errors in tests using unsupported apis
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix error handling of calling into start algo in controller setup
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* update test expectations for test checking for undefined this in strategy size call
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* update test expectation to timeout for response-stream-with-broken-then.any.worker
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* update interfaces
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix use of global() and error to_jsval
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix use of crown for promise handlers
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove fail expectation from worker interface objects test
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove fail expectation for test expecting this to be undefined in callback
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix documentation link for writablestream state
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* refactor write_requests to use a vec deque
uses ai
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove unnecessary doc
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* refactor reject_close_and_closed_promise_if_needed to take a safe js context as argument
uses ai
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* pass globals and contexts by ref where possible
uses ai
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix doc link for controller
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove unnecessary comment
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* change update_backpressure to be a method of the writablestream
uses ai
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* rename writer method that resolve closed and ready promise for clarity
uses ai
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* add comments for steps in peek queue value
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix doc link for the abort algorihtm fulfillment handler
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix step doc and variable name in abort algo rejection handler
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* Add must_root to pending abort request
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Gregory Terzian <2792687+gterzian@users.noreply.github.com>
* limit visibility to crate for has_operations_marked_inflight
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Gregory Terzian <2792687+gterzian@users.noreply.github.com>
* limit visibility to crate for get_stored_error
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Gregory Terzian <2792687+gterzian@users.noreply.github.com>
* remove potention re-borrow risk in reject loop on write requests in finish_erroring
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove potential re-borrow risk when taking pending abort request in finish_erroring
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove potential re-borrow risk when taking close request in reject_close_and_closed_promise_if_needed
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove re-borrow risks in finish_in_flight_close
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove re-borrow risk on in_flight_close_request in finish_in_flight_close_with_error
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove unnecessary clone of of reason in abort
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix condition on backpressure and a writable state in close
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* limit visibility to crate for update_backpressure
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Gregory Terzian <2792687+gterzian@users.noreply.github.com>
* remove mutability of reason in abort workflow
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove unnecessary use of ignore_malloc_size_of around Dom in controller
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix ignore malloc size of comment for strategy size
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* reduce visibility of public methods to crate in controller
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* remove use of JS_GetPendingException in controller get_chunk_size
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* return early on error in write
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* use is_some_and in assertion that stream.witer is writer in release
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* root pending abort request
uses ai
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* fix mutable re-borrow risk in writer
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
---------
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
Signed-off-by: Gregory Terzian <2792687+gterzian@users.noreply.github.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-02-19 13:02:14 +00:00