aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2012-12-10 10:35:28 -0500
committerScott González <scott.gonzalez@gmail.com>2012-12-10 10:35:28 -0500
commitd5f06c319a0508bfa342717cb7b50b97acddfb15 (patch)
tree4a0208a4c5d16aa4f8d56136f1d539cd163db647 /tests
parentfbc7956b9fbbc14f7854588341177075282d56b5 (diff)
downloadjquery-ui-d5f06c319a0508bfa342717cb7b50b97acddfb15.tar.gz
jquery-ui-d5f06c319a0508bfa342717cb7b50b97acddfb15.zip
Spinner tests: Better handling of async focus in IE.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/spinner/spinner_events.js171
1 files changed, 100 insertions, 71 deletions
diff --git a/tests/unit/spinner/spinner_events.js b/tests/unit/spinner/spinner_events.js
index 64f510de0..7da16c371 100644
--- a/tests/unit/spinner/spinner_events.js
+++ b/tests/unit/spinner/spinner_events.js
@@ -131,100 +131,129 @@ asyncTest( "change", function() {
});
}
- element.focus();
- shouldChange( false, "key UP, before blur" );
- simulateKeyDownUp( element, $.ui.keyCode.UP );
- shouldChange( true, "blur after key UP" );
- element.blur();
+ function focusWrap( fn, next ) {
+ element[0].focus();
+ setTimeout( function() {
+ fn();
+ setTimeout(function() {
+ element[0].blur();
+ setTimeout( next );
+ });
+ });
+ }
- element.focus();
- shouldChange( false, "key DOWN, before blur" );
- simulateKeyDownUp( element, $.ui.keyCode.DOWN );
- shouldChange( true, "blur after key DOWN" );
- element.blur();
+ function step1() {
+ focusWrap(function() {
+ shouldChange( false, "key UP, before blur" );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
+ shouldChange( true, "blur after key UP" );
+ }, step2 );
+ }
- element.focus();
- shouldChange( false, "key PAGE_UP, before blur" );
- simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
- shouldChange( true, "blur after key PAGE_UP" );
- element.blur();
+ function step2() {
+ focusWrap(function() {
+ shouldChange( false, "key DOWN, before blur" );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ shouldChange( true, "blur after key DOWN" );
+ }, step3 );
+ }
- element.focus();
- shouldChange( false, "key PAGE_DOWN, before blur" );
- simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
- shouldChange( true, "blur after key PAGE_DOWN" );
- element.blur();
+ function step3() {
+ focusWrap(function() {
+ shouldChange( false, "key PAGE_UP, before blur" );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ shouldChange( true, "blur after key PAGE_UP" );
+ }, step4 );
+ }
- shouldChange( false, "many keys, before blur" );
- simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
- simulateKeyDownUp( element, $.ui.keyCode.UP );
- simulateKeyDownUp( element, $.ui.keyCode.UP );
- simulateKeyDownUp( element, $.ui.keyCode.UP );
- simulateKeyDownUp( element, $.ui.keyCode.DOWN );
- shouldChange( true, "blur after many keys" );
- element.blur();
+ function step4() {
+ focusWrap(function() {
+ shouldChange( false, "key PAGE_DOWN, before blur" );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ shouldChange( true, "blur after key PAGE_DOWN" );
+ }, step5 );
+ }
- shouldChange( false, "many keys, same final value, before blur" );
- simulateKeyDownUp( element, $.ui.keyCode.UP );
- simulateKeyDownUp( element, $.ui.keyCode.UP );
- simulateKeyDownUp( element, $.ui.keyCode.DOWN );
- simulateKeyDownUp( element, $.ui.keyCode.DOWN );
- shouldChange( false, "blur after many keys, same final value" );
+ function step5() {
+ focusWrap(function() {
+ shouldChange( false, "many keys, before blur" );
+ simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ shouldChange( true, "blur after many keys" );
+ }, step6 );
+ }
- shouldChange( false, "button up, before blur" );
- element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
- shouldChange( true, "blur after button up" );
- setTimeout(function() {
- element.blur();
+ function step6() {
+ focusWrap(function() {
+ shouldChange( false, "many keys, same final value, before blur" );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.UP );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ shouldChange( false, "blur after many keys, same final value" );
- shouldChange( false, "button down, before blur" );
- element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
- shouldChange( true, "blur after button down" );
- setTimeout(function() {
- element.blur();
+ shouldChange( false, "button up, before blur" );
+ element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
+ shouldChange( true, "blur after button up" );
+ }, step7 );
+ }
+ function step7() {
+ focusWrap(function() {
+ shouldChange( false, "button down, before blur" );
+ element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
+ shouldChange( true, "blur after button down" );
+ }, step8 );
+ }
+
+ function step8() {
+ focusWrap(function() {
shouldChange( false, "many buttons, same final value, before blur" );
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
shouldChange( false, "blur after many buttons, same final value" );
- element.blur();
- setTimeout(function() {
- shouldChange( true, "stepUp" );
- element.spinner( "stepUp" );
+ }, step9 );
+ }
- shouldChange( true, "stepDown" );
- element.spinner( "stepDown" );
+ function step9() {
+ shouldChange( true, "stepUp" );
+ element.spinner( "stepUp" );
- shouldChange( true, "pageUp" );
- element.spinner( "pageUp" );
+ shouldChange( true, "stepDown" );
+ element.spinner( "stepDown" );
- shouldChange( true, "pageDown" );
- element.spinner( "pageDown" );
+ shouldChange( true, "pageUp" );
+ element.spinner( "pageUp" );
- shouldChange( true, "value" );
- element.spinner( "value", 999 );
+ shouldChange( true, "pageDown" );
+ element.spinner( "pageDown" );
- shouldChange( false, "value, same value" );
- element.spinner( "value", 999 );
+ shouldChange( true, "value" );
+ element.spinner( "value", 999 );
- shouldChange( true, "max, value changed" );
- element.spinner( "option", "max", 900 );
+ shouldChange( false, "value, same value" );
+ element.spinner( "value", 999 );
- shouldChange( false, "max, value not changed" );
- element.spinner( "option", "max", 1000 );
+ shouldChange( true, "max, value changed" );
+ element.spinner( "option", "max", 900 );
- shouldChange( true, "min, value changed" );
- element.spinner( "option", "min", 950 );
+ shouldChange( false, "max, value not changed" );
+ element.spinner( "option", "max", 1000 );
- shouldChange( false, "min, value not changed" );
- element.spinner( "option", "min", 200 );
- shouldChange( true, "cleanup" );
- start();
- });
- });
- });
+ shouldChange( true, "min, value changed" );
+ element.spinner( "option", "min", 950 );
+
+ shouldChange( false, "min, value not changed" );
+ element.spinner( "option", "min", 200 );
+ start();
+ }
+
+ step1();
});
})( jQuery );