Skip to content

Resolve relative EventSource URLs in the WPT harness - #8530

Merged
littledivy merged 1 commit into
mainfrom
littledivy/2026-11-17-wpt-eventsource-relative
Nov 17, 2026
Merged

littledivy merged 1 commit into
mainfrom
littledivy/2026-11-17-wpt-eventsource-relative

Conversation

@littledivy

Copy link
Copy Markdown
Member

The eventsource WPT files construct sources with paths like "resources/message.py". workerd's EventSource has no base URL to resolve them against, so 34 files were marked as failing with "EventSource does not support relative URLs", which told us nothing about EventSource itself.

In this patch the harness replaces EventSource with a subclass that resolves the URL against the test URL, as the fetch, Request and Response shims already do, and closes each source once its file is done. The remaining files get their real reasons:

  • 22 files now pass with both the C++ and the TypeScript EventSource.
  • 4 fail only with the C++ EventSource, because of parser differences: an event with empty data is dropped, a byte order mark split across chunks isn't stripped, and lastEventId is taken from an event that was never dispatched. The config detects which implementation is running, as url-test.ts does.
  • 9 call this.close() inside a listener, and in workerd this there isn't the EventSource. Two of these hang, so they're disabled rather than expected to fail.
  • 1 needs an Origin header, which fetch() doesn't send.

The eventsource WPT files construct sources with paths like
"resources/message.py". workerd's EventSource has no base URL to
resolve them against, so 34 files were marked as failing with
"EventSource does not support relative URLs", without telling us
anything about EventSource itself.

In this patch the harness replaces EventSource with a subclass that
resolves the URL against the test URL, as the fetch, Request and
Response shims already do, and closes each source once its file is
done. 22 files now pass with both the C++ and the TypeScript
EventSource. The remaining files get the real reasons: 4 fail only
with the C++ EventSource's parser, 9 depend on `this` in a listener
being the EventSource, which it isn't in workerd, and one needs an
Origin header that fetch() doesn't send.
@littledivy
littledivy requested review from a team as code owners November 17, 2026 06:44
Comment thread src/wpt/eventsource-test.ts Resolved

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — No issues found. The harness shim is small and handles invalid and empty URLs correctly, and the expectation changes match the description.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

Only test-harness code changes. No security impact.


📖 AGENTS.md: ✅ LGTM

No AGENTS.md updates needed.


📋 Code Quality: ✅ LGTM

No issues found in src/wpt/harness/globals.ts or src/wpt/eventsource-test.ts. Checked: URL.parse exists on the standard URL used by WPT tests, invalid URLs pass through to the native constructor, completion callbacks run only for sources that were constructed, and the native-code check on the inherited EventSource.from works after the shim is installed.


⚡ Performance: ✅ LGTM

No performance concerns.


📝 Documentation: ✅ LGTM

The comments describe the current behaviour.


Reviewed commit: e316673b

@littledivy
littledivy merged commit 86f804c into main Nov 17, 2026
23 checks passed
@littledivy
littledivy deleted the littledivy/2026-11-17-wpt-eventsource-relative branch November 17, 2026 07:09
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