aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/dialog
diff options
context:
space:
mode:
authorJay Merrifield <fracmak@gmail.com>2012-05-03 19:02:23 -0400
committerScott González <scott.gonzalez@gmail.com>2012-05-07 09:44:26 -0400
commitcab4c467d9c12ec61a652c3bf68eedd166319b34 (patch)
treee9d601d2ba5cf14f40a09917ccc17361b56eb37a /tests/unit/dialog
parent32f356bbfa9a8f3b90b4e64331e9108b4d87a349 (diff)
downloadjquery-ui-cab4c467d9c12ec61a652c3bf68eedd166319b34.tar.gz
jquery-ui-cab4c467d9c12ec61a652c3bf68eedd166319b34.zip
Dialog: Handle escape for all overlays. Fixes #8300 - Dialog: Incorrect behavior for ESCAPE with multiple modal dialogs.
Diffstat (limited to 'tests/unit/dialog')
-rw-r--r--tests/unit/dialog/dialog_tickets.js62
1 files changed, 56 insertions, 6 deletions
diff --git a/tests/unit/dialog/dialog_tickets.js b/tests/unit/dialog/dialog_tickets.js
index a169bd1a5..98983cf33 100644
--- a/tests/unit/dialog/dialog_tickets.js
+++ b/tests/unit/dialog/dialog_tickets.js
@@ -117,26 +117,76 @@ test("#6645: Missing element not found check in overlay", function(){
});
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});
+ expect(24);
+ // test with close function removing dialog triggered through the overlay
+ d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true, close: function(){ d1.remove(); }});
+ d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove(); }});
+
+ ok(d1.data('dialog') && d1.dialog('isOpen'), 'first dialog is open');
+ ok(d2.data('dialog') && d2.dialog('isOpen'), 'second dialog is open');
+
+ $( document ).simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
+ ok(d1.data('dialog') && d1.dialog('isOpen'), 'first dialog still open');
+ ok(!d2.data('dialog'), 'second dialog is closed');
+
+ $( document ).simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
+ ok(!d1.data('dialog'), 'first dialog is closed');
+ ok(!d2.data('dialog'), 'second dialog is closed');
+
+ d2.remove();
+ d1.remove();
+
+ // test with close function removing dialog triggered through the dialog
+ d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true, close: function(){ d1.remove(); }});
d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove(); }});
+
+ ok(d1.data('dialog') && d1.dialog('isOpen'), 'first dialog is open');
+ ok(d2.data('dialog') && d2.dialog('isOpen'), 'second dialog is open');
+
+ d2.simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
+ ok(d1.data('dialog') && d1.dialog('isOpen'), 'first dialog still open');
+ ok(!d2.data('dialog'), 'second dialog is closed');
+
+ d1.simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
+ ok(!d1.data('dialog'), 'first dialog is closed');
+ 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.data('dialog'), 'second dialog is closed');
+ ok(!d2.dialog("isOpen"), 'second dialog is closed');
+
+ d1.simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
+ ok(!d1.dialog("isOpen"), 'first dialog is closed');
+ ok(!d2.dialog("isOpen"), 'second dialog is closed');
+
d2.remove();
d1.remove();
- // test without close function removing dialog
+ // test without close function removing dialog triggered through the overlay
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});
+
+ $( document ).simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
ok(d1.dialog("isOpen"), 'first dialog still open');
ok(!d2.dialog("isOpen"), 'second dialog is closed');
+
+ $( document ).simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
+ ok(!d1.dialog("isOpen"), 'first dialog is closed');
+ ok(!d2.dialog("isOpen"), 'second dialog is closed');
+
d2.remove();
d1.remove();
});