Bug 226635

Summary: EventSource.constructor throws an exception when the url param is an empty string
Product: WebKit Reporter: zyscoder <zyscoder>
Component: WebCore Misc.Assignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, bugs-noreply, darin, mcatanzaro, sam, webkit-bug-importer, youennf, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch darin: review+

Description zyscoder@gmail.com 2021-06-04 02:46:36 PDT
Steps to reproduce:

(1) Open a tab and navigate to any URL;
(2) Run the following code in the Console of Devtools:
```
new EventSource("")
```
(3) Then this code would throw a SyntaxError exception.

Actual results:

This code would throw a SyntaxError exception: `SyntaxError: The string did not match the expected pattern.`

Expected results:

As https://html.spec.whatwg.org/multipage/server-sent-events.html#dom-eventsource says, when the URL param is an empty string, it should be parsed as a relative URL to the API's URL.

In fact, Firefox works as the spec says, and Chrome has fixed this problem following the spec nowadays too.
Comment 1 Alex Christensen 2021-06-04 12:08:52 PDT
Created attachment 430597 [details]
Patch
Comment 2 Alex Christensen 2021-06-04 12:09:11 PDT
Seems like an easy enough fix.  Let's see if we already have tests that cover this.
Comment 3 Yusuke Suzuki 2021-06-04 12:16:11 PDT
Comment on attachment 430597 [details]
Patch

r=me
Comment 4 Alex Christensen 2021-06-04 15:56:50 PDT
Created attachment 430626 [details]
Patch
Comment 5 Darin Adler 2021-06-06 23:55:47 PDT
Looks like Yusuke already reviews, so don’t really need my review too, but I saw a review?
Comment 6 Radar WebKit Bug Importer 2021-06-11 02:47:16 PDT
<rdar://problem/79189234>
Comment 7 Alex Christensen 2021-06-11 09:15:24 PDT
r278763