blob: de50cd6b6582a124235066ea2acb61e8f70cb839 [file] [log] [blame]
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="editor-test.js"></script>
<script>
function codeSnippet() {
return document.getElementById("codeSnippet").textContent;
}
function test()
{
var textEditor = InspectorTest.createTestEditor();
textEditor.setMimeType("text/javascript");
textEditor.setReadOnly(false);
textEditor.element.focus();
InspectorTest.evaluateInPage("codeSnippet();", onCodeSnippet);
var codeSnippetText;
function onCodeSnippet(result)
{
codeSnippetText = result.value;
InspectorTest.runTestSuite(testSuite);
}
function dumpAndNext(next)
{
function innerDumpAndNext()
{
InspectorTest.dumpTextWithSelection(textEditor, true);
next();
}
return innerDumpAndNext;
}
var testSuite = [
function testSimpleCollapsedBlockExpanding(next)
{
textEditor.setText(codeSnippetText);
InspectorTest.setLineSelections(textEditor, [
{line: 0, column: 1}
]);
InspectorTest.fakeKeyEvent(textEditor, "enter", [], dumpAndNext(next));
},
function testMulticursorCollapsedBlockExpanding(next)
{
textEditor.setText(codeSnippetText);
InspectorTest.setLineSelections(textEditor, [
{line: 0, column: 1},
{line: 0, column: 4},
{line: 1, column: 3}
]);
InspectorTest.fakeKeyEvent(textEditor, "enter", [], dumpAndNext(next));
},
function testMulticursorCollapsedBlockNotExpanding(next)
{
textEditor.setText(codeSnippetText);
InspectorTest.setLineSelections(textEditor, [
{line: 0, column: 1},
{line: 1, column: 2}
]);
InspectorTest.fakeKeyEvent(textEditor, "enter", [], dumpAndNext(next));
},
function testSingleCursorClosingBracketIndent(next)
{
textEditor.setText(codeSnippetText);
InspectorTest.setLineSelections(textEditor, [
{line: 3, column: 0}
]);
InspectorTest.fakeKeyEvent(textEditor, "}", [], dumpAndNext(next));
},
function testMulticursorClosingBracketIndent(next)
{
textEditor.setText(codeSnippetText);
InspectorTest.setLineSelections(textEditor, [
{line: 3, column: 5},
{line: 5, column: 9}
]);
InspectorTest.fakeKeyEvent(textEditor, "}", [], dumpAndNext(next));
},
function testMulticursorClosingBracketIndentNotExecuted(next)
{
textEditor.setText(codeSnippetText);
InspectorTest.setLineSelections(textEditor, [
{line: 3, column: 5},
{line: 4, column: 5}
]);
InspectorTest.fakeKeyEvent(textEditor, "}", [], dumpAndNext(next));
}
];
}
</script>
</head>
<body onload="runTest();">
<p>
This test verifies applied indentation whenever you hit enter in "{|}" or type in "}" while inside opened block.
</p>
<pre id="codeSnippet">
{} {}
{}
{
{
</pre>
</body>
</html>