dsh-browser-cdp 1.14.2 → 1.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/bin/cdp-render-worker.mjs +24 -3
- package/dsh-plugin.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
## 1.14.4 (2026-11-22)
|
|
2
|
+
|
|
3
|
+
**点击未映射点位按 unverified 放行(#18):`Number(undefined)` 的 NaN 比较不再把「未知」折叠成「确定 miss」。**
|
|
4
|
+
|
|
5
|
+
上游 issue [#18](https://github.com/drscrewdriver/dsh-browser-cdp/issues/18)(同 #16/#17 报告者)。pre/post 两处 `getNodeForLocation` 判定用 `Number(hit?.backendNodeId) !== backendNodeId` 比较——点位解析不到节点时 `Number(undefined)` 是 NaN,`NaN !== x` 恒真,`nodeContains(target, NaN)` 又在 `Number.isFinite` 守卫处短路返回 false:**「那里没有节点」被当成「有东西挡在上面」**。pre-check 由此不派发点击;post-check 报 miss 诱发上层重试 → 重复点击(#9 #5 同款失败模式,afterHref 分支只救了导航场景)。
|
|
6
|
+
|
|
7
|
+
- **与 #17 不重复**:#17 修在 `nodeContains` 内部(push 前补 getDocument,1.14.3),NaN 路径在 `Number.isFinite` 短路处**根本走不到 push**——1.14.3 之后本 issue 依旧存在;本版修在调用侧,两者无交集。报告者建议中的双向 `nodeContains(hitId, targetId)` 未采纳:点到祖先容器算命中的语义放宽无实证场景,且弱化 overlay 防护。
|
|
8
|
+
- **修复**:两处判定引入 `hitId`/`hitMissing`(`!Number.isFinite(hitId) || hitId <= 0`)守卫——`!hitMissing && hitId !== backendNodeId && !nodeContains(...)` 才判 miss。pre-check 未映射点位放行点击(盒模型刚量到目标确实在;点空由 jev verify 兜底);post-check 放行落到 `ok:true`(点击已派发无法撤销)。hitId 有效但不匹配时 miss 分支原样保留——overlay 防护零弱化。
|
|
9
|
+
- **stub 代理 E2E 三组对照**(确定性复现:本地 CDP 代理仅把 `getNodeForLocation` 响应改写后转发):旧 worker(v1.14.3) + 空改写 → `click-missed "…backendNodeId undefined"`(issue 原文逐字);新 worker + 空改写 → `ok=True code=ok`(点击派发);新 worker + 改写为其他有效节点(424242) → 仍 `click-missed`(防护保住)。
|
|
10
|
+
- **契约测试**:worker-dispatch 套件新增用例——hitMissing/afterMissing 守卫存在、旧 NaN 比较式消失、守卫先于 nodeContains 判定。
|
|
11
|
+
- **边界**:post-check 的 afterHref 导航判定分支零改动;`navigated` 标志 src 侧无消费方,hitMissing 放行路径不造无人读的 flag。
|
|
12
|
+
|
|
13
|
+
门禁:`npm run typecheck` 干净;`npm test` **1338 passed / 13 skipped**(+1 契约用例);worker 为直维护 .mjs 无构建面,lib 未动。
|
|
14
|
+
|
|
15
|
+
## 1.14.3 (2026-11-22)
|
|
16
|
+
|
|
17
|
+
**img-in-link 点击误报收口(#17):`nodeContains` 先请求 document,祖先/后代容错从死代码变回活防护。**
|
|
18
|
+
|
|
19
|
+
上游 issue [#17](https://github.com/drscrewdriver/dsh-browser-cdp/issues/17)(同 #16 报告者,-32000 行号级定位)。worker 的 `nodeContains()` 调 `DOM.pushNodesByBackendIdsToFrontend` 前从未 `DOM.getDocument`(`grep -c getDocument` = 0),Chrome 一律回 `-32000 Document needs to be requested first`,被 try/catch 吞掉后恒返回 false —— 「命中点可能是目标的后代」这层容错整段失效。裸目标的点击不受影响(`hitBackendId === targetBackendId` 有短路),只有**目标中心点最顶层是其后代元素**时才走死路:`<a><img></a>`、svg-in-button 等嵌套结构在 pre-check 就被判 `click-missed`,**点击根本没派发**。
|
|
20
|
+
|
|
21
|
+
- **修复**:`nodeContains` 内、push 之前补 `await call('DOM.getDocument', {})`(worker 免构建产物,改文件即生效)。不缓存是刻意的:同进程导航会使映射失效,而本路径每次点击至多两次(pre/post 各一),depth=1 的 getDocument 开销可忽略 —— 缓存反而要为 worker 不处理事件的消循环引入 `DOM.documentUpdated` 监听。
|
|
22
|
+
- **实测转绿**(Chrome 158 headless,issue 复现法):修复前 `ok=False code=click-missed`("candidate measured to 40,20 but that point resolves to backendNodeId 8");修复后同一锚点 `ok=True code=ok`,点击真实派发并带 recorded 忠实记录。
|
|
23
|
+
- **契约测试**:worker-dispatch 套件新增序数断言(getDocument 先于 push),防回归方式与既有 reload-before-guard 用例一致。
|
|
24
|
+
- **边界**:跨文档导航后 post-check 的降级路径(afterHref 导航判定)零改动;backendNodeId 跨文档复用的理论边角在 effects 契约层两种路径都产出 `ok:true`(`navigated` 标志 src 侧无消费方),无回归。
|
|
25
|
+
|
|
26
|
+
门禁:`npm run typecheck` 干净;`npm test` **1337 passed / 13 skipped**(+1 契约用例);worker 为直维护 .mjs 无构建面,lib 未动。
|
|
27
|
+
|
|
1
28
|
## 1.14.2 (2026-11-22)
|
|
2
29
|
|
|
3
30
|
**jev_* 捕获必失败修复(#16):`linkId` 与 `targetId` 语义分离 + 不再丢弃已产出的捕获。**
|
|
@@ -330,6 +330,14 @@ async function nodeContains(targetBackendId, hitBackendId) {
|
|
|
330
330
|
if (!Number.isFinite(hitBackendId) || hitBackendId <= 0) return false
|
|
331
331
|
if (hitBackendId === targetBackendId) return true
|
|
332
332
|
try {
|
|
333
|
+
// `pushNodesByBackendIdsToFrontend` refuses until a document has been
|
|
334
|
+
// requested (-32000 "Document needs to be requested first"). Nothing else
|
|
335
|
+
// in this worker ever asks for one, so every call here used to throw and
|
|
336
|
+
// the ancestor/descendant tolerance was dead code — an <a> wrapping an
|
|
337
|
+
// <img> was misreported as click-missed (issue #17). Uncached on purpose:
|
|
338
|
+
// a navigation inside this process invalidates the mapping, and this path
|
|
339
|
+
// runs at most twice per click.
|
|
340
|
+
await call('DOM.getDocument', {})
|
|
333
341
|
const pushed = await call('DOM.pushNodesByBackendIdsToFrontend', { backendNodeIds: [targetBackendId, hitBackendId] })
|
|
334
342
|
const [targetNodeId, hitNodeId] = pushed?.nodeIds ?? []
|
|
335
343
|
if (!targetNodeId || !hitNodeId) return false
|
|
@@ -414,13 +422,21 @@ async function actOnCandidate(params) {
|
|
|
414
422
|
const hit = await call('DOM.getNodeForLocation', {
|
|
415
423
|
x: Math.round(measured.centre.x), y: Math.round(measured.centre.y), includeUserAgentShadowDOM: false,
|
|
416
424
|
})
|
|
417
|
-
|
|
425
|
+
const hitId = Number(hit?.backendNodeId)
|
|
426
|
+
const hitMissing = !Number.isFinite(hitId) || hitId <= 0
|
|
427
|
+
// "No node at that point" is UNVERIFIED, not a miss (issue #18): the NaN
|
|
428
|
+
// comparison folded an unknown answer into "something is on top of it".
|
|
429
|
+
// An overlay answers with a NODE; an unmapped point (mutation race between
|
|
430
|
+
// the box model and this read, renderer-mapping limits) must not block the
|
|
431
|
+
// click the box model just measured — and in the post-check below it must
|
|
432
|
+
// not trigger a caller retry that double-clicks (issue #9 #5's failure mode).
|
|
433
|
+
if (!hitMissing && hitId !== backendNodeId && !(await nodeContains(backendNodeId, hitId))) {
|
|
418
434
|
const at = Math.round(measured.centre.x) + ',' + Math.round(measured.centre.y)
|
|
419
435
|
return {
|
|
420
436
|
ok: false,
|
|
421
437
|
code: 'click-missed',
|
|
422
438
|
message: 'candidate measured to ' + at + ' but that point resolves to backendNodeId ' +
|
|
423
|
-
String(
|
|
439
|
+
String(hitId) + ' - something is on top of it or the page moved',
|
|
424
440
|
}
|
|
425
441
|
}
|
|
426
442
|
|
|
@@ -445,7 +461,12 @@ async function actOnCandidate(params) {
|
|
|
445
461
|
const after = await call('DOM.getNodeForLocation', {
|
|
446
462
|
x: Math.round(measured.centre.x), y: Math.round(measured.centre.y), includeUserAgentShadowDOM: false,
|
|
447
463
|
})
|
|
448
|
-
|
|
464
|
+
const afterId = Number(after?.backendNodeId)
|
|
465
|
+
const afterMissing = !Number.isFinite(afterId) || afterId <= 0
|
|
466
|
+
// Same rule as the pre-check: an unmapped point is unverified (issue #18),
|
|
467
|
+
// not evidence that something is on top of the target — a miss here would
|
|
468
|
+
// make the caller retry an already-dispatched click.
|
|
469
|
+
if (!afterMissing && afterId !== backendNodeId && !(await nodeContains(backendNodeId, afterId))) {
|
|
449
470
|
// The node changed. If the URL changed too, the click navigated — that is a
|
|
450
471
|
// success, not a miss. Only report click-missed when neither the node family
|
|
451
472
|
// nor the URL accounts for the change.
|
package/dsh-plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-browser-cdp",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.4",
|
|
4
4
|
"description": "dsh-browser-cdp: visible agent browser for DSH — drives the vendored ego-compatible Chromium over CDP, and can also attach to a running Chrome/Edge/Brave or route through egolite, Tabbit and Lightpanda backends. 35 structured bcdp_* tools; only bcdp_status stays resident by default (lazy injection, −91.9% schema per turn for non-browser sessions). Realtime watch panel with direct click/scroll/IME input, element picks quoted into the composer, human-verification notices; non-CDP channels sync frames by 3s polling. Web shell: floating watch ball without dsh-better-sidebar, sidebar tab with it. Headless/TUI hosts: tools-only. [DSH 0.1.0-rc.2 ~ 0.2.2-rc.1: declarative settings via Config .volatile() fields on 0.1.7+; imperative installSection / module-level registration + describe/mutate bridge on 0.1.0 ~ 0.1.5 (experimental, pending farm). Client peers stay optional so gen-1 hosts without dsh-client-store still load; for a production install on the current line use the 0.17.x line]",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|