Skip to content

fix(input): checkpoint native keyboard callbacks - #3007

Open
ldm0 wants to merge 1 commit into
mainfrom
fix/keyboard-event-microtasks-3003
Open

ldm0 wants to merge 1 commit into
mainfrom
fix/keyboard-event-microtasks-3003

Conversation

@ldm0

@ldm0 ldm0 commented Nov 15, 2026

Copy link
Copy Markdown
Member

Native keyboard delivery delayed all listener microtasks until the end of the input command. A combined keyDown therefore dispatched keypress and inserted text before a keydown listener's Promise reaction could run.

Temporarily select V8's Scoped microtask policy for native keyboard delivery, using the existing Web IDL callback nesting scopes to checkpoint after each outermost listener. Keep combined keyDown dispatch synchronous; nested dispatchEvent() calls remain inside their invoking JavaScript stack. Restore the owner's previous policy when input delivery ends.

Regression tests cover combined keyDown and rawKeyDown/char, ordering between multiple listeners and before default actions, focus changes and cancellation from microtasks, and synchronous synthetic dispatch. A V8 utility test verifies callback checkpoints and policy restoration.

Playwright 1.65.0, raw CDP, and synthetic-event probes match Chrome for Testing 145.0.7632.6. The original implementation fails the native event-order comparisons.

Validation from the repository root:

  • cargo fmt --all
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run --no-fail-fast — 23,490 passed, 20 skipped.

Closes #3003.

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.

Key events dispatched in one task, microtasks run late

1 participant