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

Unified Diff: chrome/test/data/webui/menu_button_test.html

Issue 1178783003: Add menuhide event to menu button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove initUIEvent. Created 5 years, 6 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/menu_button_test.html
diff --git a/chrome/test/data/webui/menu_button_test.html b/chrome/test/data/webui/menu_button_test.html
new file mode 100644
index 0000000000000000000000000000000000000000..2e0c222182fabc7af602d47ab2751c332d352481
--- /dev/null
+++ b/chrome/test/data/webui/menu_button_test.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script>
+
+function testMenuShowAndHideEvents() {
+ var menu = document.createElement('div');
+ cr.ui.decorate(menu, cr.ui.Menu);
+ document.body.appendChild(menu);
+
+ var menuButton = document.createElement('div');
+ cr.ui.decorate(menuButton, cr.ui.MenuButton);
+ menuButton.menu = menu;
+ document.body.appendChild(menuButton);
+
+ var events = [];
+ menuButton.addEventListener('menushow', function(e) { events.push(e); });
+ menuButton.addEventListener('menuhide', function(e) { events.push(e); });
+
+ // Click to show menu.
+ menuButton.dispatchEvent(new MouseEvent('mousedown'));
+ assertEquals(1, events.length);
+ assertEquals('menushow', events[0].type);
+ assertEquals(true, events[0].bubbles);
+ assertEquals(true, events[0].cancelable);
+ assertEquals(window, events[0].view);
+
+ // Click to hide menu by clicking the button.
+ menuButton.dispatchEvent(new MouseEvent('mousedown'));
+ assertEquals(2, events.length);
+ assertEquals('menuhide', events[1].type);
+ assertEquals(true, events[1].bubbles);
+ assertEquals(false, events[1].cancelable);
+ assertEquals(window, events[1].view);
+
+ // Click to show menu and hide by clicking the outside of the button.
+ menuButton.dispatchEvent(new MouseEvent('mousedown'));
+ assertEquals(3, events.length);
+ assertEquals('menushow', events[2].type);
+ document.dispatchEvent(new MouseEvent('mousedown'));
+ assertEquals(4, events.length);
+ assertEquals('menuhide', events[3].type);
+}
+
+</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