Blob/URL: identify Blobs by our own constructor; make URL's static methods writable (WebIDL) - #251
Open
matthargett wants to merge 6 commits into
Open
matthargett wants to merge 6 commits into
matthargett wants to merge 6 commits into
Conversation
…thods writable
Blob::TryGetData compared an object's prototype chain against whatever
the global `Blob` binding held at call time. A script that replaces the
global Blob with its own class (BabylonNative's validation harness does,
for image loading) made every instance of that class look like one of
ours, and Unwrap on an object that wraps nothing threw a bare "Invalid
argument" out of URL.createObjectURL -- while a real Blob was rejected
as "not a Blob". The constructor is now kept on the runtime's native
object at Initialize and identity is checked against that; a null
Unwrap yields "not a Blob" like any other foreign object.
The same harness assigns its own URL.createObjectURL. napi_default
makes static methods read-only, so that assignment failed silently and
the native method kept receiving the foreign Blob. WebIDL static
operations are writable, enumerable and configurable; declare the URL
statics that way.
Found by the SOG Gaussian-splat scenes of BabylonNative's Dawn
validation catalog ("Failed to parse SOG zip data", cause "Invalid
argument"); they pass again with this change. Regression tests cover
both halves.
matthargett
added a commit
to rebeckerspecialties/JsRuntimeHost
that referenced
this pull request
Sep 17, 2026
Author
|
Twin caught a test-only issue on Win32_x86_Chakra: ChakraCore has no |
…look-alike rejection by message
…ime native object (workers have no JsRuntime)
matthargett
added a commit
to rebeckerspecialties/JsRuntimeHost
that referenced
this pull request
Sep 17, 2026
…look-alike rejection by message (from BabylonJS#251)
Author
|
cc @CedricGuillemet since this is another issue blocking splats on WebGPU in BN |
This was referenced Sep 26, 2026
…abylonJS#257) The Blob-identity and writable-URL-statics regression tests move from the monolithic tests.ts into the URL.createObjectURL block of Source/Scripts/tests.url.ts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Blob::TryGetData(behindURL.createObjectURL) identified our Blobs by walking the prototype chain against the current globalBlob. A page that installs its ownBlobclass (BabylonNative's validation harness does, for image loading) made every instance of that class pass the check:ObjectWrap::Unwrapthrew a bareError: Invalid argument, and a genuine native Blob was rejected as "not a Blob".URL.createObjectURL. Node-API'snapi_defaultmakes static methods read-only, so the assignment failed silently; WebIDL static operations are writable, enumerable and configurable.Failed to parse SOG zip data, causeInvalid argument.Change
Initializeand identify instances against that, not against the global binding and not on theJsRuntimenative object (worker realms have none, Add a browser-compatible Worker polyfill (dedicated workers, structured clone, transfer lists, focused WPT regressions) #258). A nullUnwrapyieldsnullopt, so the existingTypeError: … argument is not a Blobapplies.URLstatics (canParse,parse,createObjectURL,revokeObjectURL) withnapi_writable | napi_enumerable | napi_configurable.napi_writablefor method properties (it ignored the attribute).URL.createObjectURLsuite; both fail onmain.Current with
main@ b2b51ca (#257's per-feature test layout).