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

Unified Diff: third_party/WebKit/LayoutTests/inspector/console/console-viewport-control.html

Issue 2688803002: DevTools: always do partial viewport update in console (Closed)
Patch Set: more focused cl without driveby Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/inspector/console/console-viewport-control.html
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-viewport-control.html b/third_party/WebKit/LayoutTests/inspector/console/console-viewport-control.html
new file mode 100644
index 0000000000000000000000000000000000000000..efea016bb8aec5991abd861fba921db76c51c8af
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector/console/console-viewport-control.html
@@ -0,0 +1,149 @@
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script src="../../http/tests/inspector/console-test.js"></script>
+<script>
+function addMessages(count)
+{
+ for (var i = 0; i < count; ++i)
+ console.log("Message #" + i);
+}
+
+function addRepeatingMessages(count)
+{
+ for (var i = 0; i < count; ++i)
+ console.log("Repeating message");
+}
+
+//# sourceURL=console-viewport-control.html
+</script>
+
+<script>
+
+function test()
+{
+ const viewportHeight = 200;
+ InspectorTest.fixConsoleViewportDimensions(600, viewportHeight);
+ var consoleView = Console.ConsoleView.instance();
+ var viewport = consoleView._viewport;
+ const smallCount = 3;
+ const rowHeight = viewportHeight / consoleView.minimumRowHeight();
+ const maxVisibleCount = Math.ceil(rowHeight);
+ const maxActiveCount = Math.ceil(rowHeight * 2);
+ var wasShown = [];
+ var willHide = [];
+
+ InspectorTest.addResult("Max visible messages count: " + maxVisibleCount + ", active count: " + maxActiveCount);
+
+ function onMessageShown() {
+ wasShown.push(this);
+ }
+
+ function onMessageHidden() {
+ willHide.push(this);
+ }
+
+ function logAndResetCounts(next) {
+ InspectorTest.addResult("Messages shown: " + wasShown.length + ", hidden: " + willHide.length);
+ resetShowHideCounts();
+ next();
+ }
+
+ function resetShowHideCounts() {
+ wasShown = [];
+ willHide = [];
+ }
+
+ function logMessages(count, repeating, callback)
+ {
+ var awaitingMessagesCount = count;
+ function messageAdded()
+ {
+ if (!--awaitingMessagesCount) {
+ viewport.invalidate();
+ callback();
+ } else {
+ InspectorTest.addConsoleSniffer(messageAdded, false);
+ }
+ }
+ InspectorTest.addConsoleSniffer(messageAdded, false);
+ if (!repeating)
+ InspectorTest.evaluateInPage(String.sprintf("addMessages(%d)", count));
+ else
+ InspectorTest.evaluateInPage(String.sprintf("addRepeatingMessages(%d)", count));
+ }
+
+ function printStuckToBottom() {
+ InspectorTest.addResult("Is at bottom: " + viewport.element.isScrolledToBottom() + ", should stick: " + viewport.stickToBottom());
+ }
+
+ function clearConsoleAndReset() {
+ Console.ConsoleView.clearConsole();
+ resetShowHideCounts();
+ }
+
+ InspectorTest.addSniffer(Console.ConsoleViewMessage.prototype, "wasShown", onMessageShown, true);
+ InspectorTest.addSniffer(Console.ConsoleViewMessage.prototype, "willHide", onMessageHidden, true);
+
+ InspectorTest.runTestSuite([
+ function addSmallCount(next) {
+ clearConsoleAndReset();
+ logMessages(smallCount, false, () => logAndResetCounts(next));
+ },
+
+ function addMaxVisibleCount(next) {
+ clearConsoleAndReset();
+ logMessages(maxVisibleCount, false, () => logAndResetCounts(next));
+ },
+
+ function addMaxActiveCount(next) {
+ clearConsoleAndReset();
+ logMessages(maxActiveCount, false, () => logAndResetCounts(next));
+ printStuckToBottom();
+ },
+
+ function addMoreThanMaxActiveCount(next) {
+ clearConsoleAndReset();
+ logMessages(maxActiveCount, false, step2);
+ function step2() {
+ logMessages(smallCount, false, () => logAndResetCounts(next));
+ printStuckToBottom();
+ }
+ },
+
+ function scrollUpWithinActiveWindow(next) {
+ clearConsoleAndReset();
+ logMessages(maxActiveCount, false, step2);
+ printStuckToBottom();
+ function step2() {
+ resetShowHideCounts();
+ viewport.forceScrollItemToBeFirst(0);
+ logAndResetCounts(next);
+ }
+ },
+
+ function scrollUpToPositionOutsideOfActiveWindow(next) {
+ clearConsoleAndReset();
+ logMessages(maxActiveCount + smallCount, false, step2);
+ printStuckToBottom();
+ function step2() {
+ resetShowHideCounts();
+ viewport.forceScrollItemToBeFirst(0);
+ logAndResetCounts(next);
+ }
+ },
+
+ function logRepeatingMessages(next) {
+ clearConsoleAndReset();
+ logMessages(maxVisibleCount, true, () => logAndResetCounts(next));
+ }
+ ]);
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>
+ Verifies viewport correctly shows and hides messages while logging and scrolling.
+</p>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698