fix: 修复 dashboard 自动刷新失效#40
Open
KanoCifer wants to merge 8 commits into
Open
Conversation
- 改为 chrome.runtime.sendMessage 广播,命中 dashboard 与 popup 两个 runtime 监听。 - 测试:新增 background-notify.test.js 行为测试(广播通道、错误吞掉逻辑), 并修正 ui-regression.test.js 对注释中残留旧 API 的假阳性断言。 - manifest.json: 版本号 1.1.1->1.1.2。
Contributor
There was a problem hiding this comment.
Pull request overview
该 PR 旨在修复 Issue #39 中「新标签页 dashboard 自动刷新失效」的问题:background 侧不再走 content script 通道,而改用 chrome.runtime.sendMessage 向扩展内页面广播 tabs-changed,以命中 dashboard 与 popup 的 runtime.onMessage 监听,从而恢复自动刷新链路。
Changes:
background.js:将 tab 变更通知改为chrome.runtime.sendMessage广播tabs-changed消息。- 新增
background-notify.test.js:覆盖广播通道与错误吞掉/告警行为。 ui-regression.test.js:更新对 background 通知实现的回归断言;manifest.json:版本号1.1.1 → 1.1.2并格式化 permissions。
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| extension/background.js | 将 tab 变更通知改为 runtime 广播,减少对 tab 查询/逐 tab 发送的依赖 |
| extension/background-notify.test.js | 新增行为测试,验证广播与错误处理预期 |
| extension/ui-regression.test.js | 更新回归断言以反映新的通知机制 |
| extension/manifest.json | 版本号升级并调整 permissions 的格式 |
Comments suppressed due to low confidence (1)
extension/ui-regression.test.js:1068
- ui-regression.test.js 里对 background.js 的字符串断言仍硬编码了单引号(例如 action/source),但 background.js 本次改动已改为双引号。这样这些 assert.match 会变成假阴性并导致测试失败;建议用 ['"] 同时匹配单/双引号,或改为与 background.js 当前风格一致。
assert.doesNotMatch(bgJs, /await chrome\.tabs\.sendMessage/);
assert.match(bgJs, /action:\s*'tabs-changed'/);
assert.match(bgJs, /triggerTabId/);
assert.match(bgJs, /source:\s*'tabs\.onCreated'/);
assert.match(bgJs, /source:\s*'tabs\.onUpdated'/);
背景广播无接收方错误消息匹配中英双语(/接收端不存在|Receiving end/i) 真正异常添加去重保护避免刷屏(notifyTabHarborPages._lastWarn) ui-regression 断言收紧禁止任何形式 chrome.tabs.sendMessage (此前仅排除 await 前缀写法)
将 tab 变更通知从 content script 通道改为 chrome.runtime.sendMessage 广播,命中 dashboard 与 popup 的 runtime.onMessage 监听。 - 静默吞掉无接收方时的连接错误(兼容中英双语消息) - 非连接类异常添加去重保护避免刷屏 - 新增 background-notify.test.js 行为测试 - 同步更新 ui-regression.test.js 断言,收紧 chrome.tabs.sendMessage 检查 - manifest.json 版本号 1.1.1 -> 1.1.2
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…change-notify-runtime-channel
groupMap.__landing_pages__ = undefined 在 groupMap 中残留一个 undefined 值,导致 Object.values 后 sort 比较器访问 a.domain 时抛出 TypeError。当用户打开了落地页域名根路径的标签页时触发, 表现为标签页变更后 dashboard 渲染失败。
chrome.runtime.sendMessage 在 dashboard 与 popup 都关闭时必定抛 "Receiving end does not exist",这是正常现象。原 catch 仍 console.warn 产生噪音日志。改为仅当错误非该连接错误时才告警。
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.
改为 chrome.runtime.sendMessage 广播,命中 dashboard 与 popup 两个 runtime 监听。
测试:新增 background-notify.test.js 行为测试(广播通道、错误吞掉逻辑), 并修正 ui-regression.test.js 对注释中残留旧 API 的假阳性断言。
manifest.json: 版本号 1.1.1->1.1.2。
关联issue #39