Repository navigation
fix(cookies): 按每个cookie自己的originAttributes改和删(#2) - #37
Merged
Merged
Conversation
The cookies tool always passed {} as originAttributes to set and remove,
so cookies in container tabs and partitioned (third-party iframe) cookies
showed up in list but could not be changed or deleted. Single removal also
reported removed: 1 whether or not anything was deleted, and a domain
cookie (.example.com) given as example.com was never removed.
- New CookieBackend module (registered in moz.build) replaces the inline
implementation in Backends.sys.mjs and takes an injectable cookie manager.
- list marks each cookie's jar with a compact originAttributes and
isPartitioned; includePrivate adds private-window cookies, which
nsICookieManager.cookies does not return.
- remove matches the host with or without the leading dot, any path unless
path is given and every jar unless originAttributes is given, removes each
cookie with its own host and originAttributes, then re-reads the store and
counts only cookies that are really gone (failed lists the rest).
all:true still clears the normal store; includePrivate also clears the
private one.
- set writes into the given jar (default: the normal one), reads back the
exact host/name/path/jar, and for an existing cookie keeps the attributes
that were not given (secure, httpOnly, sameSite, expiry, partitioned), so
changing a value no longer drops httpOnly or the Secure that SameSite=None
needs.
- selftest-cookies.mjs: 51 checks against a fake nsICookieManager that
follows the pinned baseline's semantics.
Refs #2
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
#2要的是在浏览器里删除、修改、新增cookie(含httpOnly)。v0.21.0加的
cookies工具有几处问题:set和remove里的originAttributes固定传{}。容器标签页里的cookie、第三方iframe的分区cookie在list里看得到,但改不了也删不掉。removed。removed: 1。域cookie的host带前导点(.example.com),传example.com其实一个都没删。改动(按提交)
fix(cookies)按每个cookie自己的originAttributes操作(be2d20f):CookieBackend.sys.mjs,已在moz.build登记,替换Backends.sys.mjs里的内联实现,cookie管理器可以注入。originAttributes标出所在的罐,分区cookie另标isPartitioned。includePrivate:true时也列隐私窗口的cookie,nsICookieManager.cookies本身不含这些。path时匹配所有路径;不给originAttributes时匹配所有罐。originAttributes删,删完重新读一遍存储,只把确实没了的算进removed,没删掉的列在failed里。all:true:仍只清普通存储,加includePrivate时连隐私存储一起清。selftest-cookies.mjs共51项,用一个按锁定基线nsICookieManager语义写的假实现。docs(readme)(3b00980):工具表里的cookie一行;版本记录新开“main(尚未发布)”一节。验证
bash scripts/selftest-agent-tools.sh通过,共45步(新增cookie一步,51项)。sid报removed:1,域、容器、分区三份还在;removed:1;removed:5,容器和分区那两份还在。omni.ja并重签。用临时profile、无头模式启动,经marionette调用getBackends().cookies:(https,top.test),secure+Partitioned)、隐私窗口、httpOnly会话cookie,全部写入成功;includePrivate为5个;secure:false时被引擎拒绝,原因原样返回;includePrivate才删;子域的cookie不受影响;没验证的
已知问题(本pr未处理)
list的domain仍按host子串过滤,国际化域名要写成punycode。🤖 Generated with Claude Code