diff options
| author | Tianren Dong <tianrendong.dtr@gmail.com> | 2026-06-01 21:40:07 -0400 |
|---|---|---|
| committer | Tianren Dong <tianrendong.dtr@gmail.com> | 2026-06-01 21:40:07 -0400 |
| commit | 1c7cb9934275731de8f2fe950a0aa461637e5450 (patch) | |
| tree | d59c70c90f2561777fc507b23402bff8ae9aa086 /test-suite | |
| parent | f7f6e2a7c6faf5da532a7486e820f45bdddce85d (diff) | |
0.15.34: tabs Pi uses join session group; fix punctuation dropped by chrome_type/chrome_key (US-layout keymap)
Diffstat (limited to 'test-suite')
| -rw-r--r-- | test-suite/unit/csp-eval.test.mjs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test-suite/unit/csp-eval.test.mjs b/test-suite/unit/csp-eval.test.mjs index 24101fb..69f7943 100644 --- a/test-suite/unit/csp-eval.test.mjs +++ b/test-suite/unit/csp-eval.test.mjs @@ -164,6 +164,27 @@ async function run() { "waitFor: missing selector times out", ); + // ===== usKeyLayoutForChar / cdpKeyInfo: US-layout key codes ===== + // Regression: punctuation must NOT use charCodeAt() (".":46 collides with VK_DELETE, + // "-":45 with VK_INSERT), which made apps drop the char on keydown. + const { usKeyLayoutForChar, cdpKeyInfo } = sandbox; + const period = usKeyLayoutForChar("."); + ok(period.code === "Period" && period.keyCode === 190 && !period.needShift, "keylayout: '.' -> Period/190 (not 46)"); + const dash = usKeyLayoutForChar("-"); + ok(dash.code === "Minus" && dash.keyCode === 189, "keylayout: '-' -> Minus/189 (not 45)"); + const slash = usKeyLayoutForChar("/"); + ok(slash.code === "Slash" && slash.keyCode === 191, "keylayout: '/' -> Slash/191"); + const at = usKeyLayoutForChar("@"); + ok(at.code === "Digit2" && at.keyCode === 50 && at.needShift, "keylayout: '@' -> Digit2/50 + shift"); + const A = usKeyLayoutForChar("A"); + ok(A.code === "KeyA" && A.keyCode === 65 && A.needShift, "keylayout: 'A' -> KeyA/65 + shift"); + const a = usKeyLayoutForChar("a"); + ok(a.code === "KeyA" && a.keyCode === 65 && !a.needShift, "keylayout: 'a' -> KeyA/65 no shift"); + const dot = cdpKeyInfo("."); + ok(dot.code === "Period" && dot.windowsVirtualKeyCode === 190 && dot.text === ".", "cdpKeyInfo: '.' -> Period/190 with text"); + const ent = cdpKeyInfo("Enter"); + ok(ent.code === "Enter" && ent.windowsVirtualKeyCode === 13, "cdpKeyInfo: named key 'Enter' unaffected"); + console.log(`\n${passes} passed, ${failures} failed`); if (failures) process.exit(1); } |
