Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
bf54561
✅ 新增 example/tests 共用测试框架内核与 Console reporter
CodFrm Jul 21, 2026
c589d60
🐛 修复 sctest toEqual 的 JSON 序列化误判并补测试
CodFrm Jul 21, 2026
2a6ee46
✅ 测试框架新增 Shadow DOM 面板 reporter
CodFrm Jul 21, 2026
cc66c5b
✅ 测试框架新增 GM_log reporter 供后台/定时脚本使用
CodFrm Jul 21, 2026
b743444
🐛 移除 emitLog 中吞异常的 try/catch,补全跳过/开始日志断言
CodFrm Jul 21, 2026
ed52b93
✅ 测试框架补齐手动 suite 重跑通路与用法文档
CodFrm Jul 21, 2026
58f7ea5
🐛 修复面板失败详情在手动 suite 重跑时不渲染的问题
CodFrm Jul 21, 2026
bb5bbdc
✅ e2e 支持把测试框架 @require 重写到本地 mock server
CodFrm Jul 21, 2026
79f761e
✅ gm_api_sync_test 迁移到共用测试框架
CodFrm Jul 21, 2026
dbf482e
🐛 恢复 gm_api_sync_test 断言前的过程日志
CodFrm Jul 21, 2026
5263027
✅ gm_api_async_test 迁移到共用测试框架
CodFrm Jul 21, 2026
fa8f0ae
✅ inject_content 与 early_inject 系列迁移到共用测试框架
CodFrm Jul 21, 2026
c6af8c8
✅ sandbox_test 迁移到共用测试框架
CodFrm Jul 21, 2026
ac87145
✅ window_message 与 unwrap 系列迁移到共用测试框架
CodFrm Jul 21, 2026
e985306
✅ gm_xhr_redirect_test 迁移到共用框架并接入 e2e
CodFrm Jul 21, 2026
d1ad1ba
✅ gm_download_test 迁移到共用测试框架
CodFrm Jul 21, 2026
0ee30ea
🐛 修正 gm_download empty URL 用例一开始就写错的断言
CodFrm Jul 21, 2026
033a14c
✅ gm_download_test 接入 e2e
CodFrm Jul 21, 2026
1c1d3ef
🐛 修复手动 suite 跑完后不重新发出 onEnd 的问题
CodFrm Jul 21, 2026
a1c4483
✅ 测试框架新增用例内主动跳过通道 SCTest.skip
CodFrm Jul 21, 2026
01f3250
✅ gm_xhr_test 迁移到共用框架并接入 e2e
CodFrm Jul 21, 2026
dde2ad7
✅ gm_menu_test 迁移到共用框架,契约检查升级为断言
CodFrm Jul 21, 2026
3038fb0
✅ gm_xhr_cookie_test 迁移到共用测试框架
CodFrm Jul 21, 2026
ebf32b1
📝 更新 verification 文档以匹配统一后的测试框架输出
CodFrm Jul 21, 2026
5bd1142
📝 记录 sctest deepEqual 对 Date/Map/Set 的已知限制
CodFrm Jul 21, 2026
2b486f3
Merge branch 'main' into feat/example-tests-framework
CodFrm Jul 21, 2026
f0fd9ef
♻️ 合并 main 并适配 httpbingo 测试
CodFrm Jul 22, 2026
e2fe707
🐛 修复 SCTest 面板 CSP 注入与设计对齐
CodFrm Jul 22, 2026
762f83e
🐛 修复 SCTest 面板交互功能
CodFrm Jul 22, 2026
8382318
🐛 固定 SCTest 的提交引用
CodFrm Jul 27, 2026
98f09b0
fix: 修正 sctest 异常判定与重跑详情清理
cyfung1031 Aug 11, 2026
cad35eb
🐛 修正 GM_download 空 url 测试契约
cyfung1031 Aug 11, 2026
b7b5fc4
Merge remote-tracking branch 'origin/main' into feat/example-tests-fr…
cyfung1031 Aug 11, 2026
42b01d4
🔀 sync main into PR 1631 rework baseline
cyfung1031 Aug 14, 2026
5cf3b6c
🐛 include manual cases in skip filter
cyfung1031 Aug 14, 2026
753c74a
🐛 install E2E permission watcher before scripts
cyfung1031 Aug 14, 2026
dd1d68f
🐛 wait for permission confirmation navigation
cyfung1031 Aug 14, 2026
f3c27a5
📝 clarify E2E dependency scope
cyfung1031 Aug 14, 2026
c317eff
🐛 watch existing permission pages
cyfung1031 Aug 14, 2026
de0ee50
🐛 avoid abort race in DNS error tests
cyfung1031 Aug 14, 2026
18f6eaa
🐛 make blocked download test local
cyfung1031 Aug 14, 2026
a6bad63
♻️ 回退 gm_download_test / gm_menu_test 至迁移前
CodFrm Aug 17, 2026
66092c7
🔀 合并 origin/main (9e31780f) 并解决冲突
CodFrm Aug 17, 2026
6a942df
📝 把 in-page self-test 一节归位到 verification-methods 并修正过期注释
CodFrm Aug 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions docs/references/verification-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,26 @@ In a spec, `testWithUserScripts` and `autoApprovePermissions` solve both ([`../.

### The in-page self-test pattern

A userscript runs assertions in the page and prints a summary line the harness parses from the console. The bundled scripts in [`../../example/tests/`](../../example/tests/) do this; the line varies by script, and each emits a `通过`/`Passed` and a `失败`/`Failed` count:
A userscript runs assertions in the page and prints a summary the harness parses from the console. The bundled scripts in [`../../example/tests/`](../../example/tests/) do this. Most share one framework, [`../../example/tests/lib/sctest.js`](../../example/tests/lib/sctest.js) (loaded via `@require` and rewritten to a local mock server under E2E), so all of those emit the same four lines:

```
总计: 12 | 通过: 12 | 失败: 0 # inject_content_test.js / sandbox_test.js (combined line)
总测试数: 12 / 通过: 12 / 失败: 0 # gm_api_sync_test.js / gm_api_async_test.js (counts on separate lines)
Total: 12 | Passed: 12 | Failed: 0 # window_message_test.js (English)
总测试数: 12
通过: 12
失败: 0
跳过: 0 (34ms)
```

In a session there is nothing to wire up — the collector already recorded the line, whichever context printed it (a `@background` script prints from `src/sandbox.html`, not from a page):
A script running in a background / crontab context has no visible page, so the framework additionally emits one `GM_log` entry per case with structured labels (`sctest`, `status`) — filterable chips on the 运行日志 page. Cases that need a human action (e.g. clicking a menu item) are registered with `itManual` and count as skipped until confirmed on the panel. Writing cases against the framework is [`../../example/tests/lib/README.md`](../../example/tests/lib/README.md)'s.

Three scripts print no unified summary and have to be read on their own terms: [`gm_download_test.js`](../../example/tests/gm_download_test.js) and [`gm_menu_test.js`](../../example/tests/gm_menu_test.js) are self-contained runners carrying their own panel and human-confirmation flow (no `@require`), and [`gm_value_test.js`](../../example/tests/gm_value_test.js) is an interactive multi-frame dashboard demo for `GM_addValueChangeListener` with no machine-checkable assertions.

In a session there is nothing to wire up — the collector already recorded the lines, whichever context printed them (a `@background` script prints from `src/sandbox.html`, not from a page):

```bash
node e2e/drive.mjs console 200 | grep -E "(通过|Passed)[::] *[0-9]+"
```

In a spec, collect and assert on itthis regex matches all three layouts:
In a spec, collect and assert on themsame parse as the committed `gm-api.spec.ts` harness:

```ts
const logs: string[] = [];
Expand All @@ -52,7 +57,7 @@ expect(failed, logs.join("\n")).toBe(0);
expect(passed).toBeGreaterThan(0);
```

For a new GM API, write a small self-test userscript in the same style. In a session, `node e2e/drive.mjs install <file.user.js>` installs it through the Service Worker and `node e2e/drive.mjs console` shows the summary line the script printed; in a spec, use `installScriptByCode`. Keep the script inside the scenario directory — it is verification scaffolding, not a committed example.
For a new GM API, write a small self-test userscript in the same style. In a session, `node e2e/drive.mjs install <file.user.js>` installs it through the Service Worker and `node e2e/drive.mjs console` shows the summary the script printed; in a spec, use `installScriptByCode`. Keep the script inside the scenario directory — it is verification scaffolding, not a committed example.

## Behaviour fired from extension UI

Expand Down
6 changes: 4 additions & 2 deletions docs/verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ pnpm exec playwright test --config playwright.scratch.config.ts -g "<test title>

## Driving the session

[`../e2e/README.md`](../e2e/README.md#8-verification-sessions) owns the command reference. What matters for a
verdict:
[`../e2e/README.md`](../e2e/README.md#8-verification-sessions) owns the command reference, and
[`references/verification-methods.md`](references/verification-methods.md) the patterns for behaviour the UI does
not expose directly — the `example/tests/` in-page self-tests, Service Worker messages, themes. What matters for
a verdict:

- **Observe from a path the driven surface does not share.** `drive.mjs storage` reads `chrome.storage.local`
from an extension page, and `drive.mjs sw` evaluates inside the Service Worker — neither goes through the UI
Expand Down
Loading
Loading