3 <script src=
"../sources/debugger/resources/edit-me.js"></script>
4 <script src=
"../editor/editor-test.js"></script>
5 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
6 <script src=
"../../http/tests/inspector/debugger-test.js"></script>
8 function codeSnippet() {
9 return document
.getElementById("codeSnippet").textContent
;
14 InspectorTest
.showScriptSource("edit-me.js", onSourceFrame
);
17 function onSourceFrame(sourceFrame
)
19 textEditor
= sourceFrame
.textEditor
;
20 textEditor
.element
.focus();
21 InspectorTest
.runTestSuite(testSuite
);
25 // This test has to be the first. It validates that autocompletion controller
26 // will initialize as a key will be pressed.
27 function testCompletionsShowUpOnKeyPress(next
)
29 textEditor
.setText("name1 name2 name3 name4\nna");
30 textEditor
.setSelection(WebInspector
.TextRange
.createFromLocation(1, 2));
31 InspectorTest
.addSniffer(WebInspector
.TextEditorAutocompleteController
.prototype, "_onSuggestionsShownForTest", onAutocompletionSuggestBox
);
32 InspectorTest
.typeIn(textEditor
, "m");
33 function onAutocompletionSuggestBox()
35 document
.activeElement
.dispatchEvent(InspectorTest
.createKeyEvent("Enter"));
40 function testSetInitialText(next
)
42 textEditor
.setText("one two three3_\nfour five\na_b\nsix\n123foo\n132\nseven");
46 function testAlphaNumericWords(next
)
48 textEditor
.setText("2 2foo foo2 2foo4 foo3bar");
52 function testSetText(next
)
54 textEditor
.setText("dog cat 'mouse';dog bird");
58 function testSimpleEdit(next
)
60 textEditor
.setSelection(WebInspector
.TextRange
.createFromLocation(0, 3));
61 InspectorTest
.typeIn(textEditor
, "\b", dumpDictionary
.bind(null, next
));
64 function testDeleteOneDogAndOneCat(next
)
66 textEditor
.setSelection(WebInspector
.TextRange
.createFromLocation(0, 6));
67 InspectorTest
.typeIn(textEditor
, "\b\b\b\b\b\b", dumpDictionary
.bind(null, next
));
71 function dumpDictionary(next
) {
72 var wordsInDictionary
= textEditor
._autocompleteController
._delegate
._dictionary
.wordsWithPrefix("");
73 InspectorTest
.addResult("========= Text in editor =========");
74 InspectorTest
.dumpTextWithSelection(textEditor
);
75 InspectorTest
.addResult("======= Words in dictionary =======");
76 InspectorTest
.addResult("[" + wordsInDictionary
.sort().join(", ") + "]");
77 InspectorTest
.addResult("=============");
85 <body onload=
"runTest();">
87 This test checks how text editor updates autocompletion dictionary in a response