Bug 226635 - EventSource.constructor throws an exception when the url param is an empty string
Summary: EventSource.constructor throws an exception when the url param is an empty st...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-04 02:46 PDT by zyscoder@gmail.com
Modified: 2021-06-11 09:15 PDT (History)
8 users (show)

See Also:


Attachments
Patch (1.25 KB, patch)
2021-06-04 12:08 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (3.67 KB, patch)
2021-06-04 15:56 PDT, Alex Christensen
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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