Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / editor / text-editor-indent-autodetection.html
blob37b203ad354ee11362b752c1cc8782e18574e043
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(name) {
7 return document.getElementById(name).textContent;
10 function codeSnippetsNumber() {
11 return document.getElementsByClassName("test").length;
14 function test()
16 var textEditor = InspectorTest.createTestEditor();
17 textEditor.setMimeType("text/javascript");
18 textEditor.setReadOnly(false);
19 textEditor.element.focus();
20 WebInspector.settingForTest("textEditorAutoDetectIndent").set(true);
21 function genericTest(snippetName, next)
23 var command = "codeSnippet('" + snippetName + "');";
24 InspectorTest.evaluateInPage(command, step2);
25 function step2(result)
27 textEditor.setText(result.value);
28 var indent = textEditor.indent();
29 var description = indent === WebInspector.TextUtils.Indent.TabCharacter ? "Tab" : indent.length + " spaces";
30 InspectorTest.addResult("Autodetected indentation for " + snippetName + ": " +
31 description);
32 next();
36 function onTestNumberReceived(result)
38 var testSuite = [];
39 InspectorTest.addResult("Tests number: " + result.value);
40 for(var i = 1; i <= result.value; ++i)
41 testSuite.push(genericTest.bind(this, "test" + i));
43 InspectorTest.runTestSuite(testSuite);
46 InspectorTest.evaluateInPage("codeSnippetsNumber()", onTestNumberReceived);
49 </script>
50 </head>
52 <body onload="runTest();">
53 <p>
54 This test checks text editor indent autodetection functionality
55 </p>
56 <div>--------------TEST 1--------------</div>
57 <pre id="test1" class="test">function foo() {
58 return 42;
60 </pre>
61 <div>--------------TEST 2--------------</div>
62 <pre id="test2" class="test">console.log("Hello!");</pre>
63 <div>--------------TEST 3--------------</div>
64 <pre id="test3" class="test">/**
65 * This is a header comment that spans
66 * for a lot of lines
83 function foo() {
84 return 42;
86 </pre>
87 <div>--------------TEST 4--------------</div>
88 <pre id="test4" class="test">
89 function MyClass()
91 this._foo = "bar";
94 MyClass.prototype = {
95 method1: function()
97 var sum = 0;
98 for(var i = 0; i < 100; ++i) {
99 sum += i;
101 return sum;
104 method2: function()
106 while(true) {
107 break;
111 </pre>
112 <div>--------------TEST 5--------------</div>
113 <pre id="test5" class="test">
121 </pre>
122 <div>--------------TEST 6--------------</div>
123 <pre id="test6" class="test">
128 </pre>
129 <div>--------------TEST 7-------------- (empty content)</div>
130 <pre id="test7" class="test"></pre>
131 <div>--------------TEST 8--------------</div>
132 <pre id="test8" class="test">
133 function foo() {
134 var i = 0;
135 function bar() {
136 var a = [];
137 a.push(1);
138 a.push(12);
139 a.push(42);
140 a.push(44);
141 return a.join("!");
144 (function() {
145 var a = {
146 a: function() {
147 vbr b = [];
148 b.push(1);
149 b.push(12);
150 b.push(42);
151 b.push(44);
152 b.push(44 * 2);
153 return b.join("?");
156 })();
158 </pre>
159 </body>
160 </html>