Repository navigation
Resolve relative EventSource URLs in the WPT harness - #8530
Conversation
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.
There was a problem hiding this comment.
✅ 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
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
EventSourcewith a subclass that resolves the URL against the test URL, as thefetch,RequestandResponseshims already do, and closes each source once its file is done. The remaining files get their real reasons:lastEventIdis taken from an event that was never dispatched. The config detects which implementation is running, asurl-test.tsdoes.this.close()inside a listener, and in workerdthisthere isn't the EventSource. Two of these hang, so they're disabled rather than expected to fail.Originheader, whichfetch()doesn't send.