InspectorTest.addResult(textEditor.text());
- function dumpTextEditorWithSelection()
- {
- InspectorTest.addResult(InspectorTest.textWithSelection(textEditor.text(), textEditor.selection()));
- }
-
- function homeButton(shift)
+ function homeButton(shift, callback)
{
var key = WebInspector.isMac() ? "leftArrow" : "home";
var modifiers = WebInspector.isMac() ? ["metaKey"] : [];
if (shift)
modifiers.push("shiftKey");
- eventSender.keyDown(key, modifiers);
+ InspectorTest.fakeKeyEvent(textEditor, key, modifiers, callback);
+ }
+
+ function hitHomeButton(shift, times, callback)
+ {
+ function hitButtonCallback()
+ {
+ --times;
+ InspectorTest.dumpTextWithSelection(textEditor);
+ if (times > 0) {
+ homeButton(shift, hitButtonCallback);
+ return;
+ }
+ callback();
+ }
+ homeButton(shift, hitButtonCallback);
}
InspectorTest.runTestSuite([
{
var selection = WebInspector.TextRange.createFromLocation(2, 8);
textEditor.setSelection(selection);
- dumpTextEditorWithSelection();
- homeButton(false);
- dumpTextEditorWithSelection();
- next();
+ InspectorTest.dumpTextWithSelection(textEditor);
+ hitHomeButton(false, 1, next);
},
function testFirstNonBlankCharacterFromWhitespace(next)
{
var selection = WebInspector.TextRange.createFromLocation(2, 2);
textEditor.setSelection(selection);
- dumpTextEditorWithSelection();
- homeButton(false);
- dumpTextEditorWithSelection();
- next();
+ InspectorTest.dumpTextWithSelection(textEditor);
+ hitHomeButton(false, 1, next);
},
function testHomeButtonToggling(next)
{
var selection = WebInspector.TextRange.createFromLocation(2, 2);
textEditor.setSelection(selection);
- dumpTextEditorWithSelection();
- homeButton(false);
- dumpTextEditorWithSelection();
- homeButton(false);
- dumpTextEditorWithSelection();
- homeButton(false);
- dumpTextEditorWithSelection();
- next();
+ InspectorTest.dumpTextWithSelection(textEditor);
+ hitHomeButton(false, 3, next);
},
function testHomeButtonDoesNotChangeCursor(next)
{
var selection = WebInspector.TextRange.createFromLocation(0, 2);
textEditor.setSelection(selection);
- dumpTextEditorWithSelection();
- homeButton(false);
- dumpTextEditorWithSelection();
- homeButton(false);
- dumpTextEditorWithSelection();
- next();
+ InspectorTest.dumpTextWithSelection(textEditor);
+ hitHomeButton(false, 2, next);
},
function testHomeButtonWithShift(next)
{
var selection = new WebInspector.TextRange(0, 0, 2, 8);
textEditor.setSelection(selection);
- dumpTextEditorWithSelection();
- homeButton(true);
- dumpTextEditorWithSelection();
- homeButton(true);
- dumpTextEditorWithSelection();
- homeButton(true);
- dumpTextEditorWithSelection();
- next();
+ InspectorTest.dumpTextWithSelection(textEditor);
+ hitHomeButton(true, 3, next);
},
function testHomeButtonWithShiftInversed(next)
{
var selection = new WebInspector.TextRange(3, 1, 2, 8);
textEditor.setSelection(selection);
- dumpTextEditorWithSelection();
- homeButton(true);
- dumpTextEditorWithSelection();
- homeButton(true);
- dumpTextEditorWithSelection();
- homeButton(true);
- dumpTextEditorWithSelection();
- next();
+ InspectorTest.dumpTextWithSelection(textEditor);
+ hitHomeButton(true, 3, next);
}
]);
}