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

Side by Side Diff: chrome/test/data/webui/context_menu_handler_test.html

Issue 647483006: Fixed to return original context element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove setTimeout from test code. Created 5 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 | chrome/test/data/webui/webui_resource_browsertest.cc » ('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 <!DOCTYPE html>
2 <html>
3 <body>
4 <script>
5
6 function testShowAndHideEvents() {
Dan Beam 2015/04/22 18:15:59 var originalDateNow = Date.now;
yawano 2015/04/27 05:25:32 Done.
7 // Initial value is 1 since 0 becomes false.
8 var currentTime = 1;
9
10 // Overrides Date.now to simulate time.
11 Date.now = function() { return currentTime; };
12
13 var cmh = cr.ui.contextMenuHandler;
14
15 // Create context menu.
16 var menu = document.createElement('div');
17 cr.ui.decorate(menu, cr.ui.Menu);
18 document.body.appendChild(menu);
19
20 var menuItem = document.createElement('div');
21 menu.addMenuItem(menuItem);
22
23 // Create target elements.
24 var elem1 = document.createElement('div');
25 var elem2 = document.createElement('div');
26
27 cmh.setContextMenu(elem1, menu);
28 cmh.setContextMenu(elem2, menu);
29
30 var callbacks = [];
Dan Beam 2015/04/22 18:15:59 nit: callbacks -> events
yawano 2015/04/27 05:25:32 Done.
31 cmh.addEventListener('show', function(e) { callbacks.push(e); });
32 cmh.addEventListener('hide', function(e) { callbacks.push(e); });
33
34 // Show context menu of elem1.
35 elem1.dispatchEvent(new MouseEvent('contextmenu'));
36 assertEquals(1, callbacks.length);
37 assertEquals('show', callbacks[0].type);
38 assertEquals(elem1, callbacks[0].element);
39 assertEquals(menu, callbacks[0].menu);
40
41 // Show context menu of elem2.
42 document.dispatchEvent(new MouseEvent('mousedown'));
43
44 // On Windows to prevent context menu show again by mouse right button up,
45 // we need to wait at least 50ms from the last hide of context menu.
46 currentTime += 51; // ms
47
48 elem2.dispatchEvent(new MouseEvent('contextmenu'));
49 assertEquals(3, callbacks.length);
50 assertEquals('hide', callbacks[1].type);
51 assertEquals(elem1, callbacks[1].element);
52 assertEquals(menu, callbacks[1].menu);
53 assertEquals('show', callbacks[2].type);
54 assertEquals(elem2, callbacks[2].element);
55 assertEquals(menu, callbacks[2].menu);
Dan Beam 2015/04/22 18:15:59 Date.now = originalDateNow;
yawano 2015/04/27 05:25:32 Done.
56 }
57
58 </script>
59 </body>
60 </html>
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/webui/webui_resource_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698