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

Unified 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: Rebase again. Created 6 years, 2 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 | chrome/test/data/webui/webui_resource_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/context_menu_handler_test.html
diff --git a/chrome/test/data/webui/context_menu_handler_test.html b/chrome/test/data/webui/context_menu_handler_test.html
new file mode 100644
index 0000000000000000000000000000000000000000..4ca795363e6d8695a5b7b0b8a6f9098dee75b176
--- /dev/null
+++ b/chrome/test/data/webui/context_menu_handler_test.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script>
+
+function testShowAndHideEvents(callback) {
+ var cmh = cr.ui.contextMenuHandler;
+
+ // Create context menu.
+ var menu = document.createElement('div');
+ cr.ui.decorate(menu, cr.ui.Menu);
+ document.body.appendChild(menu);
+
+ var menuItem = document.createElement('div');
+ menu.addMenuItem(menuItem);
+
+ // Create target elements.
+ var elem1 = document.createElement('div');
+ var elem2 = document.createElement('div');
+
+ cmh.setContextMenu(elem1, menu);
+ cmh.setContextMenu(elem2, menu);
+
+ var callbacks = [];
+ cmh.addEventListener('show', function(e) { callbacks.push(e); });
+ cmh.addEventListener('hide', function(e) { callbacks.push(e); });
+
+ // Show context menu of elem1.
+ elem1.dispatchEvent(new MouseEvent('contextmenu'));
+ assertEquals(1, callbacks.length);
+ assertEquals('show', callbacks[0].type);
+ assertEquals(elem1, callbacks[0].element);
+ assertEquals(menu, callbacks[0].menu);
+
+ // Show context menu of elem2.
+ document.dispatchEvent(new MouseEvent('mousedown'));
+
+ // On Windows to prevent context menu show again by mouse right button up,
+ // we need to wait at least 50ms from the last hide of context menu.
+ var wait = cr.isWindows ? 100 : 0;
+
+ setTimeout(function() {
Dan Beam 2014/10/29 01:17:17 this is almost never a good idea. please make thi
+ elem2.dispatchEvent(new MouseEvent('contextmenu'));
+ assertEquals(3, callbacks.length);
+ assertEquals('hide', callbacks[1].type);
+ assertEquals(elem1, callbacks[1].element);
+ assertEquals(menu, callbacks[1].menu);
+ assertEquals('show', callbacks[2].type);
+ assertEquals(elem2, callbacks[2].element);
+ assertEquals(menu, callbacks[2].menu);
+
+ callback(false);
+ }, wait);
+}
+
+</script>
+</body>
+</html>
« 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