Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / console / console-search.html
blobdd4c3f76e9c1bc0f172640ace155f17b6ce1bbb0
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/console-test.js"></script>
5 <script>
6 function populateConsoleWithMessages()
8 console.log("FIRST MATCH, SECOND MATCH");
9 for (var i = 0; i < 200; ++i)
10 console.log("Message #" + i);
11 var a = {};
12 for (var i = 0; i < 200; ++i)
13 a["field_" + i] = "value #" + i;
14 console.dir(a);
15 console.log("LAST MATCH");
16 runTest();
18 //# sourceURL=console-search.html
19 </script>
21 <script>
22 function test()
24 function addResult(result)
26 viewport.refresh();
27 InspectorTest.addResult(result);
30 function setQuery(text, isRegex, caseSensitive, callback)
32 InspectorTest.addSniffer(consoleView, "_searchFinishedForTests", callback);
33 consoleView._searchableView._searchInputElement.value = text;
34 consoleView._searchableView._regexButton.setToggled(isRegex);
35 consoleView._searchableView._caseSensitiveButton.setToggled(caseSensitive);
36 consoleView._searchableView.showSearchField();
39 function matchesText()
41 return consoleView._searchableView.contentElement.querySelector(".search-results-matches").textContent;
44 function dumpMatches()
46 var matches = document.querySelectorAll("html /deep/ .highlighted-search-result");
47 addResult("number of visible matches: " + matches.length);
48 for (var i = 0; i < matches.length; ++i)
49 addResult(" match " + i + ": " + matches[i].className);
50 addResult("");
53 var consoleView = WebInspector.ConsolePanel._view();
54 var viewport = consoleView._viewport;
55 const maximumViewportMessagesCount = 150;
56 InspectorTest.runTestSuite([
57 function waitForMessages(next)
59 // NOTE: keep in sync with populateConsoleWithMessages above.
60 const expectedMessageCount = 203;
61 InspectorTest.waitForConsoleMessages(expectedMessageCount, next);
64 function assertViewportHeight(next)
66 viewport.invalidate();
67 var viewportMessagesCount = viewport._lastVisibleIndex - viewport._firstVisibleIndex;
68 if (viewportMessagesCount > maximumViewportMessagesCount) {
69 InspectorTest.addResult(String.sprintf(
70 "Test cannot be run because viewport can fit %d messages, while %d is the test's maximum.",
71 viewportMessagesCount, maximumViewportMessagesCount));
72 InspectorTest.completeTest();
73 return;
75 next();
78 function testSearchOutsideOfViewport(next)
80 setQuery("Message", false, false, function() {
81 InspectorTest.addResult("Search matches: '" + matchesText() + "'");
82 next();
83 });
86 function scrollConsoleToTop(next)
88 viewport.forceScrollItemToBeFirst(0);
89 addResult("first visible message index: " + viewport.firstVisibleIndex());
90 next();
93 function testCanJumpForward(next)
95 setQuery("MATCH", false, false, function() {
96 // Find first match.
97 consoleView._searchableView.handleFindNextShortcut();
98 addResult("first visible message index: " + viewport.firstVisibleIndex());
100 // Find second match.
101 consoleView._searchableView.handleFindNextShortcut();
102 addResult("first visible message index: " + viewport.firstVisibleIndex());
104 // Find last match.
105 consoleView._searchableView.handleFindNextShortcut();
106 addResult("last visible message index: " + viewport.lastVisibleIndex());
107 next();
111 function testCanJumpBackward(next)
113 setQuery("MATCH", false, false, function() {
114 // Start out at the first match.
115 consoleView._searchableView.handleFindNextShortcut();
117 // Find last match.
118 consoleView._searchableView.handleFindPreviousShortcut();
119 addResult("last visible message index: " + viewport.lastVisibleIndex());
121 // Find second match.
122 consoleView._searchableView.handleFindPreviousShortcut();
123 addResult("first visible message index: " + viewport.firstVisibleIndex());
125 // Find first match.
126 consoleView._searchableView.handleFindPreviousShortcut();
127 addResult("first visible message index: " + viewport.firstVisibleIndex());
128 next();
132 function scrollConsoleToTop(next)
134 viewport.forceScrollItemToBeFirst(0);
135 addResult("first visible message index: " + viewport.firstVisibleIndex());
136 next();
139 function testCanMarkCurrentMatch(next)
141 function addCurrentMarked()
143 var matches = document.querySelectorAll(".highlighted-search-result");
144 addResult("number of visible matches: " + matches.length);
145 for (var i = 0; i < matches.length; ++i)
146 addResult("match " + i + ": " + matches[i].className);
149 setQuery("MATCH", false, false, function() {
150 // Find first match.
151 consoleView._searchableView.handleFindNextShortcut();
152 addCurrentMarked();
154 // Find second match.
155 consoleView._searchableView.handleFindNextShortcut();
156 addCurrentMarked();
158 next();
162 function testCanJumpForwardBetweenTreeElementMatches(next)
164 function dumpElements(callback)
166 consoleView._searchableView.handleFindNextShortcut();
167 var currentResultElem = document.querySelector("html /deep/ .current-search-result");
168 addResult("matched tree element: " + currentResultElem.innerHTML);
169 callback();
172 function searchField1(callback)
174 // Find first match.
175 setQuery("field_1", false, false, dumpElements.bind(null, callback));
178 function searchField199(callback)
180 // Find last match.
181 setQuery("field_199", false, false, dumpElements.bind(null, callback));
184 InspectorTest.expandConsoleMessages(searchField1.bind(null, searchField199.bind(null, next)));
188 function testCaseInsensitiveRegex(next)
190 setQuery(". MATCH", true, false, function() {
191 consoleView._searchableView.handleFindNextShortcut();
192 dumpMatches();
193 next();
197 function testCaseSensitiveTextWithoutMatches(next)
199 setQuery("match", false, true, function() {
200 consoleView._searchableView.handleFindNextShortcut();
201 dumpMatches();
202 next();
206 function testCaseSensitiveTextWithMatches(next)
208 setQuery("MATCH", false, true, function() {
209 consoleView._searchableView.handleFindNextShortcut();
210 dumpMatches();
211 next();
215 function testCaseSensitiveRegexWithoutMatches(next)
217 setQuery(". match", true, true, function() {
218 consoleView._searchableView.handleFindNextShortcut();
219 dumpMatches();
220 next();
224 function testCaseSensitiveRegexWithMatches(next)
226 setQuery(". MATCH", true, true, function() {
227 consoleView._searchableView.handleFindNextShortcut();
228 dumpMatches();
229 next();
234 </script>
235 </head>
236 <body onload="populateConsoleWithMessages()">
238 Tests console search.
239 </p>
240 </body>
241 </html>