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

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: Rename forTest fn() 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() {
dgozman 2016/08/03 21:19:00 style: { on next line
luoe 2016/08/04 23:13:01 Done.
73 var newScrollTop = viewport.element.scrollTop; 67 dumpAndContinue(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 var keyEvent = InspectorTest.createKeyEvent("Escape");
74 viewport._contentElement.dispatchEvent(keyEvent);
75 dumpAndContinue(next);
76 },
77
78 function testTypingShouldJumpToBottom(next)
79 {
80 var keyEvent = InspectorTest.createKeyEvent("a");
81 viewport._contentElement.dispatchEvent(keyEvent);
82 dumpAndContinue(next);
83 },
84
85 function testViewportMutationsShouldPreserveStickToBottom(next)
86 {
87 viewport._contentElement.children[1].innerText = "More than 2 lines: foo\n\n\n\nbar";
dgozman 2016/08/03 21:19:00 Does this really make it multiline? Maybe use br i
luoe 2016/08/04 23:13:01 Yes, it does make it multiline, the '\n' is auto-r
88 dumpAndContinue(next);
89 }
78 ]; 90 ];
79 91
92 function sendPageUp()
93 {
94 var keyEvent = InspectorTest.createKeyEvent("PageUp");
95 viewport._contentElement.dispatchEvent(keyEvent);
96 viewport.element.scrollTop -= 10;
97 }
98
99 function dumpAndContinue(callback)
100 {
101 viewport.refresh();
102 InspectorTest.addResult("Is at bottom: " + viewport.element.isScrolledTo Bottom() + ", should stick: " + viewport.stickToBottom());
103 callback();
104 }
105
80 function logMessagesToConsole(count, callback) 106 function logMessagesToConsole(count, callback)
81 { 107 {
82 var awaitingMessagesCount = count; 108 var awaitingMessagesCount = count;
83 function messageAdded() 109 function messageAdded()
84 { 110 {
85 if (!--awaitingMessagesCount) 111 if (!--awaitingMessagesCount)
86 callback(); 112 callback();
87 else 113 else
88 InspectorTest.addConsoleSniffer(messageAdded, false); 114 InspectorTest.addConsoleSniffer(messageAdded, false);
89 } 115 }
90 116
91 InspectorTest.addConsoleSniffer(messageAdded, false); 117 InspectorTest.addConsoleSniffer(messageAdded, false);
92 InspectorTest.evaluateInPage(String.sprintf("populateConsoleWithMessages (%d)", count)); 118 InspectorTest.evaluateInPage(String.sprintf("populateConsoleWithMessages (%d)", count));
93 } 119 }
94 } 120 }
95 </script> 121 </script>
96 </head> 122 </head>
97 <body onload="runTest()"> 123 <body onload="runTest()">
98 <p> 124 <p>
99 Verifies viewport stick-to-bottom behavior. 125 Verifies viewport stick-to-bottom behavior.
100 </p> 126 </p>
101 </body> 127 </body>
102 </html> 128 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698