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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/inspector-unit/soft-context-menu.js

Issue 2824023002: DevTools: Use FocusRestorer in SoftContextMenu (Closed)
Patch Set: Print keys in test 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector-unit/soft-context-menu-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 var menu = new UI.SoftContextMenu([{
2 type: 'item',
3 label: 'First',
4 enabled: true
5 },
6 {
7 type: 'subMenu',
8 label: 'Second',
9 enabled: true,
10 subItems: [
11 {type: 'subMenu', label: 'Child 1', enabled: true, subItems: [{type: 'item', label: 'Grandchild', id: 'Grandchild', enabled: true}]},
12 {type: 'item', label: 'Child 2', enabled: true},
13 {type: 'item', label: 'Child 3', enabled: true},
14 {type: 'item', label: 'Child 4', enabled: true}
15 ]
16 },
17 {
18 type: 'separator',
19 },{
20 type: 'item',
21 label: 'Third',
22 enabled: true
23 }], item => TestRunner.addResult('Item Selected: ' + item));
24
25 var initialFocusedElement = UI.inspectorView.element.createChild('div');
26 initialFocusedElement.textContent = 'Initial Focused Element';
27 initialFocusedElement.tabIndex = -1;
28 initialFocusedElement.focus();
29
30 dumpContextMenu();
31 menu.show(document, new AnchorBox(50, 50, 0, 0));
32 dumpContextMenu();
33 pressKey('ArrowDown');
34 pressKey('ArrowDown');
35 pressKey('ArrowDown');
36 pressKey('ArrowUp');
37 pressKey('ArrowUp');
38 pressKey('ArrowUp');
39 pressKey('ArrowDown');
40 TestRunner.addResult('Enter Submenu');
41 pressKey('ArrowRight');
42 pressKey('ArrowDown');
43 pressKey('ArrowDown');
44 pressKey('ArrowDown');
45 TestRunner.addResult('Leave Submenu ArrowLeft');
46 pressKey('ArrowLeft');
47 pressKey('ArrowRight');
48 TestRunner.addResult('Leave Submenu Escape');
49 pressKey('Escape');
50 TestRunner.addResult('Enter Sub-Submenu');
51 pressKey(' ');
52 pressKey('Enter');
53 pressKey('Enter');
54 TestRunner.completeTest();
55
56 function pressKey(key) {
57 var element = document.deepActiveElement();
58 if (!element)
59 return;
60 element.dispatchEvent(TestRunner.createKeyEvent(key));
61 if (key === ' ')
62 key = 'Space';
63 TestRunner.addResult(key);
64 dumpContextMenu();
65 }
66
67 function dumpContextMenu() {
68 if (initialFocusedElement.hasFocus()) {
69 TestRunner.addResult('Initial focused element has focus');
70 return;
71 }
72 var selection = '';
73 var subMenu = menu;
74 var activeElement = document.deepActiveElement();
75 do {
76 if (selection)
77 selection += ' -> ';
78 if (subMenu._contextMenuElement === activeElement)
79 selection += '[';
80 if (subMenu._highlightedMenuItemElement)
81 selection += subMenu._highlightedMenuItemElement.textContent.replace(/[^A- z0-9 ]/g, '');
82 else
83 selection += 'null'
84 if (subMenu._contextMenuElement === activeElement)
85 selection += ']';
86 }
87 while (subMenu = subMenu._subMenu)
88 TestRunner.addResult(selection);
89 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector-unit/soft-context-menu-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698