Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(879)

Side by Side Diff: LayoutTests/inspector/editor/highlighter-long-line.html

Issue 22638008: DevTools: Use CodeMirror modes instead of highlight tokenizers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address comments Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="highlighter-test.js"></script>
5 <script>
6
7 function test()
8 {
9 var textModel = new WebInspector.TextEditorModel();
10
11 var highlighter = new WebInspector.TextEditorHighlighter(textModel, function () {});
12 highlighter.mimeType = "text/javascript";
13 highlighter.highlightChunkLimit = Number.MAX_VALUE; // Synchronous.
14 highlighter.setHighlightLineLimit(Number.MAX_VALUE);
15
16 var src = "/* asdf */ ";
17 var comments = 1;
18 for (var i = 0; i < 10; ++i) {
19 src += src;
20 comments *= 2;
21 }
22 textModel.setText(src);
23
24 function checkHighlights()
25 {
26 var commentsFound = 0;
27 for (var lineNumber = 0; lineNumber < textModel.linesCount; ++lineNumber ) {
28 var highlight = textModel.getAttribute(lineNumber, "highlight");
29 for (var i = 0; i < highlight.ranges.length; ++i) {
30 var range = highlight.ranges[i];
31 if (range.token === "whitespace")
32 continue;
33 var rangeLength = range.endColumn - range.startColumn + 1;
34 if (rangeLength !== 10 || (range.startColumn % 11)) {
35 InspectorTest.addResult("ERROR: unexpected highlight result: i=" + range.startColumn + ", length=" + rangeLength);
36 break;
37 }
38 ++commentsFound;
39 }
40 }
41 if (comments !== commentsFound)
42 InspectorTest.addResult("ERROR: some of the comments were not highli ghted, found: " + commentsFound);
43 }
44
45 InspectorTest.addResult("Line length: " + src.length + ", number of comments : " + comments);
46
47 highlighter.highlight(textModel.linesCount);
48 checkHighlights();
49
50 // Insert a caret return in the middle of the long line.
51 var halfLength = Math.floor(src.length / 2);
52 var range = new WebInspector.TextRange(0, halfLength, 0, halfLength);
53 var newRange = textModel.editRange(range, "\n");
54 highlighter.updateHighlight(newRange.startLine, newRange.endLine + 1);
55 checkHighlights();
56
57 InspectorTest.addResult("All checks completed.");
58 InspectorTest.completeTest();
59 }
60
61 </script>
62 </head>
63
64 <body onload="runTest()">
65 <p>
66 This test checks highlighter on a long line.
67 </p>
68
69 </body>
70 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698