Skip to content

test(e2e): headless IME preedit-geometry coverage for Korean and CJK terminal input [NOT FOR MERGE] - #13290

Closed
nwparker wants to merge 5 commits into
nwparker/ime-structural-forwarderfrom
nwparker/ime-e2e-korean-headless
Closed

nwparker wants to merge 5 commits into
nwparker/ime-structural-forwarderfrom
nwparker/ime-e2e-korean-headless

Conversation

@nwparker

@nwparker nwparker commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Draft — not for merge. This is coverage-only. It adds no product code and changes no behaviour. It exists to become the acceptance criteria for the IME re-land stack, and three of its tests are red on main on purpose.

Why

Both IME defects that shipped and were reverted walked straight through a suite of ~3000 passing IME assertions. Every one of those assertions was about bytes reaching the PTY, and a preedit rendered into a hidden overlay satisfies all of them while the user composes blind. The one arm that asserted real geometry correctly was @headful, env-gated and macOS-only, so it never ran in CI and was deleted with the revert.

What changed

Composition is driven through CDP Input.imeSetComposition rather than a native input source, which removes the accessibility grant, the system input source and the visible window that forced the headful gate. The suite runs in the ordinary electron-headless project.

The load-bearing assertion is the composition overlay's real bounding rect. Verified to have teeth: with .composition-view.active { max-width: 0; overflow: hidden } injected — invisible on screen — the active class, the textContent, display: block and checkVisibility() === true all still pass, and only the rect assertion fails.

New files, all under tests/e2e/:

file role
terminal-korean-preedit-visibility.spec.ts 2-Set Hangul: assembly, geometry, resumed preedit, fast cadence, commit-before-newline
terminal-cjk-ime-committed-text.spec.ts Japanese phrase preedit; Chinese pinyin; full-width punctuation and digits
terminal-ime-preedit-overlay-probe.ts overlay geometry sampler and its assertions
terminal-ime-cdp-composition.ts CDP composition drivers
terminal-ime-recorded-dom-trace-replay.ts per-event recorded-trace replay with a geometry sample at every composition event
fixtures/windows-wsl-2set-hangul-dom-trace.json derived from the sealed read-only Windows/WSL capture, which is unmodified

Results on this commit

10 tests, 55.4s serially on macOS. 7 green, 3 test.fail().

test on main closed by
Hangul jamo assemble, preedit visible, syllable before newline pass —
Recorded Windows/WSL Hangul session, preedit visible at all 37 updates pass —
Back-to-back syllables at full cadence, nothing lost or duplicated pass —
Japanese phrase preedit widens and commits the kanji pass —
Chinese pinyin conversion plus trailing full-width stop pass —
Full-width punctuation / digits, keydown already carries the glyph pass —
Preedit resumed by a bare compositionupdate fail the parked resumed-preedit visibility fix
Full-width punctuation, keydown carries the ASCII layout key fail the structural forwarder
Full-width digits, keydown carries the ASCII layout key fail the structural forwarder

The three red ones carry test.fail() and an @ime-known-broken tag, so they run in CI, stay visible in the report, and fail the run the moment their fix lands — which forces the marker to be removed rather than the test to be forgotten.

Findings worth reading before the re-land

  1. The recorded Windows/WSL capture does not contain the resume-without-compositionstart ordering. The source recorder logged every event twice — once on dispatch, once as a batched next-frame snapshot. Replaying both copies makes a compositionupdate follow an already-replayed compositionend, which manufactures the shape. Filtering to the dispatch-phase records leaves 11 balanced start/end pairs and all 37 updates inside them: zero resumes. The fixture here keeps only the dispatch phase, and the resumed-preedit test is therefore synthesised and says so — the shape is still reachable, because xterm adds .active only in its compositionstart handler and its compositionupdate handler never re-adds it, which this PR reproduces headlessly against a live overlay.

  2. The full-width punctuation regression is not testable while the bypass reads an input source. The keydown carries the plain Latin ,; the , exists only in the following input event. The bypass that would prevent the ASCII byte is gated on the OS reporting an input source id matching a 23-term allowlist. That probe returns null on every non-macOS host and com.apple.keylayout.* on a macOS runner with no CJK source selected, and the preload API surface is frozen so no spec can stub it. Correctness here is not expressible as a test until the gate goes away — which is an argument for the structural rule independent of the ones already made for it.

  3. event.key-rewritten punctuation is not regression coverage. xterm's own key handler emits event.key, so that shape passes with or without a forwarder and would have passed throughout the regression. It is kept, and labelled as such.

Not covered

  • Never executed on Linux. CI runs these on ubuntu under xvfb; font metrics and the UA override should carry over, but that is unverified here.
  • No native-IME arm. These specs prove the renderer and PTY path; they do not prove the OS hands Chromium the events assumed.
  • The macOS candidate-window anchoring regression is not covered — the OS reads the focused textarea's rect, which is outside what a page-level assertion can see.

Made with Orca 🐋

@nwparker
nwparker changed the base branch from main to nwparker/ime-structural-forwarder August 9, 2026 03:35
@nwparker
nwparker force-pushed the nwparker/ime-e2e-korean-headless branch 3 times, most recently from 0c87b5f to 7c19638 Compare August 9, 2026 04:49
@nwparker
nwparker force-pushed the nwparker/ime-structural-forwarder branch from 39379d4 to 0b0aa25 Compare August 9, 2026 08:17
@nwparker
nwparker force-pushed the nwparker/ime-e2e-korean-headless branch from d46e339 to fc54888 Compare August 9, 2026 08:18
nwparker and others added 5 commits August 9, 2026 01:57
…input

Both IME defects that shipped and were reverted walked through a suite of ~3000
passing assertions, because every one of them was about bytes reaching the PTY.
A preedit rendered into a hidden overlay satisfies all of them while the user
composes blind. The real-geometry coverage that would have caught it existed but
was headful, env-gated and macOS-only, so it never ran in CI.

Drives composition through CDP Input.imeSetComposition instead of a native input
source, which removes the accessibility grant and the system input source that
forced the headful gate. The suite runs in the normal headless project in about
55s serially, and asserts the composition overlay's real bounding rect — the one
property an overlay clipped to max-width:0 cannot fake and a DOM emulator cannot
produce.

Three tests are red on main and marked test.fail() so they stay visible in CI and
flip loud when their fix lands: the preedit resumed by a bare compositionupdate,
and full-width punctuation and digits committed from a keydown that still carries
the ASCII layout key.

Co-authored-by: Orca <[email protected]>
Validated on real macOS hardware: with the two fixes below this layer, all
three report "Expected to fail, but passed". Korean preedit renders at
non-zero geometry through every jamo, and an Apple pinyin source sends
ef bc 8c e3 80 82 to the pty where main sends ASCII.

Worth recording why the punctuation case looked green on main once: an input
source whose id happens to contain an allowlist term, as Sogou's does, satisfies
the old gate. Correctness there depended on which IME the user had selected.

Co-authored-by: Orca <[email protected]>
The ten headless IME specs on this branch all decided ownership through a macOS
user-agent override, so the two platforms whose failure mode is a *dropped*
character rather than a downgraded one had no coverage at all, and the one
Windows-recorded trace already in the suite was replayed under whichever policy
the runner happened to report — macOS locally, Linux on the CI shards.

Adds four Linux specs and two Windows specs, every one of them replaying a
native capture rather than a hand-authored ordering:

- IBus/X11 Hangul mixed with literal ASCII. Its `compositionend` is EMPTY and
  the syllable arrives afterwards as a bare `insertText`, so reading the commit
  off `compositionend.data` — which the Windows capture rewards — drops every
  syllable on this framework.
- fcitx5/Wayland Hangul. No keydown at all for a composing key, not even 229,
  and physically wrong `code` values on the literal keys. Any ownership rule
  reading 229 or `code` fails here.
- Numeric pinyin candidate selection under both frameworks, with the ordinary
  digit kept as the negative control, so the two directions are pinned against
  each other rather than separately.
- Windows Microsoft Korean captured with real scan codes, including the two
  lines committed with Shift held.

Each asserts both sides of the boundary: the preedit's real geometry at every
frame the user would see, and the exact byte stream the native run put on the
PTY. The recorded `onData` the Windows/WSL fixture already carried is now
asserted instead of sitting unused.

Chinese moves up to first-class alongside Korean: pinyin preedit width is now
pinned the way the Japanese phrase already was, and full-width punctuation is
covered in the composition-session shape the Windows and Linux frameworks use,
not only the macOS insertText shape.

Two harness fixes fell out of the recorded traces and are why the IBus one
passes. The replay applied each event's recorded textarea state *after*
dispatch, one event too late for the handlers that read `textarea.value`; and
it left a task boundary between `compositionend` and the `input` carrying the
commit, which Chromium never inserts, letting xterm's deferred finalizer settle
against a textarea the committed text had not reached yet.

Co-authored-by: Orca <[email protected]>
…esising them

The macOS coverage on this branch drives Chromium composition through CDP, which
is genuine but hand-ordered, so it could not assert the one property that
decides the macOS rule: a composing keydown arrives with keyCode 229 while `key`
is still the single translated character the input source produced — `ㅎ`, not
`Process` — which is indistinguishable by length from an ordinary printable key.
Three native captures were sitting unused in the evidence set.

Adds a recorded 2-Set Korean session, including the syllable boundary where one
composition closes and the next opens with no keydown between them, asserted
against its own recorded byte stream.

Adds the third failure mode, which had no coverage in any shape: an abandoned
preedit leaking to the shell. Pinyin and Cangjie both backspace a composition
away to nothing, and the assertion is not "the right bytes" but "no bytes".

Both cancellation captures continue with a literal `ordinary` typed as bare
keydowns, the recorder's own negative control. That tail carries no `input`
events because the build it was captured on produced the byte from the keydown
itself, so replaying it would measure the recorder rather than the product; the
specs cut at the `compositionend` and say so.

Co-authored-by: Orca <[email protected]>
… the suite

Qingg matches none of the terms the pre-structural build enumerated, so on that
build its bypass never installs. It is the one arm no headless spec can express,
and the only test here that the pre-structural build cannot pass.

Promoted from scratch with four changes, each forced by a measurement rather than
by taste:

- A non-attached input method is a refusal, not a negative result. macOS attaches
  per app instance and the attach can simply fail — 3 of 6 instances under
  exclusive host access, and re-selecting the source did not recover one of them
  across 9 keystrokes. That is now `test.skip()` with a reason naming the rerun,
  not a thrown error, and the suite does not gate on a fully green session.
- Attachment is probed with a LETTER. Punctuation substitution emits no
  compositionstart and no keyCode 229 even under a fully attached source, so at
  the keydown it is indistinguishable from having no source at all. The
  punctuation arms are judged on PTY bytes alone.
- The ASCII-layout control is now part of the spec rather than a side experiment.
  Without it a build that rewrote every `.` into `。` unconditionally would pass
  the Qingg arm and be badly wrong.
- The assertion runs by default instead of behind a strict-mode flag, and gained
  a non-vacuity check: the input source must have committed something. That is
  the sharp end of the mechanism — on the old build the DOM carries only keydown
  and keyup, so nothing is committed at all and the character is destroyed before
  the source is asked.

The verdict stays an equality between two measurements, never a comparison
against a hardcoded glyph, so it holds whatever punctuation mode the operator's
input source happens to be in. It reads `beforeinput`, not `input`: the forwarder
consumes `input` in the capture phase on the pane element, so a probe on the
helper textarea never sees it and a strict run fails with correct bytes
underneath.

Co-authored-by: Orca <[email protected]>
@nwparker

Copy link
Copy Markdown
Contributor Author

Superseded by #14500 (41ba29d), which is merged.

Closing because its condition was met, not because it was wrong. The [NOT FOR MERGE] was always conditional — three tests were red on main on purpose, marked test.fail() so they would break the build the day their fixes landed. #13284 and #13288 landed, a later commit here dropped the markers, and all 12 tests now pass.

Not rebased: this branch still carried the preedit product commit that shipped as #13284, so replaying it onto main conflicted immediately, and it had drifted 152 files behind. #14500 takes the 5 files it genuinely contributes onto a fresh branch.

Two things surfaced while landing it, recorded here since they came from this work:

  • terminal-ime-cdp-composition.ts reached main in a trimmed form — key-dispatch helpers only, no composition drivers — so the specs failed on first run with composeHangulSyllable is not a function. test(e2e): headless preedit-geometry coverage for Korean and CJK terminal input #14500 restores them.
  • The geometry assertion was re-verified rather than taken on trust: with max-width: 0; overflow: hidden injected, the active class, textContent, display: block and checkVisibility() all still pass and only overlay has zero width fails. The teeth are real.

@nwparker nwparker closed this Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant