| OLD | NEW |
| 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"); |
| 11 } | 11 } |
| 12 | 12 |
| 13 //# sourceURL=console-viewport-selection.html | 13 //# sourceURL=console-viewport-selection.html |
| 14 </script> | 14 </script> |
| 15 | 15 |
| 16 <script> | 16 <script> |
| 17 // window.debugTest = true |
| 17 | 18 |
| 18 function test() | 19 function test() |
| 19 { | 20 { |
| 20 InspectorTest.fixConsoleViewportDimensions(600, 200); | 21 InspectorTest.fixConsoleViewportDimensions(600, 200); |
| 21 var consoleView = WebInspector.ConsoleView.instance(); | 22 var consoleView = WebInspector.ConsoleView.instance(); |
| 22 var viewport = consoleView._viewport; | 23 var viewport = consoleView._viewport; |
| 23 const minimumViewportMessagesCount = 10; | 24 const minimumViewportMessagesCount = 10; |
| 24 const messagesCount = 150; | 25 const messagesCount = 150; |
| 25 const middleMessage = messagesCount / 2; | 26 const middleMessage = messagesCount / 2; |
| 26 var viewportMessagesCount; | 27 var viewportMessagesCount; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 49 InspectorTest.addResult("Last visible message: " + viewport.lastVisi
bleIndex()); | 50 InspectorTest.addResult("Last visible message: " + viewport.lastVisi
bleIndex()); |
| 50 next(); | 51 next(); |
| 51 }, | 52 }, |
| 52 | 53 |
| 53 function testConsoleSticksToBottom(next) | 54 function testConsoleSticksToBottom(next) |
| 54 { | 55 { |
| 55 logMessagesToConsole(messagesCount, onMessagesDumped); | 56 logMessagesToConsole(messagesCount, onMessagesDumped); |
| 56 | 57 |
| 57 function onMessagesDumped() | 58 function onMessagesDumped() |
| 58 { | 59 { |
| 60 // Force a second call to refresh() after a first call within |
| 61 // invalidate() triggers a scroll to bottom event. |
| 59 viewport.invalidate(); | 62 viewport.invalidate(); |
| 60 // Force refresh which has been scheduled via invalidate() metho
d. | |
| 61 viewport.refresh(); | 63 viewport.refresh(); |
| 62 InspectorTest.addResult("Last visible message: " + viewport.last
VisibleIndex()); | 64 |
| 65 logIsAtBottom(); |
| 63 next(); | 66 next(); |
| 64 } | 67 } |
| 65 }, | 68 }, |
| 66 | 69 |
| 67 function testManualScrollDoesNotStickToBottom(next) | 70 // function testEscShouldNotJumpToBottom(next) |
| 68 { | 71 // { |
| 69 const manualScrollValue = 3; | 72 // eventSender.keyDown('Escape'); |
| 70 var initialScrollTop = viewport.element.scrollTop; | 73 // InspectorTest.addSniffer(WebInspector.ConsoleView.prototype, "_sc
rollUpdatedByUserForTest", function () { |
| 71 viewport.element.scrollTop = initialScrollTop - manualScrollValue; | 74 // logIsAtBottom(); |
| 72 viewport.refresh(); | 75 // next(); |
| 73 var newScrollTop = viewport.element.scrollTop; | 76 // }); |
| 74 var isScrollPreserved = initialScrollTop - newScrollTop === manualSc
rollValue; | 77 // }, |
| 75 InspectorTest.addResult("Scroll preserved: " + isScrollPreserved); | 78 |
| 76 next(); | 79 // function testTypingShouldJumpToBottom(next) |
| 77 }, | 80 // { |
| 81 // eventSender.keyDown('a'); |
| 82 // InspectorTest.addSniffer(WebInspector.ConsoleView.prototype, "_sc
rollUpdatedByUserForTest", function () { |
| 83 // logIsAtBottom(); |
| 84 // next(); |
| 85 // }); |
| 86 // }, |
| 87 |
| 88 // function testSmoothScrollDoesNotStickToBottom(next) |
| 89 // { |
| 90 // eventSender.keyDown('PageUp'); |
| 91 // InspectorTest.addSniffer(WebInspector.ConsoleView.prototype, "_sc
rollUpdatedByUserForTest", function () { |
| 92 // logIsAtBottom(); |
| 93 // next(); |
| 94 // }); |
| 95 // }, |
| 96 |
| 97 function testViewportMuationsShouldPreserveStickToBottom(next) { |
| 98 InspectorTest.addSniffer(WebInspector.ViewportControl.prototype, "re
fresh", onRefresh); |
| 99 viewport._contentElement.children[1].innerText = "foo\n\n\n\nbar"; |
| 100 |
| 101 function onRefresh() |
| 102 { |
| 103 logIsAtBottom(); |
| 104 next(); |
| 105 } |
| 106 } |
| 78 ]; | 107 ]; |
| 79 | 108 |
| 109 function logIsAtBottom(distance) |
| 110 { |
| 111 var dist = viewport.element.scrollHeight - (viewport.element.scrollTop +
viewport.element.clientHeight); |
| 112 if (distance) |
| 113 InspectorTest.addResult("Distance from bottom: " + dist); |
| 114 else |
| 115 InspectorTest.addResult("Is at bottom: " + viewport.element.isScroll
edToBottom() + ", should stick: " + viewport.stickToBottom()); |
| 116 } |
| 117 |
| 118 |
| 80 function logMessagesToConsole(count, callback) | 119 function logMessagesToConsole(count, callback) |
| 81 { | 120 { |
| 82 var awaitingMessagesCount = count; | 121 var awaitingMessagesCount = count; |
| 83 function messageAdded() | 122 function messageAdded() |
| 84 { | 123 { |
| 85 if (!--awaitingMessagesCount) | 124 if (!--awaitingMessagesCount) |
| 86 callback(); | 125 callback(); |
| 87 else | 126 else |
| 88 InspectorTest.addConsoleSniffer(messageAdded, false); | 127 InspectorTest.addConsoleSniffer(messageAdded, false); |
| 89 } | 128 } |
| 90 | 129 |
| 91 InspectorTest.addConsoleSniffer(messageAdded, false); | 130 InspectorTest.addConsoleSniffer(messageAdded, false); |
| 92 InspectorTest.evaluateInPage(String.sprintf("populateConsoleWithMessages
(%d)", count)); | 131 InspectorTest.evaluateInPage(String.sprintf("populateConsoleWithMessages
(%d)", count)); |
| 93 } | 132 } |
| 94 } | 133 } |
| 95 </script> | 134 </script> |
| 96 </head> | 135 </head> |
| 97 <body onload="runTest()"> | 136 <body onload="runTest()"> |
| 98 <p> | 137 <p> |
| 99 Verifies viewport stick-to-bottom behavior. | 138 Verifies viewport stick-to-bottom behavior. |
| 100 </p> | 139 </p> |
| 101 </body> | 140 </body> |
| 102 </html> | 141 </html> |
| OLD | NEW |