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

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: Changed to use event.type directly. 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..752e3fa99ce2d7ea6da24769ded61a2dd2287b53
--- /dev/null
+++ b/chrome/test/data/webui/context_menu_handler_test.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script>
+
+function testShowAndHideEvents() {
+ var cm = cr.ui.contextMenuHandler;
Dan Beam 2014/10/15 03:09:40 nit: cmh
yawano 2014/10/15 04:16:27 Done.
+
+ // Create context menu
Dan Beam 2014/10/15 03:09:41 nit: end comments with .
yawano 2014/10/15 04:16:26 Done.
+ 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');
+
+ cm.setContextMenu(elem1, menu);
+ cm.setContextMenu(elem2, menu);
+
+ var callbacks = [];
+ cm.addEventListener('show', function(e) { callbacks.push(e); });
+ cm.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'));
+ 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);
+}
+
+</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