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

Unified Diff: remoting/webapp/unittests/menu_button_unittest.js

Issue 592793003: Make pop-up menus more easily dismissable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment and fixed unit tests. Created 6 years, 3 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
Index: remoting/webapp/unittests/menu_button_unittest.js
diff --git a/remoting/webapp/unittests/menu_button_unittest.js b/remoting/webapp/unittests/menu_button_unittest.js
index cba90fbc384e502e5bed94dba59ce823d33835bc..7337134d5ac6378487d26aa584fa060db90c28cf 100644
--- a/remoting/webapp/unittests/menu_button_unittest.js
+++ b/remoting/webapp/unittests/menu_button_unittest.js
@@ -40,22 +40,23 @@ test('should display on click', function() {
ok(menu.offsetWidth != 0 && menu.offsetHeight != 0);
});
-test('should dismiss when <body> is clicked', function() {
+test('should dismiss when the menu is clicked', function() {
var menu = menuButton.menu();
menuButton.button().click();
- document.body.click();
+ menu.click();
ok(menu.offsetWidth == 0 && menu.offsetHeight == 0);
});
-/*
-TODO(jamiewalch): Reinstate this once MenuButton is fixed properly.
-test('should dismiss when button is clicked', function() {
+test('should dismiss when anything outside the menu is clicked', function() {
var menu = menuButton.menu();
menuButton.button().click();
- menuButton.button().click();
+ var x = menu.offsetRight + 1;
+ var y = menu.offsetBottom + 1;
+ var notMenu = document.elementFromPoint(x, y);
+ base.debug.assert(notMenu != menu);
+ notMenu.click();
ok(menu.offsetWidth == 0 && menu.offsetHeight == 0);
});
-*/
test('should dismiss when menu item is clicked', function() {
var menu = menuButton.menu();
@@ -70,7 +71,7 @@ test('should invoke callbacks', function() {
menuButton.button().click();
ok(onShow.called);
ok(!onHide.called);
- document.body.click();
+ menuButton.menu().click();
ok(onHide.called);
});

Powered by Google App Engine
This is Rietveld 408576698