✅ 修正资源分类边界并降低页面脚本资源开销 - #1686
Open
cyfung1031 wants to merge 7 commits into
Open
Conversation
cyfung1031
marked this pull request as ready for review
August 22, 2026 01:32
Collaborator
Author
|
结论:发现一个 P2,建议 Request changes,置信度高。 [P2] 非法
|
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.
摘要
修复脚本资源从 Service Worker 传到页面执行上下文时的边界问题,并降低每个标签页保留的资源 payload。
PR 仍保持为 draft,等待人工 review。已測試根因
ResourceService原先把@require、@require-css和@resource合并到一个 string-keyed map;随后页面边界会把整个 map 转发。这样既会把已经编译进注入代码的@require重复带入每个标签页,也会把未授权的@resource带入页面。更重要的是,同一个 key 在不同资源类别中出现时,合并会丢失类别来源,可能让 JavaScript 或 CSS 消费到错误的资源内容。实现
@resource <name> <url>解析器,生产者和页面筛选器使用同一套严格规则;非法声明不会创建资源或触发下载。require、require-css、resource三个类别的独立 map;保留旧的合并 map 作为兼容形状,但编译、CSS 注入、页面缓存和本地资源刷新都使用类别来源。@resource名称;@require-css声明的 CSS 资源;@require。@grant none和 context-menu 场景。base64/contentType以及本地file:///刷新行为。验证覆盖
GM_getResourceText、GM_getResourceURL、GM.getResourceText、GM.getResourceUrl。@grant none、context-menu 的none与 resource grant 组合。@resource、输入不变性和资源值完整性。@require编译顺序及页面 payload 不重复转发。@require-css的 metadata 顺序,以及 CSS key 与@resourcekey 冲突时的类别隔离。ResourceService类别保留、运行时 page cache/local refresh,以及既有 sandbox、value-update 和 execution-path tests。验证结果
pnpm run typecheck— 通过。pnpm test -- --run— 受限环境第一次运行因验证工具监听127.0.0.1被EPERM阻断;在允许本地监听的环境重跑后 341 个文件、4223 项全部通过。pnpm run build— 通过;仅有既有 bundle-size 与 Monaco 动态require警告。@require先输出PR1686_REQUIRE_LOADED,随后 page-side result 为{"resourceText":"resource payload","resourceUrlIsData":true,"cssValue":"ok"}。远端 checks 中 lint、两组 test shard、四组 E2E 和 License Compliance 均通过。
codecov/project目前失败的原因是项目总覆盖率由 base 的 70.07% 变为 70.04%(下降 0.03 个百分点);本次 patch 覆盖率为 80.6%。没有为了通过该总量指标加入无语义的测试填充。本 PR 未进行精确 heap benchmark;性能收益来自页面边界不再传输/保留无关资源,定量内存对比留给后续 profiling。
提交顺序
dd24ac17— page resource boundary filter9efb062b— grant and resource boundary tests3a04d08b— category-preserving production implementationbed1598b— category-preserving verification tests范围
maincodex/add-performance-verification-tests