Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/Tests.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/Tests.js b/third_party/WebKit/Source/devtools/front_end/Tests.js |
| index 5a96d0e64bbe85d305b1d131ecc96f331013dc26..d90b840b1fa9c8f595e2c9518e5b4a693a78cdd2 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/Tests.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/Tests.js |
| @@ -665,6 +665,61 @@ |
| step1(); |
| }; |
| + TestSuite.prototype.testDispatchKeyEventShowsAutoFill = function() { |
| + var test = this; |
| + var receivedReady = false; |
| + |
| + function signalToShowAutofill() { |
| + SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
| + {type: 'rawKeyDown', key: 'Down', windowsVirtualKeyCode: 40, nativeVirtualKeyCode: 40}); |
| + SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
| + {type: 'keyUp', key: 'Down', windowsVirtualKeyCode: 40, nativeVirtualKeyCode: 40}); |
| + } |
| + |
| + function selectTopAutoFill() { |
| + SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
| + {type: 'rawKeyDown', key: 'Down', windowsVirtualKeyCode: 40, nativeVirtualKeyCode: 40}); |
| + SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
| + {type: 'keyUp', key: 'Down', windowsVirtualKeyCode: 40, nativeVirtualKeyCode: 40}); |
| + SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
| + {type: 'rawKeyDown', key: 'Enter', windowsVirtualKeyCode: 13, nativeVirtualKeyCode: 13}); |
| + SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
| + {type: 'keyUp', key: 'Enter', windowsVirtualKeyCode: 13, nativeVirtualKeyCode: 13}); |
| + |
| + test.evaluateInConsole_('document.getElementById("name").value', onResultOfInput); |
| + } |
| + |
| + function onResultOfInput(value) { |
| + // Console adds "" around the response. |
| + test.assertEquals('"Abbf"', value); |
| + test.releaseControl(); |
| + } |
| + |
| + function onConsoleMessage(event) { |
| + var message = event.data.messageText; |
| + if (message === 'ready' && !receivedReady) { |
| + receivedReady = true; |
| + signalToShowAutofill(); |
| + } |
| + // This log comes from the browser unittest code. |
| + if (message === 'didShowSuggestions') |
| + selectTopAutoFill(); |
| + } |
| + |
| + this.takeControl(); |
| + |
| + // It is possible for the ready console messagage to be already received but not handled |
| + // or received later. This ensures we can catch both cases. |
| + SDK.multitargetConsoleModel.addEventListener(SDK.ConsoleModel.Events.MessageAdded, onConsoleMessage, this); |
|
dgozman
2017/06/08 23:52:27
This is ConsoleModel.consoleModel now.
allada
2017/06/09 18:19:00
Done.
|
| + |
| + var messages = SDK.multitargetConsoleModel.messages(); |
| + if (messages.length) { |
| + var text = messages[0].messageText; |
| + this.assertEquals('ready', text); |
| + signalToShowAutofill(); |
| + } |
| + }; |
| + |
| TestSuite.prototype.testDispatchKeyEventDoesNotCrash = function() { |
| SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( |
| {type: 'rawKeyDown', windowsVirtualKeyCode: 0x23, key: 'End'}); |