3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"editor-test.js"></script>
6 function codeSnippet() {
7 return document
.getElementById("codeSnippet").textContent
;
12 var textEditor
= InspectorTest
.createTestEditor();
13 textEditor
.setMimeType("text/javascript");
14 textEditor
.setReadOnly(false);
15 textEditor
.element
.focus();
16 InspectorTest
.evaluateInPage("codeSnippet();", onCodeSnippet
);
19 function onCodeSnippet(result
)
21 codeSnippetText
= result
.value
;
22 InspectorTest
.runTestSuite(testSuite
);
25 function dumpAndNext(next
)
27 function innerDumpAndNext()
29 InspectorTest
.dumpTextWithSelection(textEditor
, true);
32 return innerDumpAndNext
;
36 function testSingleCursorFromOutsideOpenBracket(next
)
38 textEditor
.setText(codeSnippetText
);
39 InspectorTest
.setLineSelections(textEditor
, [
40 { line
: 0, column
: 16 }
42 InspectorTest
.fakeKeyEvent(textEditor
, "M", ["ctrlKey"], dumpAndNext(next
));
45 function testSingleCursorFromInsideOpenBracket(next
)
47 textEditor
.setText(codeSnippetText
);
48 InspectorTest
.setLineSelections(textEditor
, [
49 { line
: 0, column
: 17 }
51 InspectorTest
.fakeKeyEvent(textEditor
, "M", ["ctrlKey"], dumpAndNext(next
));
54 function testSingleCursorFromOutsideCloseBracket(next
)
56 textEditor
.setText(codeSnippetText
);
57 InspectorTest
.setLineSelections(textEditor
, [
58 { line
: 3, column
: 1 }
60 InspectorTest
.fakeKeyEvent(textEditor
, "M", ["ctrlKey"], dumpAndNext(next
));
63 function testSingleCursorFromInsideCloseBracket(next
)
65 textEditor
.setText(codeSnippetText
);
66 InspectorTest
.setLineSelections(textEditor
, [
67 { line
: 3, column
: 0 }
69 InspectorTest
.fakeKeyEvent(textEditor
, "M", ["ctrlKey"], dumpAndNext(next
));
72 function testMulticursor(next
)
74 textEditor
.setText(codeSnippetText
);
75 InspectorTest
.setLineSelections(textEditor
, [
76 { line
: 0, column
: 16 },
77 { line
: 0, column
: 21 },
78 { line
: 3, column
: 0 },
79 { line
: 2, column
: 10 }
81 InspectorTest
.fakeKeyEvent(textEditor
, "M", ["ctrlKey"], dumpAndNext(next
));
89 <body onload=
"runTest();">
91 This test verifies editor's
"Goto Matching Bracket" behavior, which is triggered via Ctrl-M shortcut.
94 <pre id=
"codeSnippet">
95 function MyClass(a, b)