blob: bb61ccb0a2f29e667ba4de0bc0b29a7c86ab0fa6 [file] [log] [blame]
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="editor-test.js"></script>
<script>
function test()
{
function foo()
{
return 42;
}
var textEditor = InspectorTest.createTestEditor();
textEditor.overrideViewportForTest(0, undefined, 3);
textEditor.mimeType = "text/javascript";
textEditor.setReadOnly(false);
textEditor.element.focus();
textEditor.setText(foo.toString());
InspectorTest.addResult(textEditor.text());
function dumpTextEditorWithSelection()
{
InspectorTest.addResult(InspectorTest.textWithSelection(textEditor.text(), textEditor.selection()));
}
function homeButton(shift)
{
var key = WebInspector.isMac() ? "leftArrow" : "home";
var modifiers = WebInspector.isMac() ? ["metaKey"] : [];
if (shift)
modifiers.push("shiftKey");
eventSender.keyDown(key, modifiers);
}
InspectorTest.runTestSuite([
function testFirstNonBlankCharacter(next)
{
var selection = WebInspector.TextRange.createFromLocation(2, 8);
textEditor.setSelection(selection);
dumpTextEditorWithSelection();
homeButton(false);
dumpTextEditorWithSelection();
next();
},
function testFirstNonBlankCharacterFromWhitespace(next)
{
var selection = WebInspector.TextRange.createFromLocation(2, 2);
textEditor.setSelection(selection);
dumpTextEditorWithSelection();
homeButton(false);
dumpTextEditorWithSelection();
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();
},
function testHomeButtonDoesNotChangeCursor(next)
{
var selection = WebInspector.TextRange.createFromLocation(0, 2);
textEditor.setSelection(selection);
dumpTextEditorWithSelection();
homeButton(false);
dumpTextEditorWithSelection();
homeButton(false);
dumpTextEditorWithSelection();
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();
},
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();
}
]);
}
</script>
</head>
<body onload="runTest();">
<p>
This test verifies that home button triggers selection between first symbol of the line
and first non-blank symbol of the line.
</p>
</body>
</html>