Closed
Bug 1260915
Opened 9 years ago
Closed 9 years ago
Write a test to make sure Service Worker handle userContextId correctly
Categories
(Core :: DOM: Service Workers, defect)
Core
DOM: Service Workers
Tracking
()
RESOLVED
FIXED
mozilla49
Tracking | Status | |
---|---|---|
firefox49 | --- | fixed |
People
(Reporter: huseby, Assigned: jhao)
References
Details
(Whiteboard: [userContextId][OA] btpp-acdtive)
Attachments
(1 file, 4 obsolete files)
4.83 KB,
patch
|
jhao
:
review+
|
Details | Diff | Splinter Review |
In the file ServiceWorkerManager.cpp there are three calls to createCodebasePrincipal:
https://mxr.mozilla.org/mozilla-central/source/dom/workers/ServiceWorkerManager.cpp#2428
https://mxr.mozilla.org/mozilla-central/source/dom/workers/ServiceWorkerManager.cpp#3695
https://mxr.mozilla.org/mozilla-central/source/dom/workers/ServiceWorkerManager.cpp#3900
We need to analyze how the newly created principals are being used. Are they used to isolate any browser state? If so, do we want to isolate on userContextId?
Reporter | ||
Updated•9 years ago
|
Component: DOM → DOM: Service Workers
Comment 1•9 years ago
|
||
I believe we serialize and deserialize all principal attributes. If userContextId is included there, then it should already get propagated correctly.
Updated•9 years ago
|
Summary: ServieWorkerManager needs to handle userContextId correctly → ServiceWorkerManager needs to handle userContextId correctly
Reporter | ||
Updated•9 years ago
|
Whiteboard: [userContextId] → [userContextId][OA]
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → jhao
Comment 2•9 years ago
|
||
Can someone summarize what this actually means for service workers? I have no clue what semantics you are expecting SWM to implement here.
Assignee | ||
Comment 3•9 years ago
|
||
(In reply to Ben Kelly [:bkelly] from comment #2)
> Can someone summarize what this actually means for service workers? I have
> no clue what semantics you are expecting SWM to implement here.
We only want to make sure that those principals created in ServiceWorkerManager are not used to separate browser states like cookies. If they aren't, there would be nothing to fix. If they are, we need to check if the origin attributes are passed correctly with userContextId's.
Updated•9 years ago
|
Whiteboard: [userContextId][OA] → [userContextId][OA] btpp-acdtive
Assignee | ||
Comment 4•9 years ago
|
||
As far as I can tell, we'll get scopeKeys, essentially origins, from those principals, and use it to get registration info. So, it seems that under different user context, there will be different service workers. If a user opens a web page in context A, they may access it offline later in context A, but they may not access it offline in context B.
Hi Ben and Jonas,
Just to confirm. Is this the behavior that we want?
Thanks.
Flags: needinfo?(jonas)
Flags: needinfo?(bkelly)
Comment 5•9 years ago
|
||
I guess so. To be honest I don't really understand what you are trying to achieve with the user context stuff.
From my perspective service workers are based on origins. If you are adding something to the principal such that two different pages no longer pass a principal equality test, then they should have separate service workers and separate storage.
Its important you make sure this works with QuotaManager since our storage layers are built on top of that.
Please don't make any assumptions about particular user contexts running in particular child processes. That caused us all manner of trouble with the appId extension to principals.
Flags: needinfo?(bkelly)
Assignee | ||
Updated•9 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 6•9 years ago
|
||
Thanks, Ben.
I tried open https://mdn.github.io/sw-test/ in a couple of different user contexts. I checked about:serviceworkers, and they each have their own service worker as expected. Since it behaves the way we want, there's nothing to fix. We can close this bug if Jonas has no objections.
OriginAttributes are very similar to separate profiles. You can create a profile for yourself, and a profile for your child. These profiles will have separate cookies, separate http cache, separate service-worker registrations, separate IndexedDB databases, separate Cache API storages, etc.
OriginAttributes work the same way, except that gecko is able to access all profiles without having to be restarted. So we can run one profile in one tab, and another profile in another tab.
If ServiceWorkers is written such that it always uses nsIPrincipals to do same-origin checks, and it always uses nsIPrincipal.origin when you need a serializable key (such as when writing to disk), then we should be good. If the serviceworker code ever looks at the scheme+host+port to do either of those, then we're in trouble.
And if you're ever reading back origins from disk (which were serialized using nsIPrincipal.origin), then you need to use the appropriate parsing function. Though I'm not sure which function that is actually.
Flags: needinfo?(jonas)
Comment 8•9 years ago
|
||
Yea, service workers does all that already because we had to support appId correctly.
We do look at scheme in some places, but thats just to block things like file://, etc.
Assignee | ||
Comment 9•9 years ago
|
||
Thanks to Jonas and Ben. I'm closing this bug.
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
Assignee | ||
Comment 10•9 years ago
|
||
On second thought, I probably should write an automated test for it besides testing it manually.
Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
Summary: ServiceWorkerManager needs to handle userContextId correctly → Write a test to make sure Service Worker handle userContextId correctly
Assignee | ||
Comment 11•9 years ago
|
||
This is a wip patch. It keeps failing, but I can't figure out why. If I ran this test with --keep-open=true and manually open about:serviceworkers, I can see three service workers, but by swm.getAllRegistrations() I always get 0 registration info.
Assignee | ||
Comment 12•9 years ago
|
||
Hi Ben, do you have any idea about what was wrong with my patch? I can't see why it didn't work since that's what about:serviceworkers do[1].
p.s. serviceworker.html[2] and worker.js[3] already exists in that test directory.
Thank you.
[1] https://dxr.mozilla.org/mozilla-central/source/toolkit/content/aboutServiceWorkers.js#36
[2] https://dxr.mozilla.org/mozilla-central/source/dom/workers/test/serviceworkers/serviceworker.html
[3] https://dxr.mozilla.org/mozilla-central/source/dom/workers/test/serviceworkers/worker.js
Flags: needinfo?(bkelly)
Comment 13•9 years ago
|
||
The only thing I can think is that you are getting the SWM service instance too early. Try moving it into the your function call right before you use swm.
Flags: needinfo?(bkelly)
Assignee | ||
Comment 14•9 years ago
|
||
Thanks, Ben. That didn't solve the problem, but later, with Dimi's help, I realized that registration doesn't happen right away. I needed to add a listener.
May I ask you to be the reviewer? Thanks.
Attachment #8744847 -
Flags: review?(bkelly)
Assignee | ||
Comment 15•9 years ago
|
||
Dave, do we need someone from container side to review this patch?
Flags: needinfo?(huseby)
Updated•9 years ago
|
Attachment #8744847 -
Flags: review?(bkelly) → review+
Assignee | ||
Comment 16•9 years ago
|
||
Hi Tanvi, I move the test to the contextual identity folder as you suggested. I also added some cleanup code to ensure all service workers added in this test are unregistered. Do you want to take a look? Thanks.
Attachment #8745259 -
Flags: review?(tanvi)
Assignee | ||
Updated•9 years ago
|
Attachment #8744847 -
Attachment is obsolete: true
Assignee | ||
Comment 17•9 years ago
|
||
I changed one line because the url in the previous patch still points to the service worker directory.
Attachment #8745920 -
Flags: review?(tanvi)
Assignee | ||
Updated•9 years ago
|
Attachment #8745259 -
Attachment is obsolete: true
Attachment #8745259 -
Flags: review?(tanvi)
Assignee | ||
Updated•9 years ago
|
Flags: needinfo?(huseby)
Assignee | ||
Comment 18•9 years ago
|
||
Comment on attachment 8745920 [details] [diff] [review]
Write a test to make sure Service Worker handle userContextId correctly
I talked to Tanvi. Since Ben has already given r+, this patch is good to go. I'll push to try later.
Attachment #8745920 -
Flags: review?(tanvi)
Assignee | ||
Comment 19•9 years ago
|
||
Assignee | ||
Comment 20•9 years ago
|
||
Assignee | ||
Updated•9 years ago
|
Attachment #8744279 -
Attachment is obsolete: true
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 21•9 years ago
|
||
needs rebasing
patching file browser/components/contextualidentity/test/browser/browser.ini
Hunk #1 FAILED at 0
1 out of 1 hunks FAILED -- saving rejects to file browser/components/contextualidentity/test/browser/browser.ini.rej
patch failed, unable to continue (try -v)
patch failed, rejects left in working directory
Flags: needinfo?(jhao)
Keywords: checkin-needed
Assignee | ||
Comment 22•9 years ago
|
||
Rebased. Thanks, Carsten.
Assignee | ||
Updated•9 years ago
|
Attachment #8745920 -
Attachment is obsolete: true
Assignee | ||
Updated•9 years ago
|
Flags: needinfo?(jhao)
Attachment #8746432 -
Flags: review+
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 23•9 years ago
|
||
Keywords: checkin-needed
Comment 24•9 years ago
|
||
bugherder |
Status: REOPENED → RESOLVED
Closed: 9 years ago → 9 years ago
status-firefox49:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
You need to log in
before you can comment on or make changes to this bug.
Description
•