Closed Bug 1131271 Opened 10 years ago Closed 10 years ago

Set ServiceWorker script redirection limit to zero

Categories

(Core :: DOM: Core & HTML, defect)

33 Branch
x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: nsm, Assigned: nsm)

References

Details

Attachments

(2 files, 1 obsolete file)

Attached file MozReview Request: bz://1131271/nsm (obsolete) (deleted) —
/r/3627 - Bug 1131271 - Set ServiceWorker script redirect limit to zero. Pull down this commit: hg pull review -r 22ad0e6c8503897a70c98bca39b7783bedebf653
Attachment #8561658 - Flags: review?(bkelly)
Nikhil, where does it say redirects should not be allowed? That section you link only checks redirect count if there was already an error.
Flags: needinfo?(nsm.nikhil)
Good catch! It sounds weird now though, why do we discriminate between a network error and one that is specifically a redirect? Anne, is this some Fetch thing?
Flags: needinfo?(nsm.nikhil) → needinfo?(annevk)
Comment on attachment 8561658 [details] MozReview Request: bz://1131271/nsm Dropping review flag until we sort out the spec.
Attachment #8561658 - Flags: review?(bkelly)
Assignee: nobody → nsm.nikhil
The spec has been modified. It says if the request is a network error or response is not in range 200-299, fail with type error. In accordance with that I've changed the failure codes. The GetResponseSucceeded() on the channel checks for the 200-299 case. The spec says to set the manual redirection flag on the request. What this does in the fetch algorithm is on a 302-308 code, respond with that as a response rather than internally handling the redirect. Necko would allow us to do something like this using the async redirect callbacks used by FetchDriver and nsCORSListenerProxy, but setting the limit to zero is the easier way.
Attachment #8576287 - Flags: review?(bkelly)
Comment on attachment 8576287 [details] [diff] [review] Set ServiceWorker script redirect limit to zero Review of attachment 8576287 [details] [diff] [review]: ----------------------------------------------------------------- r=m with comments addressed. Mainly curious if we want all errors to be type errors or only redirect limit errors. Ehsan, can you look this over as neither Nikhil or myself are DOM peers? Thanks. ::: dom/workers/ServiceWorkerManager.cpp @@ +532,5 @@ > nsresult aStatus, uint32_t aLen, > const uint8_t* aString) MOZ_OVERRIDE > { > if (NS_WARN_IF(NS_FAILED(aStatus))) { > + Fail(NS_ERROR_DOM_TYPE_ERR); Do we want to throw TYPE_ERR on all these? Or do we want to look explicitly for NS_ERROR_REDIRECT_LOOP and convert to a TYPE_ERR only in that case?
Attachment #8576287 - Flags: review?(ehsan)
Attachment #8576287 - Flags: review?(bkelly)
Attachment #8576287 - Flags: review+
Comment on attachment 8576287 [details] [diff] [review] Set ServiceWorker script redirect limit to zero Ben's review should be enough.
Attachment #8576287 - Flags: review?(ehsan)
Nikhil, this needs a test. Were you planning to write one?
Flags: needinfo?(nsm.nikhil)
(In reply to Ben Kelly [:bkelly] from comment #7) > Comment on attachment 8576287 [details] [diff] [review] > Set ServiceWorker script redirect limit to zero > > Review of attachment 8576287 [details] [diff] [review]: > ----------------------------------------------------------------- > > r=m with comments addressed. Mainly curious if we want all errors to be > type errors or only redirect limit errors. > > Ehsan, can you look this over as neither Nikhil or myself are DOM peers? > Thanks. > > ::: dom/workers/ServiceWorkerManager.cpp > @@ +532,5 @@ > > nsresult aStatus, uint32_t aLen, > > const uint8_t* aString) MOZ_OVERRIDE > > { > > if (NS_WARN_IF(NS_FAILED(aStatus))) { > > + Fail(NS_ERROR_DOM_TYPE_ERR); > > Do we want to throw TYPE_ERR on all these? Or do we want to look explicitly > for NS_ERROR_REDIRECT_LOOP and convert to a TYPE_ERR only in that case? Any NetworkError in fetching a SW leads to failure with TypeError in the spec. This captures that. I've added a test and will push once try agrees.
Flags: needinfo?(nsm.nikhil)
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: