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

Unified Diff: third_party/WebKit/LayoutTests/inspector/console/console-focus.html

Issue 2840663002: DevTools: clicking in console messages should not jump to bottom (Closed)
Patch Set: ac Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector/console/console-focus-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/inspector/console/console-focus.html
diff --git a/third_party/WebKit/LayoutTests/inspector/console/console-focus.html b/third_party/WebKit/LayoutTests/inspector/console/console-focus.html
new file mode 100644
index 0000000000000000000000000000000000000000..b72e040b98ae1aa8a10ae64f2266d2b5e2660533
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector/console/console-focus.html
@@ -0,0 +1,105 @@
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script src="../../http/tests/inspector/console-test.js"></script>
+<script>
+
+var test = function()
+{
+ var consoleView = Console.ConsoleView.instance();
+ var viewport = consoleView._viewport;
+ var prompt = consoleView._prompt;
+ var consoleEditor;
+ InspectorTest.waitUntilConsoleEditorLoaded().then(e => consoleEditor = e).then(logMessages);
+
+ // Ensure that the body is focusable.
+ document.body.tabIndex = -1;
+ function clearFocus() {
+ document.body.focus();
+ }
+
+ function logMessages() {
+ InspectorTest.waitForConsoleMessages(2, () => {
+ viewport.element.scrollTop = 0;
+ InspectorTest.runTestSuite(testSuite);
+ });
+ InspectorTest.evaluateInConsole("'foo " + "\n".repeat(50) + "bar'");
+ }
+
+ var testSuite = [
+ function testClickingWithSelectedTextShouldNotFocusPrompt(next) {
pfeldman 2017/04/27 21:51:51 But does it scroll? We are fixing scrolling here,
luoe 2017/04/27 22:24:40 Done.
+ clearFocus();
+ dumpFocusInfo();
+
+ // Make a selection.
+ var messageElement = consoleView.itemElement(0).element();
+ var firstTextNode = messageElement.traverseNextTextNode();
+ window.getSelection().setBaseAndExtent(firstTextNode, 0, firstTextNode, 1);
+
+ clickObjectInMessage(0);
+ dumpFocusInfo();
+ window.getSelection().removeAllRanges();
+ next();
+ },
+
+ function testClickOnMessageShouldFocusPromptWithoutScrolling(next) {
+ clearFocus();
+ dumpFocusInfo();
+ InspectorTest.addResult("Viewport scrollTop before: " + viewport.element.scrollTop);
+
+ clickObjectInMessage(0);
+
+ dumpFocusInfo();
+ InspectorTest.addResult("Viewport scrollTop after: " + viewport.element.scrollTop);
+ next();
+ },
+
+ function testClickOutsideMessageListShouldFocusPromptAndMoveCaretToEnd(next) {
pfeldman 2017/04/27 21:51:51 ditto
luoe 2017/04/27 22:24:40 Done.
+ clearFocus();
+ dumpFocusInfo();
+
+ prompt.setText("foobar");
+ consoleEditor.setSelection(TextUtils.TextRange.createFromLocation(0, 1));
+ InspectorTest.addResult("Selection before: " + consoleEditor.selection().toString());
+
+ consoleView._messagesElement.click();
+
+ InspectorTest.addResult("Selection after: " + consoleEditor.selection().toString());
+ dumpFocusInfo();
+ next();
+ }
+ ];
+
+ function clickObjectInMessage(index) {
+ var previewElement = consoleView._visibleViewMessages[index].element().querySelector('.source-code');
+ var previewRect = previewElement.getBoundingClientRect();
+ var clientX = previewRect.left + previewRect.width / 2;
+ var clientY = previewRect.top + previewRect.height / 2;
+
+ InspectorTest.addResult('Clicking message ' + index);
+ previewElement.dispatchEvent(new MouseEvent('click', {clientX: clientX, clientY: clientY, bubbles: true}));
+ }
+
+ function dumpFocusInfo()
+ {
+ var focusedElement = document.deepActiveElement();
+ if (focusedElement) {
+ var id = focusedElement.id ? (", id: " + focusedElement.id) : "";
+ var className = focusedElement.className ? (", class: " + focusedElement.className) : "";
+ InspectorTest.addResult("Focused element: " + focusedElement.tagName + id + className);
+ } else {
+ InspectorTest.addResult("No focus");
+ }
+ }
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+<p>
+Tests that interacting with the console gives appropriate focus.
+</p>
+
+</body>
+</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector/console/console-focus-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698