| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="highlighter-test.js"></script> |
| <script> |
| |
| function test() |
| { |
| var src = "/**\n"; |
| for (var i = 1; i < 9; ++i) { |
| src += " * line #" + i + "\n"; |
| } |
| src += " * var a = new A(); //*/\n"; |
| src += "some text\n"; |
| |
| var textModel = new WebInspector.TextEditorModel(); |
| textModel.setText(src); |
| |
| var highlighter = new WebInspector.TextEditorHighlighter(textModel, function() {}); |
| highlighter.mimeType = "text/javascript"; |
| highlighter.highlightChunkLimit = Number.MAX_VALUE; // Synchronous. |
| |
| function dumpTextModel(msg) { |
| InspectorTest.addResult("\n" + msg); |
| InspectorTest.dumpTextModel(textModel); |
| } |
| |
| highlighter.highlight(5); |
| dumpTextModel("After highlighting 5 lines"); |
| |
| highlighter.highlight(textModel.linesCount); |
| dumpTextModel("After highlighting all lines"); |
| |
| var range = new WebInspector.TextRange(3, 0, 6, 0); |
| var newRange = textModel.editRange(range, src); |
| dumpTextModel("After changing text model, but before updating highlights"); |
| |
| highlighter.updateHighlight(newRange.startLine, newRange.endLine + 1); |
| dumpTextModel("After updating highlights"); |
| |
| highlighter.highlight(textModel.linesCount, true); |
| dumpTextModel("After highlighting up to the end"); |
| |
| var range = new WebInspector.TextRange(0, 0, 0, textModel.lineLength(0)); |
| var newRange = textModel.editRange(range, "foo /* comment */"); |
| highlighter.updateHighlight(0, 5); |
| dumpTextModel("After changing the first line, and updating the highlights for the first 5 lines"); |
| |
| var range = new WebInspector.TextRange(0, textModel.lineLength(0), 0, textModel.lineLength(0)); |
| var newRange = textModel.editRange(range, " /*"); |
| highlighter.updateHighlight(0, 2); |
| dumpTextModel("Again change the first line, but update only first 2 lines (invalidate update for the lines below)"); |
| |
| InspectorTest.completeTest(); |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="runTest()"> |
| <p> |
| This test checks highlighter correctness. |
| </p> |
| |
| </body> |
| </html> |