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

Side by Side 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: fix platform dependent test Created 3 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector/console/console-focus-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/console-test.js"></script>
5 <script>
6
7 var test = function()
8 {
9 var consoleView = Console.ConsoleView.instance();
10 var viewport = consoleView._viewport;
11 var prompt = consoleView._prompt;
12 var consoleEditor;
13 InspectorTest.waitUntilConsoleEditorLoaded().then(e => consoleEditor = e).th en(logMessages);
14
15 // Ensure that the body is focusable.
16 document.body.tabIndex = -1;
17 function resetAndDumpFocusAndScrollTop() {
18 document.body.focus();
19 viewport.element.scrollTop = 0;
20 dumpFocusAndScrollInfo();
21 }
22
23 function logMessages() {
24 InspectorTest.waitForConsoleMessages(2, () => InspectorTest.runTestSuite (testSuite));
25 InspectorTest.evaluateInConsole("'foo " + "\n".repeat(50) + "bar'");
26 }
27
28 var testSuite = [
29 function testClickingWithSelectedTextShouldNotFocusPrompt(next) {
30 resetAndDumpFocusAndScrollTop();
31
32 // Make a selection.
33 var messageElement = consoleView.itemElement(0).element();
34 var firstTextNode = messageElement.traverseNextTextNode();
35 window.getSelection().setBaseAndExtent(firstTextNode, 0, firstTextNo de, 1);
36
37 clickObjectInMessage(0);
38 dumpFocusAndScrollInfo();
39 window.getSelection().removeAllRanges();
40 next();
41 },
42
43 function testClickOnMessageShouldFocusPromptWithoutScrolling(next) {
44 resetAndDumpFocusAndScrollTop();
45
46 clickObjectInMessage(0);
47
48 dumpFocusAndScrollInfo();
49 next();
50 },
51
52 function testClickOutsideMessageListShouldFocusPromptAndMoveCaretToEnd(n ext) {
53 prompt.setText("foobar");
54 consoleEditor.setSelection(TextUtils.TextRange.createFromLocation(0, 1));
55 resetAndDumpFocusAndScrollTop();
56 InspectorTest.addResult("Selection before: " + consoleEditor.selecti on().toString());
57
58 InspectorTest.addResult("Clicking on container");
59 consoleView._messagesElement.click();
60
61 dumpFocusAndScrollInfo();
62 InspectorTest.addResult("Selection after: " + consoleEditor.selectio n().toString());
63 next();
64 }
65 ];
66
67 function clickObjectInMessage(index) {
68 var previewElement = consoleView._visibleViewMessages[index].element().q uerySelector('.source-code');
69 var previewRect = previewElement.getBoundingClientRect();
70 var clientX = previewRect.left + previewRect.width / 2;
71 var clientY = previewRect.top + previewRect.height / 2;
72
73 InspectorTest.addResult('Clicking message ' + index);
74 previewElement.dispatchEvent(new MouseEvent('click', {clientX: clientX, clientY: clientY, bubbles: true}));
75 }
76
77 function dumpFocusAndScrollInfo()
78 {
79 var focusedElement = document.deepActiveElement();
80 if (focusedElement)
81 InspectorTest.addResult("Focused element: " + focusedElement.tagName );
82 else
83 InspectorTest.addResult("No focus");
84 InspectorTest.addResult("Viewport scrolled to top: " + String(viewport.e lement.scrollTop === 0));
85 }
86 }
87
88 </script>
89 </head>
90
91 <body onload="runTest()">
92 <p>
93 Tests that interacting with the console gives appropriate focus.
94 </p>
95
96 </body>
97 </html>
OLDNEW
« 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