aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorCorey Frang <gnarf@gnarf.net>2011-08-19 06:07:47 -0500
committerCorey Frang <gnarf@gnarf.net>2011-08-19 06:07:47 -0500
commit8f16cc304a97c7c3c2b5ab69678d666ec9ebd75a (patch)
tree53d4587ee45e9a098bf3e41ef887238dde553c55 /tests/unit
parenta62074d477c19f135b60de963dfb49fdcab09de2 (diff)
downloadjquery-ui-8f16cc304a97c7c3c2b5ab69678d666ec9ebd75a.tar.gz
jquery-ui-8f16cc304a97c7c3c2b5ab69678d666ec9ebd75a.zip
Dialog: Tabbing out of a modal dialog was possible because keypress doesn't fire for tabs everywhere, switched to keyup. Added Unit Test - Caught by @DomenicDenicola - Fixes #3123 - Tabbing stops in modal dialog
(cherry picked from commit 96e5c241e1b26224c53738b590e07290db7a3e54)
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/dialog/dialog_tickets.js31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/unit/dialog/dialog_tickets.js b/tests/unit/dialog/dialog_tickets.js
index def2452de..acfddab43 100644
--- a/tests/unit/dialog/dialog_tickets.js
+++ b/tests/unit/dialog/dialog_tickets.js
@@ -3,7 +3,36 @@
*/
(function($) {
-module("dialog: tickets");
+module( "dialog: tickets" );
+
+asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
+ expect( 3 );
+
+ var el = $( "<div><input id='t3123-first'><input id='t3123-last'></div>" ).dialog({ modal: true }),
+ inputs = el.find( "input" ),
+ widget = el.dialog( "widget" );
+
+ inputs.eq( 1 ).focus();
+ equal( document.activeElement, inputs[1], "Focus set on second input" );
+ inputs.eq( 1 ).simulate( "keyup", { keyCode: $.ui.keyCode.TAB });
+
+ setTimeout( checkTab, 2 );
+
+ function checkTab() {
+ ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" );
+
+ // check shift tab
+ $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true });
+ setTimeout( checkShiftTab, 2 );
+ }
+
+ function checkShiftTab() {
+ ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" );
+
+ el.remove();
+ start();
+ }
+});
test("#4826: setting resizable false toggles resizable on dialog", function() {
expect(6);