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

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: Address comments 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 refreshLogAndContinue(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 refreshLogAndContinue(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 eViewportFromTimeoutForTest", 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 refreshLogAndContinue(next);
74 var isScrollPreserved = initialScrollTop - newScrollTop === manualSc rollValue; 68 }
75 InspectorTest.addResult("Scroll preserved: " + isScrollPreserved);
76 next();
77 }, 69 },
70
71 function testEscShouldNotJumpToBottom(next)
72 {
73 eventSender.keyDown('Escape');
74 refreshLogAndContinue(next);
75 },
76
77 function testTypingShouldJumpToBottom(next)
78 {
79 eventSender.keyDown('a');
80 refreshLogAndContinue(next);
81 },
82
lushnikov 2016/08/02 00:10:48 stray line
luoe 2016/08/02 19:17:15 Done.
83
84 function testViewportMuationsShouldPreserveStickToBottom(next)
lushnikov 2016/08/02 00:10:47 Muations -> Mutations
luoe 2016/08/02 19:17:15 Done.
85 {
86 viewport._contentElement.children[1].innerText = "More than 2 lines: foo\n\n\n\nbar";
87 refreshLogAndContinue(next);
88 }
78 ]; 89 ];
79 90
91 function sendPageUp()
92 {
93 // To ensure that PageUp scrolls up the viewport, check that the
94 // autocomplete suggest box (which may have a scrollbar) is not visible
95 // and clear the prompt text so that PageUp does not just move the
96 // cursor.
97 eventSender.keyDown('Tab');
lushnikov 2016/08/02 00:10:47 let's not use eventSender if possible
luoe 2016/08/02 19:17:15 Done.
98 consoleView._promptElement.textContent = "";
99 eventSender.keyDown('PageUp');
100 }
101
102 function refreshLogAndContinue(callback)
lushnikov 2016/08/02 00:10:47 in multiple tests across inspctor, we call such me
luoe 2016/08/02 19:17:15 Done.
103 {
104 viewport.refresh();
105 InspectorTest.addResult("Is at bottom: " + viewport.element.isScrolledTo Bottom() + ", should stick: " + viewport.stickToBottom());
106 callback();
107 }
108
80 function logMessagesToConsole(count, callback) 109 function logMessagesToConsole(count, callback)
81 { 110 {
82 var awaitingMessagesCount = count; 111 var awaitingMessagesCount = count;
83 function messageAdded() 112 function messageAdded()
84 { 113 {
85 if (!--awaitingMessagesCount) 114 if (!--awaitingMessagesCount)
86 callback(); 115 callback();
87 else 116 else
88 InspectorTest.addConsoleSniffer(messageAdded, false); 117 InspectorTest.addConsoleSniffer(messageAdded, false);
89 } 118 }
90 119
91 InspectorTest.addConsoleSniffer(messageAdded, false); 120 InspectorTest.addConsoleSniffer(messageAdded, false);
92 InspectorTest.evaluateInPage(String.sprintf("populateConsoleWithMessages (%d)", count)); 121 InspectorTest.evaluateInPage(String.sprintf("populateConsoleWithMessages (%d)", count));
93 } 122 }
94 } 123 }
95 </script> 124 </script>
96 </head> 125 </head>
97 <body onload="runTest()"> 126 <body onload="runTest()">
98 <p> 127 <p>
99 Verifies viewport stick-to-bottom behavior. 128 Verifies viewport stick-to-bottom behavior.
100 </p> 129 </p>
101 </body> 130 </body>
102 </html> 131 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698