From fbc7956b9fbbc14f7854588341177075282d56b5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 10 Dec 2012 10:35:01 -0500 Subject: [PATCH] Button tests: Handle async focus in IE. --- tests/unit/button/button_core.js | 7 +++++-- tests/unit/button/button_events.js | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js index 460201f15..6d0bbbe88 100644 --- a/tests/unit/button/button_core.js +++ b/tests/unit/button/button_core.js @@ -153,13 +153,16 @@ test( "#6262 - buttonset not applying ui-corner to invisible elements", function ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) ); }); -test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() { +asyncTest( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() { expect( 2 ); var check = $( "#check" ).button(), label = $( "label[for='check']" ); ok( !label.is( ".ui-state-focus" ) ); check.focus(); - ok( label.is( ".ui-state-focus" ) ); + setTimeout(function() { + ok( label.is( ".ui-state-focus" ) ); + start(); + }); }); test( "#7534 - Button label selector works for ids with \":\"", function() { diff --git a/tests/unit/button/button_events.js b/tests/unit/button/button_events.js index 7b79c41ea..2fd038325 100644 --- a/tests/unit/button/button_events.js +++ b/tests/unit/button/button_events.js @@ -13,14 +13,24 @@ test("buttonset works with single-quote named elements (#7505)", function() { }).click(); }); -test( "when button loses focus, ensure active state is removed (#8559)", function() { +asyncTest( "when button loses focus, ensure active state is removed (#8559)", function() { expect( 1 ); - $("#button").button().keypress( function() { - $("#button").one( "blur", function() { - ok( !$("#button").is(".ui-state-active"), "button loses active state appropriately" ); + var element = $( "#button" ).button(); + + element.one( "keypress", function() { + element.one( "blur", function() { + ok( !element.is(".ui-state-active"), "button loses active state appropriately" ); + start(); }).blur(); - }).focus().simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ).simulate( "keypress", { keyCode: $.ui.keyCode.ENTER } ); + }); + + element.focus(); + setTimeout(function() { + element + .simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ) + .simulate( "keypress", { keyCode: $.ui.keyCode.ENTER } ); + }); }); })(jQuery); -- 2.39.5