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 91d725f8edd7338da54e3bacc04358373a2ec35b..2d868878ddcf01d4072fc640859ddb5a94ff4f61 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/Tests.js |
+++ b/third_party/WebKit/Source/devtools/front_end/Tests.js |
@@ -662,6 +662,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. |
+ ConsoleModel.consoleModel.addEventListener(ConsoleModel.ConsoleModel.Events.MessageAdded, onConsoleMessage, this); |
+ |
+ var messages = ConsoleModel.consoleModel.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'}); |