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();
17 var completionDictionary = new WebInspector.SampleCompletionDictionary();
18 textEditor.setCompletionDictionary(completionDictionary);
20 InspectorTest.runTestSuite([
21 function testSetInitialText(next)
23 textEditor.setText("one two three3_\nfour five\na_b\nsix\n123foo\n132\nseven");
27 function testAlphaNumericWords(next)
29 textEditor.setText("2 2foo foo2 2foo4 foo3bar");
33 function testSetText(next)
35 textEditor.setText("dog cat 'mouse';dog bird");
39 function testSimpleEdit(next)
41 textEditor.setSelection(WebInspector.TextRange.createFromLocation(0, 3));
42 InspectorTest.typeIn(textEditor, "\b", dumpDictionary.bind(null, next));
45 function testDeleteOneDogAndOneCat(next)
47 textEditor.setSelection(WebInspector.TextRange.createFromLocation(0, 6));
48 InspectorTest.typeIn(textEditor, "\b\b\b\b\b\b", dumpDictionary.bind(null, next));
51 function testCSSMimeType(next)
53 textEditor.setText(".my-class { -webkit-border: 1px solid black; }");
54 textEditor.setMimeType("text/css");
59 function dumpDictionary(next) {
60 var wordsInDictionary = completionDictionary.wordsWithPrefix("");
61 InspectorTest.addResult("========= Text in editor =========");
62 InspectorTest.dumpTextWithSelection(textEditor);
63 InspectorTest.addResult("======= Words in dictionary =======");
64 InspectorTest.addResult("[" + wordsInDictionary.sort().join(", ") + "]");
65 InspectorTest.addResult("=============");
73 <body onload="runTest();">
75 This test checks how text editor updates autocompletion dictionary in a response