| 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..e3cd0e68a268cc42d68f47328bc7a27fabd27e89
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/inspector/console/console-viewport-control.html
|
| @@ -0,0 +1,164 @@
|
| +<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 printAndResetCounts(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, () => printAndResetCounts(next));
|
| + },
|
| +
|
| + function addMaxVisibleCount(next) {
|
| + clearConsoleAndReset();
|
| + logMessages(maxVisibleCount, false, () => printAndResetCounts(next));
|
| + },
|
| +
|
| + function addMaxActiveCount(next) {
|
| + clearConsoleAndReset();
|
| + logMessages(maxActiveCount, false, () => printAndResetCounts(next));
|
| + printStuckToBottom();
|
| + },
|
| +
|
| + function addMoreThanMaxActiveCount(next) {
|
| + clearConsoleAndReset();
|
| + logMessages(maxActiveCount, false, step2);
|
| + function step2() {
|
| + logMessages(smallCount, false, () => printAndResetCounts(next));
|
| + printStuckToBottom();
|
| + }
|
| + },
|
| +
|
| + function scrollUpWithinActiveWindow(next) {
|
| + clearConsoleAndReset();
|
| + logMessages(maxActiveCount, false, step2);
|
| + printStuckToBottom();
|
| + function step2() {
|
| + resetShowHideCounts();
|
| + viewport.forceScrollItemToBeFirst(0);
|
| + printAndResetCounts(next);
|
| + }
|
| + },
|
| +
|
| + function scrollUpToPositionOutsideOfActiveWindow(next) {
|
| + clearConsoleAndReset();
|
| + logMessages(maxActiveCount + smallCount, false, step2);
|
| + printStuckToBottom();
|
| + function step2() {
|
| + resetShowHideCounts();
|
| + viewport.forceScrollItemToBeFirst(0);
|
| + printAndResetCounts(next);
|
| + }
|
| + },
|
| +
|
| + function logRepeatingMessages(next) {
|
| + clearConsoleAndReset();
|
| + logMessages(maxVisibleCount, true, () => printAndResetCounts(next));
|
| + },
|
| +
|
| + function reorderingMessages(next) {
|
| + clearConsoleAndReset();
|
| + InspectorTest.addResult("Logging " + smallCount + " messages");
|
| + logMessages(smallCount, false, () => printAndResetCounts(step2));
|
| + function step2() {
|
| + resetShowHideCounts();
|
| + InspectorTest.addResult("Swapping messages 0 and 1");
|
| + var temp = consoleView._visibleViewMessages[0];
|
| + consoleView._visibleViewMessages[0] = consoleView._visibleViewMessages[1];
|
| + consoleView._visibleViewMessages[1] = temp;
|
| + viewport.invalidate();
|
| + printAndResetCounts(next);
|
| + }
|
| + }
|
| + ]);
|
| +}
|
| +</script>
|
| +</head>
|
| +<body onload="runTest()">
|
| +<p>
|
| + Verifies viewport correctly shows and hides messages while logging and scrolling.
|
| +</p>
|
| +</body>
|
| +</html>
|
|
|