Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / console / console-search-reveals-messages.html
blob7df93ec3a5ad5aaa3b47501a8332bad21577dc48
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 for (var i = 0; i < 200; ++i)
9 console.log("Message #" + i);
10 console.log("LAST MESSAGE");
11 runTest();
14 function test()
16 var consoleView = WebInspector.ConsolePanel._view();
17 var viewport = consoleView._viewport;
18 const maximumViewportMessagesCount = 150;
19 InspectorTest.runTestSuite([
20 function waitForMessages(next)
22 // NOTE: keep in sync with populateConsoleWithMessages above.
23 const expectedMessageCount = 201;
24 InspectorTest.waitForConsoleMessages(expectedMessageCount, next);
27 function verifyViewportIsTallEnough(next)
29 viewport.invalidate();
30 var viewportMessagesCount = viewport._lastVisibleIndex - viewport._firstVisibleIndex;
31 if (viewportMessagesCount > maximumViewportMessagesCount) {
32 InspectorTest.addResult(String.sprintf("Test cannot be run because viewport could fit %d messages which is more then maxiumum of %d.", viewportMessagesCount, maximumViewportMessagesCount));
33 InspectorTest.completeTest();
34 return;
36 next();
39 function scrollConsoleToTop(next)
41 viewport.forceScrollItemToBeFirst(0);
42 dumpTop();
43 next();
46 function testFindLastMessage(next)
48 InspectorTest.addSniffer(consoleView, "_searchFinishedForTests", callback);
49 consoleView._searchableView._searchInputElement.value = "LAST MESSAGE";
50 consoleView._searchableView.showSearchField();
52 function callback()
54 consoleView._searchableView.handleFindNextShortcut();
55 dumpBottom();
56 next();
59 ]);
61 function dumpTop()
63 viewport.refresh();
64 InspectorTest.addResult("first visible message index: " + viewport.firstVisibleIndex());
67 function dumpBottom()
69 viewport.refresh();
70 InspectorTest.addResult("last visible message index: " + viewport.lastVisibleIndex());
73 </script>
74 </head>
75 <body onload="populateConsoleWithMessages()">
76 <p>
77 Tests that console viewport reveals messages on searching.
78 </p>
79 </body>
80 </html>