aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorJay Merrifield <fracmak@gmail.com>2011-03-08 09:42:10 -0500
committerScott González <scott.gonzalez@gmail.com>2011-03-08 09:42:10 -0500
commitf9996682b5739661c21548f0de3d4c4883c5119d (patch)
treec2a20c11b85a4d6ced5ebe6a224e7f22c8c6f527 /tests/unit
parent3a0ec399cdd19c7e7b11934aef559cfa6b8f8258 (diff)
downloadjquery-ui-f9996682b5739661c21548f0de3d4c4883c5119d.tar.gz
jquery-ui-f9996682b5739661c21548f0de3d4c4883c5119d.zip
Dialog: Before handling escape key presses, check if the default action has been prevented. Fixes #6966 - Pressing ESC on dialog when 2 dialogs are open closes both dialogs.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/dialog/dialog_tickets.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/unit/dialog/dialog_tickets.js b/tests/unit/dialog/dialog_tickets.js
index b9bf2f972..def2452de 100644
--- a/tests/unit/dialog/dialog_tickets.js
+++ b/tests/unit/dialog/dialog_tickets.js
@@ -88,4 +88,29 @@ test("#6645: Missing element not found check in overlay", function(){
d1.add(d2).remove();
});
+test("#6966: Escape key closes all dialogs, not the top one", function(){
+ expect(8);
+ // test with close function removing dialog
+ d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true});
+ d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove()}});
+ ok(d1.dialog("isOpen"), 'first dialog is open');
+ ok(d2.dialog("isOpen"), 'second dialog is open');
+ d2.simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
+ ok(d1.dialog("isOpen"), 'first dialog still open');
+ ok(!d2.data('dialog'), 'second dialog is closed');
+ d2.remove();
+ d1.remove();
+
+ // test without close function removing dialog
+ d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true});
+ d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true});
+ ok(d1.dialog("isOpen"), 'first dialog is open');
+ ok(d2.dialog("isOpen"), 'second dialog is open');
+ d2.simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
+ ok(d1.dialog("isOpen"), 'first dialog still open');
+ ok(!d2.dialog("isOpen"), 'second dialog is closed');
+ d2.remove();
+ d1.remove();
+});
+
})(jQuery);