Refactor ext-cookies.js: consolidate duplicate logic
Categories
(WebExtensions :: General, task, P3)
Tracking
(firefox96 fixed)
Tracking | Status | |
---|---|---|
firefox96 | --- | fixed |
People
(Reporter: robwu, Assigned: robwu)
References
Details
(Whiteboard: [addons-jira])
Attachments
(3 files)
ext-cookies.js has some duplication of logic. To improve maintainability, the logic should be consolidated. In bug 1669716 I am introducing a new method to derive origin attributes from the received details, that method can be expanded to resolve this bug.
Duplicate logic (only difference is to return early vs throwing error):
- query: https://searchfox.org/mozilla-central/rev/f953948db2ac26698487f5fc5c03046c29922f26/toolkit/components/extensions/parent/ext-cookies.js#188-218,224-230
- set: https://searchfox.org/mozilla-central/rev/f953948db2ac26698487f5fc5c03046c29922f26/toolkit/components/extensions/parent/ext-cookies.js#417-440,455-459
Redundant private browsing check:
- remove: https://searchfox.org/mozilla-central/rev/f953948db2ac26698487f5fc5c03046c29922f26/toolkit/components/extensions/parent/ext-cookies.js#496-501
- The check is redundant because
query
does already respect the private browsing check (and doesn't return private cookies if not allowed).
- The check is redundant because
Comment 1•3 years ago
|
||
Changing severity to N/A because this is a task.
Updated•3 years ago
|
Assignee | ||
Comment 2•3 years ago
|
||
The cookies API implementation emits a bunch of errors in some cases,
but these are not covered by unit tests. I'm going to refactor some
logic involving these checks, and before doing so I'd like to start
with unit tests with the current behavior as expectations.
Assignee | ||
Comment 3•3 years ago
|
||
Move the duplicate logic of parsing the storeId to a common place.
This patch has the following observable changes in behavior:
-
Invalid storeId (whether with the "firefox-container-" prefix or with
something else) have the same error message instead of distinct ones.
Instead of "Illegal storeId: Xor "Unknown storeId", the message is now
Invalid cookie store id: "X"`, which is also what Chromium uses. -
Invalid storeId in remove, get and getAll now result in an error,
instead of being ignored silently. This is now consistent with the
existing behavior for the cookies.set method, and also consistent with
how Chromium rejects invalid storeId values.
Assignee | ||
Comment 4•3 years ago
|
||
The query method already validates whether access to private cookies is
allowed. It cannot yield private cookies if not allowed, so checking it
again in the loop of getAll is redundant..
Updated•3 years ago
|
Comment 6•3 years ago
|
||
Backed out for causing Android xpcshell failures on test_ext_cookies_errors.js.
Failure log: https://treeherder.mozilla.org/logviewer?job_id=359704751&repo=autoland
Backout link: https://hg.mozilla.org/integration/autoland/rev/9fc1ffd42417840e9b9b6746eabcaacd6fef229b
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 7•3 years ago
|
||
Filed bug 1743616, updated test and will reland.
Comment 9•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/8a37f510e7d4
https://hg.mozilla.org/mozilla-central/rev/1a7011d80f7a
https://hg.mozilla.org/mozilla-central/rev/cfa39c8b2830
Description
•