BabylonJS / BabylonJS/JsRuntimeHost
Web polyfill constants: add missing InstanceValue exposure on WebSocket and XMLHttpRequest
- Dominant language
- C++
- Stars
- 22
- Forks
- 23
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 6
Description
Per WHATWG IDL, class `const` members are exposed on both the constructor (static) and instances (via the prototype). JRH polyfills currently do this inconsistently:
- `Polyfills/WebSocket/Source/WebSocket.cpp` (L16–19) — `CONNECTING` / `OPEN` / `CLOSING` / `CLOSED` are `StaticValue` only. `new WebSocket(...).OPEN` returns `undefined`.
- `Polyfills/XMLHttpRequest/Source/XMLHttpRequest.cpp` (L72–76) — `UNSENT` / `OPENED` / `HEADERS_RECEIVED` / `LOADING` / `DONE` are `StaticValue` only. Same gap.
- `Polyfills/File/Source/FileReader.cpp` (new in #169) — exposes both, conformant.
**Fix:** add an `InstanceValue` entry alongside each `StaticValue` for both polyfills. Going forward, web polyfill classes with IDL `const` members should define one of each.
**Follow-up:** investigate whether a helper function/macro can emit both descriptors from a single declaration so authors don't have to remember the dual exposure (and constants can't silently drift between static and instance values).
**References:**
- https://websockets.spec.whatwg.org/#interface-definition
- https://xhr.spec.whatwg.org/#interface-xmlhttprequest
- https://w3c.github.io/FileAPI/#APIASynch
Contributor guide
Assessment
This issue has not been assessed yet.