Skip to content

chore(deps): happy-dom 20.14.5 with an OffscreenCanvas shim for the real-xterm test (#1365) - #1446

Merged
Juliusolsson05 merged 4 commits into
mainfrom
chore/happy-dom-20-14
Sep 27, 2026
Merged

Juliusolsson05 merged 4 commits into
mainfrom
chore/happy-dom-20-14

Conversation

@Juliusolsson05

@Juliusolsson05 Juliusolsson05 commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Fixes #1365.

Root cause

Only one of #1322's three failing groups was caused by happy-dom, and the cause was not event dispatch.

  • Real-xterm wheel test, 5 tests: happy-dom 20.10.0 added a global OffscreenCanvas. 20.9.0 has no lib/canvas at all.
    • xterm's WidthCache prefers new OffscreenCanvas(1, 1) whenever that global exists.
    • The test shimmed only HTMLCanvasElement.prototype.getContext, so the shim was bypassed.
    • happy-dom's OffscreenCanvas.getContext('2d') returns null without a canvas adapter, so term.open() threw value must not be falsy.
  • Keybinding recorder (7 tests) and ConversationsPicker (2 tests): not happy-dom.

Change

  1. The plan (docs/plans/2026-09-27-happy-dom-20-14-offscreen-canvas.md).
  2. Fail-first: bump happy-dom to ^20.14.5. The lockfile diff is minimal: happy-dom plus its new buffer-image-size dependency. npm's unrelated pruning of five wasm optionals was left out. With this commit alone, the existing wheel test fails 5/5 on the real open() path.
  3. The fix: shim 1 also covers OffscreenCanvas.prototype.getContext, restored in afterEach.
    • I shimmed it rather than deleting the global, because Chromium has OffscreenCanvas, so production xterm takes the same branch.
    • The WHY block drops its now-false claim that happy-dom has no OffscreenCanvas.
    • It also documents why CharSizeService still uses the DOM strategy: the fake context lacks fontBoundingBox*, so xterm's own try/catch falls back.
    • No assertion changed.

Verification

Local runs used Node 24 and happy-dom 20.14.5, confirmed via the navigator.userAgent string. A symlinked vitest silently loads 20.9.0, so the version has to be checked.

  • Wheel boundary, real-xterm and stand-in files: 18/18. The real-xterm file on 20.9.0 still passes 5/5, which covers the guard branch.
  • Recorder, picker and wheel files together: 34/34.
  • Full renderer project: 2061/2062.
    • The one failure was AgentCodeCustomSkillsRow > refreshes its shared revision after a Conventions mutation (a findByRole on "New Skill…").
    • That file passes 9/9 in isolation on 20.14.5 (twice) and on 20.9.0, so it looks load-sensitive under the full local run rather than a happy-dom effect. CI is the gate.

The overlap with #1439 (node-pty) is in package.json/package-lock.json, in different hunks: git merge-tree merges it cleanly.

🤖 Generated with Claude Code

Juliusolsson05 and others added 3 commits September 27, 2026 08:15
…1365)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
happy-dom 20.10 added a global OffscreenCanvas. xterm's WidthCache prefers it
over <canvas>, so the real-xterm wheel test's 2D-context shim is bypassed and
term.open() throws 'value must not be falsy'. The shim fix follows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eel test (#1365)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Juliusolsson05

Copy link
Copy Markdown
Owner Author

Review disposition (round 1)

Two independent reviewers (Codex a and b), reports in temp/review-1446/. Both verdicts: MERGE-READY.

  • a: root cause confirmed from the published tarballs. 20.10.0 assigns window.OffscreenCanvas, and its getContext returns null without a canvas adapter. The xterm WidthCache and CharSizeService paths match the PR. The mutations killed the test: dropping preventDefault failed 2/5, and capture-phase interception failed 5/5. The fail-first commit 53f8b039 fails 5/5 at open().
    • Nuance, no change: 20.9.0 already had an internal OffscreenCanvas class but no global. The PR only claims the global and lib/canvas are new.
  • b: full renderer project 2062/2062 on a version-proved 20.14.5. A per-area review of 20.9 → 20.14.5 lib/ found no accidental passes: dispatch, focus/blur, pointer, mouse and wheel are unchanged. Computed-style internals changed, and the tested values still pass. The stale-label cause of chore(deps): Bump the minor-and-patch group across 1 directory with 21 updates #1322's recorder and picker failures is confirmed. The lockfile is minimal, and npm ci --dry-run --offline passes.
    • Non-blocking: the local Custom Skills failure was not reproduced (5+5 isolated runs, plus a full run). It is not tied to happy-dom. If it recurs in CI it gets its own issue; no change here.

No code changes from review. CI is green at 12e8f5fe.

@Juliusolsson05 Juliusolsson05 added type:chore Maintenance, deps, tests, docs class:C9-tests Test hygiene sev:P3 Minor labels Sep 27, 2026
…block (#1446 review c)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Juliusolsson05

Copy link
Copy Markdown
Owner Author

Review disposition: reviewer c (Pi), comment accuracy and shim hygiene

Verdict: MERGE-READY. Every behavioral claim in the WHY block was checked against the installed xterm sourcemap and happy-dom 20.14.5, and the shim restore and isolation are leak-free.

  • Fixed in 033a7d81 (comment only): shim 3's claim that a browser computes .xterm-screen padding "from xterm.css" was false; xterm.css has no such rule. It now says the browser uses the CSS initial value. The tangled "not observed on its own" sentence now records reviewer c's observation: padding alone gives the same ESC[<64;NaN;NaNM.
  • No change: "three shims" is still accurate. The dropped getContext options argument has no caller that passes one.

@Juliusolsson05
Juliusolsson05 merged commit f7e66c0 into main Sep 27, 2026
2 checks passed
@Juliusolsson05
Juliusolsson05 deleted the chore/happy-dom-20-14 branch September 27, 2026 19:07
Juliusolsson05 added a commit that referenced this pull request Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

class:C9-tests Test hygiene sev:P3 Minor type:chore Maintenance, deps, tests, docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(deps): happy-dom 20.9 → 20.14 breaks DOM-event renderer tests

1 participant