ReviewOS

zig-utils/zig-js

Events: canonicalize persistent and compared type StringData

#684
Closed chris opened this 10 days ago ·
10 days ago

Parent: #473

Problem

Event(type), CustomEvent(type), EventTarget.addEventListener(type, ...), and EventTarget.removeEventListener(type, ...) currently route WebIDL string coercion through physical StringData bytes. Event objects persist that result, listener records persist it, and dispatch/remove compare it bytewise. With flat Latin-1 storage enabled, an equal JavaScript string can therefore be stored or compared using a representation-dependent byte sequence.

Scope

  • Canonicalize the four event-type coercion boundaries to WTF-8.
  • Preserve WebIDL coercion count and ordering.
  • Preserve Event/CustomEvent initialization, listener deduplication, removal, AbortSignal integration, and dispatch semantics.
  • Add one regression witness that covers observable event.type, CustomEvent.type, add/dispatch/remove matching, and exact coercion count.
  • Exercise both canonical and forced-flat physical string storage.

This issue does not change promise jobs, queues, workers, threads, or Map/Set iterators.

Acceptance

  • Equal type strings behave identically across physical StringData representations.
  • Each object-valued type is coerced exactly once at its specified boundary.
  • Focused Debug, ReleaseSafe, and TSan witnesses pass, including a forced-flat-storage run.
  • Full sharded units report zero failures and zero leaks.
  • Test262 Web API coverage is inventoried explicitly; a zero denominator is reported as no corpus claim.
10 days ago

Implemented and pushed in https://github.com/zig-utils/zig-js/commit/965b5d1b7df5ca65a5d9865a3f2f4852f6d916ad.

Event and CustomEvent constructors plus EventTarget add/remove listener coercions now produce canonical WTF-8. Listener deduplication, removal, dispatch matching, and AbortSignal observation now read stored type strings through the representation-aware WTF-8 boundary.

Validation: focused Debug, forced-flat storage, ReleaseSafe, and TSan 1/1 each; full units 1777 passed, 1 skipped, 0 failed, 0 leaked. Test262 contains 0 DOM Events Web API files, so no corpus conformance claim is made.

Sign in to comment on this issue.