Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / editor / text-editor-autocomplete.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="editor-test.js"></script>
5 <script>
6 function codeSnippet() {
7     return document.getElementById("codeSnippet").textContent;
8 }
9
10 function test()
11 {
12     var textEditor = InspectorTest.createTestEditor();
13     textEditor.setMimeType("text/javascript");
14     textEditor.setReadOnly(false);
15     textEditor.element.focus();
16
17     var completionDictionary = new WebInspector.SampleCompletionDictionary();
18     textEditor.setCompletionDictionary(completionDictionary);
19
20     InspectorTest.runTestSuite([
21         function testSetInitialText(next)
22         {
23             textEditor.setText("one two three3_\nfour five\na_b\nsix\n123foo\n132\nseven");
24             dumpDictionary(next);
25         },
26
27         function testAlphaNumericWords(next)
28         {
29             textEditor.setText("2 2foo foo2 2foo4 foo3bar");
30             dumpDictionary(next);
31         },
32
33         function testSetText(next)
34         {
35             textEditor.setText("dog cat 'mouse';dog bird");
36             dumpDictionary(next);
37         },
38
39         function testSimpleEdit(next)
40         {
41             textEditor.setSelection(WebInspector.TextRange.createFromLocation(0, 3));
42             InspectorTest.typeIn(textEditor, "\b", dumpDictionary.bind(null, next));
43         },
44
45         function testDeleteOneDogAndOneCat(next)
46         {
47             textEditor.setSelection(WebInspector.TextRange.createFromLocation(0, 6));
48             InspectorTest.typeIn(textEditor, "\b\b\b\b\b\b", dumpDictionary.bind(null, next));
49         },
50
51         function testCSSMimeType(next)
52         {
53             textEditor.setText(".my-class { -webkit-border: 1px solid black; }");
54             textEditor.setMimeType("text/css");
55             dumpDictionary(next);
56         },
57     ]);
58
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("=============");
66         next();
67     }
68 }
69
70 </script>
71 </head>
72
73 <body onload="runTest();">
74 <p>
75 This test checks how text editor updates autocompletion dictionary in a response
76 to user input.
77 </p>
78 </body>
79 </html>