Calling browser.cookies.get without storeId returns cookie for main context in containers
Categories
(WebExtensions :: General, defect, P3)
Tracking
(firefox95 affected, firefox96 affected, firefox97 affected)
People
(Reporter: apple502j, Unassigned)
References
(Depends on 1 open bug)
Details
Attachments
(1 file)
|
1.20 KB,
application/x-zip-compressed
|
Details |
User Agent: Mozilla/5.0 (Windows NT 10.0; rv:100.0) Gecko/20100101 Firefox/100.0
Steps to reproduce:
- Install the attached extension. The extension sets cookies of https://httpbin.org and reads it via two methods -
browser.cookie.getwithout storeId, and the sentCookieheader (which the website reflects back.) - On
about:addons, allow the extension to run in incognito - Click the browser action. A tab should open.
- Set random value on input, then click "Set", setting a cookie on httpbin
- Click "Fetch via browser.cookies.get", note the value of the cookie
- Click "Fetch via HTTP", confirm the value of the cookie equals step 5 (Good behavior)
- Open incognito window
- Repeat step 3-6 on incognito using different cookie value. The two values should equal, and neither should equal the value in the previous steps on normal windows. (Good behavior)
- Repeat step 3-6 on a container tab (by either copy-pasting URL or via context menu's Open in New Container Tab). (Bad behavior)
Actual results:
The HTTP cookie value and the browser.cookies.get cookie value do not match; the browser.cookies.get cookie value is from the non-container session. This is inconsistent with incognito mode's handling.
Expected results:
The HTTP cookie value and the browser.cookies.get cookie value should match.
Note that the MDN documents that for browser.cookies.get, "[b]y default, the current execution context's cookie store will be used. "
Comment 1•4 years ago
|
||
Hello,
I reproduced the issue on the latest Nightly (97.0a1/20211223215735), Beta (96.0b9/20211223202418) and Release (95.0.2/20211218203254) under Windows 10 x64 and Ubuntu 16.04 LTS.
The issue occurs exactly as per the description in the original report.
Comment 2•4 years ago
|
||
The severity field is not set for this bug.
:mixedpuppy, could you have a look please?
For more information, please visit auto_nag documentation.
Comment 3•4 years ago
|
||
This is because the implementation only accounts for private and non-private browsing modes when computing the default storeId.
context.incognitoat https://searchfox.org/mozilla-central/rev/7271a078fa0c1b858a52614ea60ac82fdd8b3d23/toolkit/components/extensions/parent/ext-cookies.js#246- set in the
ProxyContextParentconstructor at https://searchfox.org/mozilla-central/rev/7271a078fa0c1b858a52614ea60ac82fdd8b3d23/toolkit/components/extensions/ExtensionParent.jsm#469 - the
ExtensionPageContextParentclass (that is a subclass ofProxyContextParent) is constructed at https://searchfox.org/mozilla-central/rev/7271a078fa0c1b858a52614ea60ac82fdd8b3d23/toolkit/components/extensions/ExtensionParent.jsm#872,875 - The
incognitooption is forwarded at https://searchfox.org/mozilla-central/rev/7271a078fa0c1b858a52614ea60ac82fdd8b3d23/toolkit/components/extensions/ExtensionPageChild.jsm#168
This current implementation is rather complicated, we could simplify the implementation by removing the incognito property and directly deriving the incognito state from context.principal.
ProxyContextParentalready sets it at https://searchfox.org/mozilla-central/rev/7271a078fa0c1b858a52614ea60ac82fdd8b3d23/toolkit/components/extensions/ExtensionParent.jsm#480-481- We just need to ensure that the principal is forwarded from https://searchfox.org/mozilla-central/rev/7271a078fa0c1b858a52614ea60ac82fdd8b3d23/toolkit/components/extensions/ExtensionParent.jsm#869-893
After doing that refactoring, it would be rather easy to support this feature request, by reading off context.principal.originAttributes.userContextId after https://searchfox.org/mozilla-central/rev/7271a078fa0c1b858a52614ea60ac82fdd8b3d23/toolkit/components/extensions/parent/ext-cookies.js#246
Description
•