blob: 0cafde4c9dad7117702b3ae9aea8438a2b7e1cdd [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 testSingleCursorFromOutsideOpenBracket(next)
{
textEditor.setText(codeSnippetText);
InspectorTest.setLineSelections(textEditor, [
{ line: 0, column: 16 }
]);
InspectorTest.fakeKeyEvent(textEditor, "M", ["ctrlKey"], dumpAndNext(next));
},
function testSingleCursorFromInsideOpenBracket(next)
{
textEditor.setText(codeSnippetText);
InspectorTest.setLineSelections(textEditor, [
{ line: 0, column: 17 }
]);
InspectorTest.fakeKeyEvent(textEditor, "M", ["ctrlKey"], dumpAndNext(next));
},
function testSingleCursorFromOutsideCloseBracket(next)
{
textEditor.setText(codeSnippetText);
InspectorTest.setLineSelections(textEditor, [
{ line: 3, column: 1 }
]);
InspectorTest.fakeKeyEvent(textEditor, "M", ["ctrlKey"], dumpAndNext(next));
},
function testSingleCursorFromInsideCloseBracket(next)
{
textEditor.setText(codeSnippetText);
InspectorTest.setLineSelections(textEditor, [
{ line: 3, column: 0 }
]);
InspectorTest.fakeKeyEvent(textEditor, "M", ["ctrlKey"], dumpAndNext(next));
},
function testMulticursor(next)
{
textEditor.setText(codeSnippetText);
InspectorTest.setLineSelections(textEditor, [
{ line: 0, column: 16 },
{ line: 0, column: 21 },
{ line: 3, column: 0 },
{ line: 2, column: 10 }
]);
InspectorTest.fakeKeyEvent(textEditor, "M", ["ctrlKey"], dumpAndNext(next));
},
];
}
</script>
</head>
<body onload="runTest();">
<p>
This test verifies editor's "Goto Matching Bracket" behavior, which is triggered via Ctrl-M shortcut.
</p>
<pre id="codeSnippet">
function MyClass(a, b)
{
console.log("Test");
}
</pre>
</body>
</html>