EventSource only works with HTTP channels

NEW
Unassigned

Status

()

defect
4 years ago
a month ago

People

(Reporter: bzbarsky, Unassigned)

Tracking

Trunk
x86
macOS
Points:
---

Firefox Tracking Flags

(firefox40 affected)

Details

Attachments

(1 attachment)

Per spec, EventSource should work with any channel.  And this simple testcase works in Chrome:

<script>
  var e = new EventSource("data:text/event-stream;charset=UTF-8,data:hey%0a%0a");
  e.addEventListener("message", function(e) {
    alert(e.data);
    this.close();
  })
</script>

There's a bunch of stuff in EventSource code that prevents this from working:

1)  Explicit checks for the http/https schemes in EventSource::CheckCanRequestSrc.

2)  What looks like a bogus use of DISALLOW_INHERIT_PRINCIPAL in the same function.

3)  QIs to nsIHttpChannel various places.

This code needs to be weaned off its HTTP dependency, really.

Comment 2

4 years ago
Does it really make sense to make this generic though? Requiring http/https seems okay to me. But I guess we'd need to convince Chrome.
Sure.  Either we need to get the spec changed and convince Chrome to change or implement the spec or something.
Given that this API is mainly syntax sugar on top of XHR/fetch(), I don't really have any opinion either way.

Comment 5

4 years ago
Persuaded by Ian that we should fix this. With a "Fetch layer" this would work automatically.
Component: DOM → DOM: Core & HTML
Product: Core → Core
You need to log in before you can comment on or make changes to this bug.