Closed
Bug 931243
Opened 11 years ago
Closed 9 years ago
XMLHttpRequest should be disabled on ServiceWorkers
Categories
(Core :: DOM: Workers, defect)
Tracking
()
RESOLVED
FIXED
mozilla44
Tracking | Status | |
---|---|---|
firefox44 | --- | fixed |
People
(Reporter: nsm, Assigned: ehsan.akhgari)
References
Details
(Keywords: dev-doc-needed, site-compat)
Attachments
(1 file, 1 obsolete file)
11.64 KB,
patch
|
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
Reporter | ||
Updated•11 years ago
|
Blocks: ServiceWorkers
Comment 1•10 years ago
|
||
(In reply to Nikhil Marathe [:nsm] (needinfo? please) from comment #0)
> See
> https://github.com/slightlyoff/ServiceWorker/blob/master/advanced_topics.md
That link is broken.
Comment 2•10 years ago
|
||
I made some changes. The when open is called from the proxy object that glues workers XMLHttpRequest to the main thread XMLHttpRequest, it sets the async option to true if it is a serviceWorker. Am I on the right track here?
Also, I don't know how to test this directly. I was thinking of registering a serviceWorker with the synchronous option to true and the test whether it blocked a timeout or not. But that seems to me a roundabout way of doing it. Let me know what you think.
Attachment #8517806 -
Flags: feedback?(nsm.nikhil)
Comment 3•10 years ago
|
||
Why is the sync option being removed from workers (i.e. non-main threads)? Is FileReaderSync also deprecated in ServiceWorkers?
Where is the spec about this? The link is broken as you said.
Reporter | ||
Comment 4•10 years ago
|
||
Please file a spec issue at https://github.com/slightlyoff/ServiceWorker/issues about whether this topic that was discussed several months ago is something we want to enforce.
Reporter | ||
Comment 5•10 years ago
|
||
Comment on attachment 8517806 [details] [diff] [review]
disable Synchronous XMLHttpRequest in ServiceWorkers
Review of attachment 8517806 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/workers/XMLHttpRequest.cpp
@@ +1913,5 @@
> return;
> }
>
> + if (!aAsync && mWorkerPrivate->IsServiceWorker()){
> + aAsync = true;
We don't want to do this, doing something unexpected. The spec issue is where discussion should happen, but my suggestion (and feel free to put this in the issue) is that we throw a AbortError here, along with a devtools warning.
Attachment #8517806 -
Flags: feedback?(nsm.nikhil)
Reporter | ||
Comment 6•9 years ago
|
||
XHR is not exposed on ServiceWorkers at all - https://github.com/whatwg/xhr/issues/19
Summary: Sync XMLHttpRequest should be disabled on ServiceWorkers → XMLHttpRequest should be disabled on ServiceWorkers
Reporter | ||
Updated•9 years ago
|
Attachment #8517806 -
Attachment is obsolete: true
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → ehsan
Updated•9 years ago
|
Keywords: dev-doc-needed
Assignee | ||
Comment 9•9 years ago
|
||
Attachment #8676249 -
Flags: review?(bzbarsky)
Comment 10•9 years ago
|
||
Comment on attachment 8676249 [details] [diff] [review]
Remove the XMLHttpRequest APIs from ServiceWorkerGlobalScope
>+ assert_equals(e.data.xhr, false);
assert_false(e.data.xhr) is more idiomatic, right?
r=me, though we'll see if people end up crying out for this in service workers...
Attachment #8676249 -
Flags: review?(bzbarsky) → review+
Comment 11•9 years ago
|
||
(In reply to Boris Zbarsky [:bz] from comment #10)
> r=me, though we'll see if people end up crying out for this in service
> workers...
XHR ergonomics are heavily penalized in service workers compared to fetch(). An XHR would have to read into an arraybuffer and then do new Response() in order to intercept. Its much easier just to use fetch() directly.
Assignee | ||
Comment 12•9 years ago
|
||
(In reply to Ben Kelly [:bkelly] from comment #11)
> (In reply to Boris Zbarsky [:bz] from comment #10)
> > r=me, though we'll see if people end up crying out for this in service
> > workers...
>
> XHR ergonomics are heavily penalized in service workers compared to fetch().
> An XHR would have to read into an arraybuffer and then do new Response() in
> order to intercept. Its much easier just to use fetch() directly.
Well, for the record, while that is true, removing XHR has a huge downside of making all of the existing libraries that use XHR useless for using inside service workers. I wouldn't be surprised at all that we would have to add it back to service workers at some point because of this reason, but I guess it's easier to add it later than take it away.
Comment 13•9 years ago
|
||
Comment 14•9 years ago
|
||
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox44:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
Comment 15•9 years ago
|
||
Posted the site compatibility doc: https://www.fxsitecompat.com/en-US/docs/2015/xmlhttprequest-is-no-longer-available-in-service-workers/
Keywords: site-compat
You need to log in
before you can comment on or make changes to this bug.
Description
•