You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make blob: URLs cross‑realm and allow file‑backed Blob cloning
Detailed description:
- Add a global native blob URL registry so blob: URLs created in one realm are resolvable in another (e.g. main → worker). Registry entries store the DataQueue and metadata, are mutex‑protected, and are cleaned up via Environment cleanup hooks to avoid teardown races.
- Extend the DataQueue / Entry reader API to accept an optional `Environment*`, and update `FdEntry` reader creation so file handles and reader resources are created in the target environment/realm. This enables structured cloning / transferring of file‑backed Blobs across workers.
- Remove the JS-side prohibition on cloning file‑backed blobs so `structuredClone()` succeeds for file‑backed Blobs.
- Wire up Blob native bindings to use the new registry when storing/getting/revoking blob URLs; ensure Blob::GetDataObject constructs the Blob in the receiving environment.
- Add/update regression tests covering URL resolution in workers and cloning of file‑backed Blobs.
Files changed (high level):
- **node_blob.cc**: add global blob URL registry, Store/Get/Revoke helpers, env cleanup hook integration, Blob::StoreDataObject/GetDataObject/RevokeObjectURL wiring.
- **queue.h**, **queue.cc**: add optional `Environment*` parameter to `Entry::get_reader`, propagate env through DataQueue, implement `FdEntry::ReaderImpl::Create(entry, env)` to open file handles in the reader env.
- **blob.js**: remove `kNotCloneable` flag for file‑backed Blobs so they can be cloned/ transferred.
- **test-blob-url-worker.js**: new/updated regression test validating `resolveObjectURL` in a worker for a URL created on the main thread.
- **test-blob-file-backed.js**: update test to assert `structuredClone()` succeeds for file‑backed Blobs and that cloned content/metadata match.
Rationale and tests:
- These changes fix two related issues: blob URLs that only worked per‑realm, and file‑backed Blobs that were prevented from being cloned/transferred. Both were blocking cross‑realm Blob usage (main ↔ worker). All added/updated tests pass in the local test harness used during development.
0 commit comments