Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/inspector-protocol/input/dispatchKeyEvent-focus.js |
| diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/input/dispatchKeyEvent-focus.js b/third_party/WebKit/LayoutTests/inspector-protocol/input/dispatchKeyEvent-focus.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..49419693a727dcda56a245842ebeb18d562db2eb |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/inspector-protocol/input/dispatchKeyEvent-focus.js |
| @@ -0,0 +1,66 @@ |
| +(async function(testRunner) { |
| + let {page, session, dp} = await testRunner.startHTML(` |
| + <div id='inputs'> |
| + <input onfocus='log("focus foo")' onblur='log("blur foo")' id='foo' autofocus> |
| + <input onfocus='log("focus bar")' onblur='log("blur bar")' id='bar'> |
| + <input onfocus='log("focus baz")' onblur='log("blur baz")' id='baz'> |
| + </div> |
| + `, ``); |
| + |
| + function type(text) { |
| + for (var i = 0; i < text.length; ++i) { |
| + var dec = text.charCodeAt(i); |
| + var hex = 'U+00' + Number(dec).toString(16); |
| + dp.Input.dispatchKeyEvent({ |
| + 'type': 'rawKeyDown', |
| + 'windowsVirtualKeyCode': dec, |
| + 'key': text[i] |
| + }); |
| + dp.Input.dispatchKeyEvent({ |
| + 'type': 'char', |
| + 'text': text[i], |
| + 'key': text[i], |
| + 'unmodifiedText': text[i] |
| + }); |
| + dp.Input.dispatchKeyEvent({ |
| + 'type': 'keyUp', |
| + 'windowsVirtualKeyCode': dec, |
| + 'key': text[i] |
| + }); |
| + } |
| + } |
| + |
| + function typeTab() { |
| + dp.Input.dispatchKeyEvent({ |
| + 'type': 'rawKeyDown', |
| + 'windowsVirtualKeyCode': 9, |
| + 'key': 'Tab', |
| + }); |
| + dp.Input.dispatchKeyEvent({ |
| + 'type': 'keyUp', |
| + 'windowsVirtualKeyCode': 9, |
| + 'key': 'Tab', |
| + }); |
| + } |
| + |
| + await session.evaluate(` |
| + window.logs = []; |
| + function log(text) { |
| + logs.push(text); |
| + } |
| + window.internals.setFocused(false); |
|
allada
2017/06/26 22:02:53
It looks like the old test was bluring then runnin
dgozman
2017/06/26 23:22:07
Done.
|
| + `); |
| + type('foo'); |
|
allada
2017/06/26 22:02:53
At this point the field should be blured and we ar
dgozman
2017/06/26 23:22:07
As I understand it, autofocus affects what is focu
|
| + typeTab(); |
| + type('bar'); |
| + typeTab(); |
| + testRunner.log(await session.evaluate(` |
| + log('================'); |
| + log('value of foo:' + document.getElementById('foo').value); |
| + log('value of bar:' + document.getElementById('bar').value); |
| + log('value of baz:' + document.getElementById('baz').value); |
| + window.internals.setFocused(true); |
| + logs.join('\\n') |
| + `)); |
| + testRunner.completeTest(); |
| +}) |