Index: third_party/WebKit/LayoutTests/inspector/editor/editor-test.js |
diff --git a/third_party/WebKit/LayoutTests/inspector/editor/editor-test.js b/third_party/WebKit/LayoutTests/inspector/editor/editor-test.js |
index a7ac98b09e04a58f25908c600c50b020935670db..2dd7c7821a51560c82c51f5971947adbdfe8ac49 100644 |
--- a/third_party/WebKit/LayoutTests/inspector/editor/editor-test.js |
+++ b/third_party/WebKit/LayoutTests/inspector/editor/editor-test.js |
@@ -60,29 +60,31 @@ InspectorTest.setLineSelections = function(editor, selections) |
InspectorTest.typeIn = function(editor, typeText, callback) |
{ |
callback = callback || new Function(); |
+ var charIndex = 0; |
var noop = new Function(); |
- for(var charIndex = 0; charIndex < typeText.length; ++charIndex) { |
- // As soon as the last key event was processed, the whole text was processed. |
- var iterationCallback = charIndex + 1 === typeText.length ? callback : noop; |
- switch (typeText[charIndex]) { |
+ for (var charIndex = 0; charIndex < typeText.length; charIndex++) { |
+ var character = typeText[charIndex]; |
lushnikov
2016/07/21 16:54:25
how's this code different from the old one? I don'
einbinder
2016/07/21 20:35:50
Oh, I guess it turned out the same
|
+ var command; |
+ switch (character) { |
case "\n": |
- InspectorTest.fakeKeyEvent(editor, "Enter", null, iterationCallback); |
+ command = "Enter"; |
break; |
case "L": |
- InspectorTest.fakeKeyEvent(editor, "ArrowLeft", null, iterationCallback); |
+ command = "ArrowLeft"; |
break; |
case "R": |
- InspectorTest.fakeKeyEvent(editor, "ArrowRight", null, iterationCallback); |
+ command = "ArrowRight"; |
break; |
case "U": |
- InspectorTest.fakeKeyEvent(editor, "ArrowUp", null, iterationCallback); |
+ command = "ArrowUp"; |
break; |
case "D": |
- InspectorTest.fakeKeyEvent(editor, "ArrowDown", null, iterationCallback); |
+ command = "ArrowDown"; |
break; |
default: |
- InspectorTest.fakeKeyEvent(editor, typeText[charIndex], null, iterationCallback); |
+ command = character; |
} |
+ InspectorTest.fakeKeyEvent(editor, command, null, charIndex + 1 === typeText.length ? callback : noop); |
} |
} |
@@ -95,7 +97,7 @@ var eventCodes = { |
ArrowDown: 40 |
}; |
-function createCodeMirrorFakeEvent(eventType, code, charCode, modifiers) |
+function createCodeMirrorFakeEvent(editor, eventType, code, charCode, modifiers) |
{ |
function eventPreventDefault() |
{ |
@@ -108,6 +110,7 @@ function createCodeMirrorFakeEvent(eventType, code, charCode, modifiers) |
charCode: charCode, |
preventDefault: eventPreventDefault, |
stopPropagation: function(){}, |
+ target: editor._codeMirror.display.input.textarea |
}; |
if (modifiers) { |
for (var i = 0; i < modifiers.length; ++i) |
@@ -118,7 +121,7 @@ function createCodeMirrorFakeEvent(eventType, code, charCode, modifiers) |
function fakeCodeMirrorKeyEvent(editor, eventType, code, charCode, modifiers) |
{ |
- var event = createCodeMirrorFakeEvent(eventType, code, charCode, modifiers); |
+ var event = createCodeMirrorFakeEvent(editor, eventType, code, charCode, modifiers); |
switch(eventType) { |
case "keydown": |
editor._codeMirror.triggerOnKeyDown(event); |
@@ -138,7 +141,7 @@ function fakeCodeMirrorKeyEvent(editor, eventType, code, charCode, modifiers) |
function fakeCodeMirrorInputEvent(editor, character) |
{ |
if (typeof character === "string") |
- editor._codeMirror.display.input.value += character; |
+ editor._codeMirror.display.input.textarea.value += character; |
} |
InspectorTest.fakeKeyEvent = function(editor, originalCode, modifiers, callback) |