| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="editor-test.js"></script> |
| <script> |
| function codeSnippet() { |
| return document.getElementById("codeSnippet").textContent; |
| } |
| |
| function test() |
| { |
| var textEditor = InspectorTest.createTestEditor(); |
| textEditor.overrideViewportForTest(0, undefined, 3); |
| textEditor.mimeType = "text/javascript"; |
| textEditor.setReadOnly(false); |
| textEditor.element.focus(); |
| |
| function step2(result) |
| { |
| var codeLines = result.value.split("\n"); |
| for(var i = 0; i < codeLines.length; ++i) |
| InspectorTest.insertTextLine(codeLines[i].trim()); |
| |
| setTimeout(step3); |
| } |
| |
| function step3() |
| { |
| InspectorTest.addResult("============ editor contents start ============"); |
| InspectorTest.addResult(textEditor.text().replace(/ /g, ".")); |
| InspectorTest.addResult("============ editor contents end ============"); |
| InspectorTest.completeTest(); |
| } |
| |
| InspectorTest.evaluateInPage("codeSnippet();", step2); |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="runTest();"> |
| <p> |
| This test checks text editor javascript formatting. |
| </p> |
| |
| <pre id="codeSnippet"> |
| /** |
| * Multi-line comment |
| * |
| */ |
| function foo(n) { |
| // one-line comment |
| function bar() { |
| return 42; |
| } |
| |
| var sum = 0; |
| for(var i = 0; i < n; ++i) { |
| for(var j = 0; j < n; ++j) { |
| sum += i + j; |
| } |
| } |
| |
| |
| if (sum > 1000) { |
| while (sum > 0) { |
| --sum; |
| } |
| } |
| }</pre> |
| |
| </body> |
| </html> |