The structured cloning with transfer list
https://html.spec.whatwg.org/multipage/#structuredserializewithtransfer
throws a "DataCloneError" DOM expection by default if
serialization/transferral
is not possible, but a platform object can throw a custom excepton on
its serialization/transfer steps.
One example is OffscreenCanvas, which can throw
an "InvalidStateError" exception if the context mode is not none on
transfer steps.
https://html.spec.whatwg.org/multipage/#the-offscreencanvas-interface:transfer-steps
Testing: Improvements in the following tests
-
html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.transferrable*
Fixes: #37919
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
In https://github.com/servo/servo/pull/36977, when transferring
`TransformStream`, `CrossRealmTransform::Writable` and
`CrossRealmTransform::Readable` are set to different message ports. The
message port will not be readable and writable at the same time when
transferring the stream, so we can now merge
`cross_realm_transform_readable` and `cross_realm_transform_writable`
into a single field `cross_realm_transform`.
Testing: WPT ([passed on try
branch](https://github.com/pewsheen/servo/actions/runs/15209389525/job/42784179519))
Fixes: https://github.com/servo/servo/issues/37084
---------
Signed-off-by: Jason Tsai <git@pews.dev>