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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector/console/console-viewport-stick-to-bottom.html

Issue 2179123004: DevTools: fix stick to bottom in console viewport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed. Created 4 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
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script> 3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/console-test.js"></script> 4 <script src="../../http/tests/inspector/console-test.js"></script>
5 <script> 5 <script>
6 function populateConsoleWithMessages(count) 6 function populateConsoleWithMessages(count)
7 { 7 {
8 for (var i = 0; i < count - 1; ++i) 8 for (var i = 0; i < count - 1; ++i)
9 console.log("Multiline\nMessage #" + i); 9 console.log("Multiline\nMessage #" + i);
10 console.log("hello %cworld", "color: blue"); 10 console.log("hello %cworld", "color: blue");
(...skipping 27 matching lines...) Expand all
38 InspectorTest.completeTest(); 38 InspectorTest.completeTest();
39 return; 39 return;
40 } 40 }
41 InspectorTest.addResult(String.sprintf("Viewport contains %d message s", viewportMessagesCount)); 41 InspectorTest.addResult(String.sprintf("Viewport contains %d message s", viewportMessagesCount));
42 next(); 42 next();
43 }, 43 },
44 44
45 function testScrollViewportToBottom(next) 45 function testScrollViewportToBottom(next)
46 { 46 {
47 consoleView._immediatelyScrollToBottom(); 47 consoleView._immediatelyScrollToBottom();
48 viewport.refresh(); 48 dumpAndContinue(next);
49 InspectorTest.addResult("Last visible message: " + viewport.lastVisi bleIndex());
50 next();
51 }, 49 },
52 50
53 function testConsoleSticksToBottom(next) 51 function testConsoleSticksToBottom(next)
54 { 52 {
55 logMessagesToConsole(messagesCount, onMessagesDumped); 53 logMessagesToConsole(messagesCount, onMessagesDumped);
56 54
57 function onMessagesDumped() 55 function onMessagesDumped()
58 { 56 {
59 viewport.invalidate(); 57 dumpAndContinue(next);
60 // Force refresh which has been scheduled via invalidate() metho d.
61 viewport.refresh();
62 InspectorTest.addResult("Last visible message: " + viewport.last VisibleIndex());
63 next();
64 } 58 }
65 }, 59 },
66 60
67 function testManualScrollDoesNotStickToBottom(next) 61 function testSmoothScrollDoesNotStickToBottom(next)
68 { 62 {
69 const manualScrollValue = 3; 63 InspectorTest.addSniffer(WebInspector.ConsoleView.prototype, "_updat eViewportStickinessForTest", onUpdateTimeout);
70 var initialScrollTop = viewport.element.scrollTop; 64 sendPageUp();
71 viewport.element.scrollTop = initialScrollTop - manualScrollValue; 65
72 viewport.refresh(); 66 function onUpdateTimeout()
73 var newScrollTop = viewport.element.scrollTop; 67 {
74 var isScrollPreserved = initialScrollTop - newScrollTop === manualSc rollValue; 68 dumpAndContinue(next);
75 InspectorTest.addResult("Scroll preserved: " + isScrollPreserved); 69 }
76 next();
77 }, 70 },
71
72 function testEscShouldNotJumpToBottom(next)
73 {
74 var keyEvent = InspectorTest.createKeyEvent("Escape");
75 viewport._contentElement.dispatchEvent(keyEvent);
76 dumpAndContinue(next);
77 },
78
79 function testTypingShouldJumpToBottom(next)
80 {
81 var keyEvent = InspectorTest.createKeyEvent("a");
82 viewport._contentElement.dispatchEvent(keyEvent);
83 consoleView._prompt._proxyElement.dispatchEvent(new Event('input'));
84
85 dumpAndContinue(next);
86 },
87
88 function testViewportMutationsShouldPreserveStickToBottom(next)
89 {
90 viewport._contentElement.children[1].innerText = "More than 2 lines: foo\n\nbar";
91 dumpAndContinue(onMessagesDumped);
92
93 function onMessagesDumped()
94 {
95 viewport.setStickToBottom(false);
96 viewport._contentElement.children[1].innerText = "More than 3 li nes: foo\n\n\nbar";
97 dumpAndContinue(next);
98 }
99 }
78 ]; 100 ];
79 101
102 function sendPageUp()
103 {
104 var keyEvent = InspectorTest.createKeyEvent("PageUp");
105 consoleView._prompt._proxyElement.dispatchEvent(keyEvent);
106 viewport.element.scrollTop -= 10;
107 }
108
109 function dumpAndContinue(callback)
110 {
111 viewport.refresh();
112 InspectorTest.addResult("Is at bottom: " + viewport.element.isScrolledTo Bottom() + ", should stick: " + viewport.stickToBottom());
113 callback();
114 }
115
80 function logMessagesToConsole(count, callback) 116 function logMessagesToConsole(count, callback)
81 { 117 {
82 var awaitingMessagesCount = count; 118 var awaitingMessagesCount = count;
83 function messageAdded() 119 function messageAdded()
84 { 120 {
85 if (!--awaitingMessagesCount) 121 if (!--awaitingMessagesCount)
86 callback(); 122 callback();
87 else 123 else
88 InspectorTest.addConsoleSniffer(messageAdded, false); 124 InspectorTest.addConsoleSniffer(messageAdded, false);
89 } 125 }
90 126
91 InspectorTest.addConsoleSniffer(messageAdded, false); 127 InspectorTest.addConsoleSniffer(messageAdded, false);
92 InspectorTest.evaluateInPage(String.sprintf("populateConsoleWithMessages (%d)", count)); 128 InspectorTest.evaluateInPage(String.sprintf("populateConsoleWithMessages (%d)", count));
93 } 129 }
94 } 130 }
95 </script> 131 </script>
96 </head> 132 </head>
97 <body onload="runTest()"> 133 <body onload="runTest()">
98 <p> 134 <p>
99 Verifies viewport stick-to-bottom behavior. 135 Verifies viewport stick-to-bottom behavior.
100 </p> 136 </p>
101 </body> 137 </body>
102 </html> 138 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698