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
feat: add DOMException and CustomEvent as lazy globals
Port of NativeScript/ios#452, the next two items of the web-globals plan,
both behind the lazy-global tier.
DOMException (Web IDL §4.3) is a new lazy builtin (dom-exception.js, shared
verbatim with iOS): a class grafted onto Error.prototype with branded
enumerable name/message/code prototype accessors, the full legacy code
table, the 25 constants on interface object and prototype, @@toStringTag
and stack capture. LazyGlobals places it on first read; until then nothing
runs or allocates.
Sibling builtins construct DOMExceptions through a new internal-only
specifier tier: kRegistry rows flagged internalOnly resolve through the
require builtins receive and nowhere else (the module system refuses them,
and a canary pins that app code cannot name them). All five stand-in throw
sites now produce real DOMExceptions, required at first throw so a clean
path never runs the builtin: abort-signal.js (AbortError/TimeoutError
reasons), performance.js (SyntaxError/InvalidModificationError),
structured-clone.js and StructuredSerialization.cpp (DataCloneError, the
native serializer keeping the name-patched-Error shape as a teardown
fallback), and base64.js (InvalidCharacterError).
With the tier in place the interim `internals` wrapper parameter had
exactly two users left; both moved into events.js's exports behind
internal/events (kListenerChanged for abort-signal's GC accounting,
setListenerErrorReporter for error-events). The builtin wrapper is back to
Node's five parameters (exports, require, module, binding, primordials).
CustomEvent (DOM §2.4) is defined in events.js next to the Event it
extends, exported rather than installed: Events::Init now runs the file
through BuiltinLoader::GetExports and reads the backing EventTarget from
the exports bag, so the lazy CustomEvent row is a cache hit — only the
placement is deferred.
Tests: shared submodule bumped to 9cc46c06 (self-gating DOMException and
CustomEvent suites plus integration specs), both suites wired into
mainpage.js, and unguarded canaries added so this runtime regressing the
globals fails instead of skipping. Full suite: 1203 specs, 0 failures on
arm64 API 33.
Copy file name to clipboardExpand all lines: docs/README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,13 +12,13 @@
12
12
(`AbortController`, `AbortSignal` with the `abort`/`timeout`/`any` statics)
13
13
layered on the runtime's `EventTarget`, the GC contract (weak timers and
14
14
`any()` links, listener-driven persistence), and the `DOMException`
15
-
stand-in (name-patched `Error`reasons).
15
+
reasons.
16
16
-[TextEncoder / TextDecoder and atob / btoa](text-encoding.md) — the WHATWG
17
17
encoding and base64 globals (`TextEncoder`, `TextDecoder`, `atob`, `btoa`),
18
18
the supported encodings with their label sets, streaming decode semantics,
19
19
and the lazy-global tier that runs their builtins only on first use.
20
20
-[Error handling](error-handling.md) — global `error`/`unhandledrejection` events, `reportError`, catching Java exceptions in JS (`error.nativeException`), forwarding JS throws to Java callers (`interop.escapeException`), JS stacks on Java exceptions (`com.tns.JavaScriptStackTrace`), configuration flags, and crash-reporter integration.
21
-
-[structuredClone](structured-clone.md) — the WHATWG `structuredClone(value, { transfer })` global: what clones, how graph identity and cycles are preserved, `ArrayBuffer` transfer, and the `DataCloneError`-named `Error` that stands in for `DOMException`.
21
+
-[structuredClone](structured-clone.md) — the WHATWG `structuredClone(value, { transfer })` global: what clones, how graph identity and cycles are preserved, `ArrayBuffer` transfer, and the `DataCloneError``DOMException` on failure.
Copy file name to clipboardExpand all lines: docs/structured-clone.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ Two differences are intentional:
48
48
49
49
## Deviations from the specification
50
50
51
-
-**`DataCloneError` is an `Error`, not a `DOMException`.**This runtime has no `DOMException`, so failures throw an `Error` whose `name` is set to `"DataCloneError"`. Detect failures with`e.name === "DataCloneError"`; `instanceof DOMException`cannot work.
51
+
-**`DataCloneError` is a `DOMException`.**Failures throw a `DOMException` named `"DataCloneError"`, from the JS argument checks and the native serializer alike, so both`e.name === "DataCloneError"` and `instanceof DOMException`detect them. (The serializer falls back to a `DataCloneError`-named `Error` only when the builtin can no longer run, e.g. during isolate teardown.)
52
52
-**Only `ArrayBuffer` is transferable.** The spec's other transferable types — `MessagePort`, `ImageBitmap`, `ReadableStream` and friends — do not exist here. A non-`ArrayBuffer` in the transfer list is a `DataCloneError`.
53
53
-**Host objects are not cloneable by `structuredClone`.** The spec leaves platform objects to each host; here every native/interop wrapper is rejected with a `DataCloneError`, because a JavaScript copy detached from its native counterpart would be a wrapper around nothing. Worker `postMessage` deliberately differs — see above.
0 commit comments