3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"editor-test.js"></script>
6 function codeSnippet(name
) {
7 return document
.getElementById(name
).textContent
;
10 function codeSnippetsNumber() {
11 return document
.getElementsByClassName("test").length
;
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
+ ": " +
36 function onTestNumberReceived(result
)
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
);
52 <body onload=
"runTest();">
54 This test checks text editor indent autodetection functionality
56 <div>--------------TEST
1--------------
</div>
57 <pre id=
"test1" class=
"test">function foo() {
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
87 <div>--------------TEST
4--------------
</div>
88 <pre id=
"test4" class=
"test">
98 for(var i =
0; i <
100; ++i) {
112 <div>--------------TEST
5--------------
</div>
113 <pre id=
"test5" class=
"test">
122 <div>--------------TEST
6--------------
</div>
123 <pre id=
"test6" class=
"test">
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">