| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="editor-test.js"></script> |
| <script> |
| function test() |
| { |
| function findElement(collection, elem) { |
| // length |
| for(var i = 0; i < collection.length; ++i) |
| if (collection[i] === elem) |
| return i; |
| return null; |
| } |
| |
| var steps = [step3, step2, step1]; // reversed order |
| function selectionChangeListener() |
| { |
| if (steps.length) |
| steps.pop().call(); |
| } |
| |
| var textEditorDelegate = new WebInspector.TextEditorDelegate(); |
| textEditorDelegate.selectionChanged = selectionChangeListener; |
| |
| var textEditor = InspectorTest.createTestEditor(undefined, undefined, textEditorDelegate); |
| textEditor.setReadOnly(false); |
| textEditor.setText(findElement.toString()); |
| textEditor.element.focus(); |
| |
| InspectorTest.addResult("=========== TextEditor text =========="); |
| InspectorTest.addResult(textEditor.text()); |
| |
| InspectorTest.addResult("=========== Before selecting element ==========="); |
| InspectorTest.dumpEditorHTML(textEditor, true); |
| |
| var range = new WebInspector.TextRange(0, 21, 0, 31); |
| textEditor.setSelection(range); |
| |
| function step1() |
| { |
| InspectorTest.addResult("=========== After selecting '" + textEditor._textModel.copyRange(range) + "' ==========="); |
| InspectorTest.dumpEditorHTML(textEditor, true); |
| range = new WebInspector.TextRange(0, 33, 0, 37); |
| textEditor.setSelection(range); |
| } |
| |
| function step2() |
| { |
| InspectorTest.addResult("=========== After selecting '" + textEditor._textModel.copyRange(range) + "' ==========="); |
| InspectorTest.dumpEditorHTML(textEditor, true); |
| range = new WebInspector.TextRange(1, 11, 1, 17); |
| textEditor.setSelection(range); |
| } |
| |
| function step3() |
| { |
| InspectorTest.addResult("=========== After selecting '" + textEditor._textModel.copyRange(range) + "' ==========="); |
| InspectorTest.dumpEditorHTML(textEditor, true); |
| InspectorTest.completeTest(); |
| } |
| |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="runTest();"> |
| <p> |
| This test checks text editor token highlight functionality. |
| </p> |
| </body> |
| </html> |