Skip to content

Commit f3525af

Browse files
committed
Dialog: Update focus-tabbable test with a timer workaround to get IE8 to pass.
1 parent 73533d9 commit f3525af

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

tests/unit/dialog/dialog_core.js

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,36 @@ test( "focus tabbable", function() {
4848
}]
4949
};
5050

51-
// 1. first element inside the dialog matching [autofocus]
5251
el = $( "<div><input><input autofocus></div>" ).dialog( options );
53-
equal( document.activeElement, el.find( "input" )[ 1 ] );
52+
equal( document.activeElement, el.find( "input" )[ 1 ], "1. first element inside the dialog matching [autofocus]" );
5453
el.remove();
5554

56-
// 2. tabbable element inside the content element
57-
el = $( "<div><input><input></div>" ).dialog( options );
58-
equal( document.activeElement, el.find( "input" )[ 0 ] );
59-
el.remove();
60-
61-
// 3. tabbable element inside the buttonpane
62-
el = $( "<div>text</div>" ).dialog( options );
63-
equal( document.activeElement, el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ] );
64-
el.remove();
65-
66-
// 4. the close button
67-
el = $( "<div>text</div>" ).dialog();
68-
equal( document.activeElement, el.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ] );
69-
el.remove();
70-
71-
// 5. the dialog itself
72-
el = $( "<div>text</div>" ).dialog({
73-
autoOpen: false
74-
});
75-
el.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide();
76-
el.dialog( "open" );
77-
equal( document.activeElement, el.parent()[ 0 ] );
78-
el.remove();
55+
// IE8 fails to focus the input, <body> ends up being the activeElement
56+
// so wait for that stupid browser
57+
stop();
58+
setTimeout(function() {
59+
el = $( "<div><input><input></div>" ).dialog( options );
60+
equal( document.activeElement, el.find( "input" )[ 0 ], "2. tabbable element inside the content element" );
61+
el.remove();
62+
63+
el = $( "<div>text</div>" ).dialog( options );
64+
equal( document.activeElement, el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ], "3. tabbable element inside the buttonpane" );
65+
el.remove();
66+
67+
el = $( "<div>text</div>" ).dialog();
68+
equal( document.activeElement, el.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ], "4. the close button" );
69+
el.remove();
70+
71+
el = $( "<div>text</div>" ).dialog({
72+
autoOpen: false
73+
});
74+
el.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide();
75+
el.dialog( "open" );
76+
equal( document.activeElement, el.parent()[ 0 ], "5. the dialog itself" );
77+
el.remove();
78+
79+
start();
80+
}, 13);
7981
});
8082

8183
})(jQuery);

0 commit comments

Comments
 (0)