Skip to content

fix(ext/web): define Symbol.toStringTag on interface prototypes - #37125

Open
linzch3 wants to merge 1 commit into
denoland:mainfrom
linzch3:fix/interface-prototype-tostringtag
Open

linzch3 wants to merge 1 commit into
denoland:mainfrom
linzch3:fix/interface-prototype-tostringtag

Conversation

@linzch3

@linzch3 linzch3 commented Nov 4, 2026 •

Copy link
Copy Markdown

Refs #37107

Web IDL puts Symbol.toStringTag on the interface prototype (non-writable, non-enumerable, configurable). This handles the JS-implemented interfaces from the issue:

  • CustomEvent, ErrorEvent, MessageEvent, ProgressEvent, PromiseRejectionEvent and Worker declared the tag as a class field, so every instance got an own writable/enumerable property and subclasses couldn't override it with a getter. These now define it on the prototype, the same way fix(web): support Event subclasses with readonly toStringTag #35920 did for Event.
  • BroadcastChannel, CloseEvent, EventSource and Navigator had no tag at all, so they now get one.

Not covered here: the Rust-backed interfaces (ImageBitmap, OffscreenCanvas, ImageBitmapRenderingContext, Storage, NavigatorUAData) and WebGPU. Those live in different places and seem better as follow-ups, so this PR only references the issue and doesn't close it.

Added interfacePrototypesHaveToStringTag to tests/unit/event_test.ts. It checks the descriptor on each prototype, that instances no longer have an own tag, and that a subclass getter wins. tests/unit/event_test.ts, event_target_test.ts, broadcast_channel_test.ts and globals_test.ts pass locally. dprint check on the changed files is clean.

AI disclosure: this PR was written with help from an AI coding assistant. I tested it with the issue's repro and the unit tests above. I've also reviewed the changes myself.

Move the toStringTag of CustomEvent, ErrorEvent, MessageEvent,
ProgressEvent, PromiseRejectionEvent and Worker from an own instance
field to a non-writable, non-enumerable property of the prototype, and
add the missing tag to BroadcastChannel, CloseEvent, EventSource and
Navigator, as required by Web IDL.

Refs denoland#37107

Generated-by: Grok Bot (AI coding assistant)
@linzch3

linzch3 commented Nov 5, 2026

Copy link
Copy Markdown
Author

@bartlomieju gentle ping — Symbol.toStringTag on a few interface prototypes; small web-compat fix (。•ᴗ•。)

NetOpWibby pushed a commit to theende/ende that referenced this pull request Nov 7, 2026
Move the toStringTag of CustomEvent, ErrorEvent, MessageEvent,
ProgressEvent, PromiseRejectionEvent and Worker from an own instance
field to a non-writable, non-enumerable property of the prototype, and
add the missing tag to BroadcastChannel, CloseEvent, EventSource and
Navigator, as required by Web IDL.

Ende change: drop the TODOs that referred to the removed instance
fields. This fixes part of denoland/deno#37107: the canvas, image,
WebGPU, WorkerNavigator and Storage interfaces still have no tag.

(cherry picked from commit eff3c8bdde8bf6a5afe2d0c07d53d7e16b7e9be9)

Upstream: denoland/deno#37125
@CLAassistant

CLAassistant commented Nov 8, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants