diff options
| author | Tianren Dong <tianrendong.dtr@gmail.com> | 2026-09-26 19:07:56 -0400 |
|---|---|---|
| committer | Tianren Dong <tianrendong.dtr@gmail.com> | 2026-09-26 19:07:56 -0400 |
| commit | 238f347a03b2cefb21198bb78a90699e931d8504 (patch) | |
| tree | 4c7221441428a086e93f2767a9fb332ee97c9995 /test-suite/unit/type-evidence.test.mjs | |
| parent | df1472b8c777d40daa70da23115f4c8f5afb6623 (diff) | |
Report hidden-tab input, append targeted typing, smarter uploads, prune screenshots; release 0.15.54
- Check page visibility before trusted input: Chrome drops input to hidden pages (inactive tabs,
covered/minimized windows, macOS window tabs behind full screen). Type/key/hover/scroll/tap/drag
fail fast with the reason; click/fill use their DOM fallback immediately (or reject with
domFallback:false).
- Use an inactive tab instead of a new window for the automation target while the user's window is
full screen.
- chrome_type with uid/selector moves the caret to the end (moveToEndOfDocument) after its focus click.
- chrome_upload_file: labels/wrappers resolve to their file input, same-origin iframe search, and
intercepted file chooser for upload buttons (trusted click when visible, user-gesture click when
hidden); reject multiple paths for single-file inputs; no duplicate change event.
- Prune default-folder chrome_screenshot captures (7 days, newest 20 kept, retentionDays override).
- input.debug without a target no longer calls tabs.get(-1).
- New hidden-input unit suite.
Diffstat (limited to 'test-suite/unit/type-evidence.test.mjs')
| -rw-r--r-- | test-suite/unit/type-evidence.test.mjs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/test-suite/unit/type-evidence.test.mjs b/test-suite/unit/type-evidence.test.mjs index f0a51c1..22393be 100644 --- a/test-suite/unit/type-evidence.test.mjs +++ b/test-suite/unit/type-evidence.test.mjs @@ -59,6 +59,7 @@ function harness(element, { platform = "MacIntel", tabs = {} } = {}) { calls.push({ method, params: clone(params) }); if (method === "Input.dispatchKeyEvent") { if ((params.commands || []).includes("selectAll")) { element.selectionStart = 0; element.selectionEnd = element.value.length; } + else if ((params.commands || []).includes("moveToEndOfDocument") && typeof element.value === "string") { element.selectionStart = element.selectionEnd = element.value.length; } else if (params.type === "keyDown" && params.key === "Delete") { if (element.selectionEnd > element.selectionStart) splice(""); } else if (params.type === "keyDown" && params.text && params.key !== "Enter") splice(params.text); @@ -68,9 +69,29 @@ function harness(element, { platform = "MacIntel", tabs = {} } = {}) { return { worker, calls, element, listeners, fire: (tabId, info) => { for (const fn of [...listeners]) fn(tabId, info); } }; } -test("typing into the middle of a prefilled field reports the splice instead of a bare count", async () => { +test("a targeted chrome_type moves the caret to the end after its focus click, so it appends", async () => { const h = harness(makeInput({ value: "why do flamingos stand", caret: 7 })); - const result = await h.worker.dispatch("page.type", { targetId: "2", selector: "#q", text: "cats " }); + const result = await h.worker.dispatch("page.type", { targetId: "2", selector: "#q", text: " still" }); + assert.equal(h.element.value, "why do flamingos stand still"); + assert.equal(result.insertedAt, "caret-end"); + const moves = h.calls.filter((c) => (c.params.commands || []).includes("moveToEndOfDocument")); + assert.equal(moves.length, 1); + assert.equal(h.calls.indexOf(moves[0]) > h.calls.findIndex((c) => c.method === "Input.dispatchMouseEvent" && c.params.type === "mouseReleased"), true, "caret moves after the focus click"); +}); + +test("replace=true does not move the caret first; untargeted typing keeps the user's caret", async () => { + const replace = harness(makeInput({ value: "old", caret: 1 })); + await replace.worker.dispatch("page.type", { targetId: "2", selector: "#q", text: "new", replace: true }); + assert.equal(replace.calls.some((c) => (c.params.commands || []).includes("moveToEndOfDocument")), false); + const focused = harness(makeInput({ value: "abc", caret: 1 })); + await focused.worker.dispatch("page.type", { targetId: "2", text: "X" }); + assert.equal(focused.calls.some((c) => (c.params.commands || []).includes("moveToEndOfDocument")), false); + assert.equal(focused.element.value, "aXbc"); +}); + +test("typing into the middle of a focused prefilled field reports the splice instead of a bare count", async () => { + const h = harness(makeInput({ value: "why do flamingos stand", caret: 7 })); + const result = await h.worker.dispatch("page.type", { targetId: "2", text: "cats " }); assert.equal(h.element.value, "why do cats flamingos stand"); assert.equal(result.valueBefore, "why do flamingos stand"); assert.equal(result.valueAfter, "why do cats flamingos stand"); |
