aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/dialog/dialog_core.js48
-rw-r--r--tests/unit/menu/menu.html4
-rw-r--r--tests/unit/menu/menu_events.js12
-rw-r--r--tests/unit/testsuite.js4
4 files changed, 61 insertions, 7 deletions
diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js
index 062d44576..c08019da9 100644
--- a/tests/unit/dialog/dialog_core.js
+++ b/tests/unit/dialog/dialog_core.js
@@ -4,6 +4,7 @@
(function($) {
+// TODO add teardown callback to remove dialogs
module("dialog: core");
test("title id", function() {
@@ -180,4 +181,51 @@ asyncTest( "#9048: multiple modal dialogs opened and closed in different order",
start();
});
});
+
+asyncTest( "interaction between overlay and other dialogs", function() {
+ $.widget( "ui.testWidget", $.ui.dialog, {
+ options: {
+ modal: true,
+ autoOpen: false
+ }
+ });
+ expect( 2 );
+ var first = $( "<div><input id='input-1'></div>" ).dialog({
+ modal: true
+ }),
+ firstInput = first.find( "input" ),
+ second = $( "<div><input id='input-2'></div>" ).testWidget(),
+ secondInput = second.find( "input" );
+
+ // Support: IE8
+ // For some reason the focus doesn't get set properly if we don't
+ // focus the body first.
+ $( "body" ).focus();
+
+ // Wait for the modal to init
+ setTimeout(function() {
+ second.testWidget( "open" );
+
+ // Simulate user tabbing from address bar to an element outside the dialog
+ $( "#favorite-animal" ).focus();
+ setTimeout(function() {
+ equal( document.activeElement, secondInput[ 0 ] );
+
+ // Last active dialog must receive focus
+ firstInput.focus();
+ $( "#favorite-animal" ).focus();
+ setTimeout(function() {
+ equal( document.activeElement, firstInput[ 0 ] );
+
+ // Cleanup
+ first.remove();
+ second.remove();
+ delete $.ui.testWidget;
+ delete $.fn.testWidget;
+ start();
+ });
+ });
+ });
+});
+
})(jQuery);
diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html
index a49c72a04..504d3f3cf 100644
--- a/tests/unit/menu/menu.html
+++ b/tests/unit/menu/menu.html
@@ -31,6 +31,10 @@
<style>
.ui-menu {
font-size: 15px;
+ line-height: 15px;
+ }
+ .ui-menu .ui-menu-item {
+ padding: 0;
}
#menu3 {
height: 250px;
diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js
index 9d74b4bbb..3f834fd66 100644
--- a/tests/unit/menu/menu_events.js
+++ b/tests/unit/menu/menu_events.js
@@ -389,15 +389,15 @@ asyncTest( "handle keyboard navigation on menu with scroll and without submenus"
log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equal( logOutput(), "keydown,11", "Keydown PAGE_DOWN" );
+ equal( logOutput(), "keydown,17", "Keydown PAGE_DOWN" );
log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equal( logOutput(), "keydown,22", "Keydown PAGE_DOWN" );
+ equal( logOutput(), "keydown,34", "Keydown PAGE_DOWN" );
log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
- equal( logOutput(), "keydown,11", "Keydown PAGE_UP" );
+ equal( logOutput(), "keydown,17", "Keydown PAGE_UP" );
log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
@@ -484,15 +484,15 @@ asyncTest( "handle keyboard navigation on menu with scroll and with submenus", f
function menukeyboard3() {
log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equal( logOutput(), "keydown,11", "Keydown PAGE_DOWN" );
+ equal( logOutput(), "keydown,17", "Keydown PAGE_DOWN" );
log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equal( logOutput(), "keydown,22", "Keydown PAGE_DOWN" );
+ equal( logOutput(), "keydown,27", "Keydown PAGE_DOWN" );
log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
- equal( logOutput(), "keydown,11", "Keydown PAGE_UP" );
+ equal( logOutput(), "keydown,10", "Keydown PAGE_UP" );
log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js
index 13daa7e66..ffd1e73de 100644
--- a/tests/unit/testsuite.js
+++ b/tests/unit/testsuite.js
@@ -59,7 +59,9 @@ QUnit.config.urlConfig.push({
jshintLoaded = false;
TestHelpers.testJshint = function( module ) {
- if ( QUnit.urlParams.nojshint ) {
+ // Function.prototype.bind check is needed because JSHint doesn't work in ES3 browsers anymore
+ // https://github.com/jshint/jshint/issues/1384
+ if ( QUnit.urlParams.nojshint || !Function.prototype.bind ) {
return;
}