Open Bug 1587744 Opened 5 years ago Updated 2 years ago

dispatchKeyEvent `text` parameter should cause Input event to be synthesized

Categories

(Remote Protocol :: CDP, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: impossibus, Unassigned)

References

(Blocks 1 open bug)

Details

In order to support the text parameter, we need to synthesize an Input event independently of KeyboardEvents. In other words, the value text is what should show up in an input field, regardless of what value is provided by KeyboardEvent.key.

In puppeteer running with Chrome:

await page.keyboard.down("KeyA", {"text": "L"});
await page.keyboard.up("KeyA");

The corresponds to CDP commands: (note that "text" is L)

{"method":"Input.dispatchKeyEvent","params":{"type":"keyDown","modifiers":0,"windowsVirtualKeyCode":65,"code":"KeyA","key":"a","text":"L","unmodifiedText":"L","autoRepeat":false,"location":0,"isKeypad":false}}
{"method":"Input.dispatchKeyEvent","params":{"type":"keyUp","modifiers":0,"key":"a","windowsVirtualKeyCode":65,"code":"KeyA","location":0}} 

keyboard events: note that the keyboard event has 'a', but the input event has 'L' and 'L' is displayed in the input element.

[ { code: 'KeyA',
    key: 'a',
    which: 65,
    location: 0,
    ctrl: false,
    meta: false,
    shift: false,
    repeat: false,
    type: 'keydown' },
  { code: 'KeyA',
    key: 'a',
    which: 76,
    location: 0,
    ctrl: false,
    meta: false,
    shift: false,
    repeat: false,
    type: 'keypress' },
  { data: 'L', inputType: 'insertText', isComposing: false },
  { code: 'KeyA',
    key: 'a',
    which: 65,
    location: 0,
    ctrl: false,
    meta: false,
    shift: false,
    repeat: false,
    type: 'keyup' } ]

As far as I can tell, there's no way to synthesize a trusted Input event via EventUtils or TextInputProcessor such that it represents different text data than the corresponding KeyboardEvents.

Whiteboard: [puppeteer-alp
Whiteboard: [puppeteer-alp → [puppeteer-alpha]

This isn't used in the gutenberg test suite and is a relatively esoteric use-case so I don't think it needs to be in alpha.

Whiteboard: [puppeteer-alpha]
Priority: -- → P3
Component: CDP: Input → CDP
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.