Closed Bug 1136200 Opened 5 years ago Closed 5 years ago

Verify request type is no-cors if Service Worker returns opaque response.


(Core :: DOM: Workers, defect)

33 Branch
Not set



Tracking Status
firefox39 --- fixed


(Reporter: nsm, Assigned: nsm)




(1 file, 1 obsolete file)

Mentor: nsm.nikhil
Whiteboard: [good first bug][lang=C++]
"no-cors" mode is used, for example, when a page has an <img> tag with src="" where the image is displayed, or canvas where you may set the bitmap to another origin but then may no longer access the data.

If a service-worker returns an opaque Response it must have been in response to a Request with mode "no-cors".

Implement Section 4.2 step 2.2 -

1) In dom/fetch/ServiceWorkerEvents.cpp, in the ResolvedCallback(), after unwrapping the Response check that if the initiating Request (the implementer will have to add some way to get at the FetchEvent's Request, or just track what the Request's mode was) has mode no-cors and Response's Type() is not opaque, to just return.

2) Write a test case using mochitest in dom/workers/test/serviceworkers/fetch/fetch_tests.js to add a call to fetch("crossOriginURL", { mode: "no-cors" }). There are a couple of tests.
a) no-cors request, sw returns opaque response -> pass
b) "same-origin" request, sw returns opaque response -> error
Whiteboard: [good first bug][lang=C++]
Assignee: nobody → nsm.nikhil
Mentor: nsm.nikhil
Attached file MozReview Request: bz://1136200/nsm (obsolete) —
/r/5547 - Bug 1136200 - Verify request type is not no-cors if response is opaque

Pull down this commit:

hg pull review -r 17ea7e7061bf0814a0b3f13fc8b94b3679545af8
Attachment #8578876 - Flags: review?(josh)
Comment on attachment 8578876 [details]
MozReview Request: bz://1136200/nsm

::: dom/workers/ServiceWorkerEvents.cpp
(Diff revision 1)
>      return;

This isn't a network error, is it? Doesn't this make the original request go through unintercepted?
Attachment #8578876 - Flags: review?(josh)
Comment on attachment 8578876 [details]
MozReview Request: bz://1136200/nsm

Ship It!
Attachment #8578876 - Flags: review+
Closed: 5 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
You need to log in before you can comment on or make changes to this bug.