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..0ac50989ea81b1ace81f4166f21d10cf345e7b22 100644 |
--- a/third_party/WebKit/LayoutTests/inspector/editor/editor-test.js |
+++ b/third_party/WebKit/LayoutTests/inspector/editor/editor-test.js |
@@ -57,31 +57,46 @@ InspectorTest.setLineSelections = function(editor, selections) |
editor.setSelections(coords); |
} |
-InspectorTest.typeIn = function(editor, typeText, callback) |
+InspectorTest.typeIn = function(editor, typeText, finalCallback) |
{ |
- callback = callback || new Function(); |
+ finalCallback = finalCallback || 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]) { |
+ iterationCallback(); |
+ |
+ function iterationCallback() |
+ { |
+ var character = typeText[charIndex]; |
lushnikov
2016/07/20 01:40:13
typeText[charIndex++]
einbinder
2016/07/21 20:35:50
Done.
|
+ var command; |
+ var callback = noop; |
+ switch (character) { |
case "\n": |
- InspectorTest.fakeKeyEvent(editor, "Enter", null, iterationCallback); |
+ command = "Enter"; |
+ callback = iterationCallback; |
lushnikov
2016/07/20 01:40:13
should we do this?
einbinder
2016/07/21 20:35:50
nope
|
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; |
+ } |
+ charIndex++; |
+ if (typeText.length === charIndex) |
+ callback = finalCallback; |
+ else if (typeText[charIndex] === "\n") |
+ callback = iterationCallback; |
+ InspectorTest.fakeKeyEvent(editor, command, null, callback); |
+ if (callback === noop) { |
lushnikov
2016/07/20 01:40:13
nit: braces
einbinder
2016/07/21 20:35:50
Done.
|
+ iterationCallback(); |
} |
} |
} |
@@ -95,7 +110,7 @@ var eventCodes = { |
ArrowDown: 40 |
}; |
-function createCodeMirrorFakeEvent(eventType, code, charCode, modifiers) |
+function createCodeMirrorFakeEvent(editor, eventType, code, charCode, modifiers) |
{ |
function eventPreventDefault() |
{ |
@@ -108,6 +123,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 +134,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 +154,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) |