Permalink
Browse files

Tests: Integration: Popup: Add test to make sure popup elements do no…

…t have focus after the popup is closed. Tests #5974.
  • Loading branch information...
gabrielschulhof committed May 7, 2013
1 parent 7d59d30 commit 273624b864b52707aeb3136a26b53afdcfe45db1
Showing with 46 additions and 0 deletions.
  1. +7 −0 tests/integration/popup/index.html
  2. +39 −0 tests/integration/popup/popup_core.js
@@ -75,6 +75,13 @@
<p>This is the test popup</p>
</div>
<a id="go-to-another-page" href="back-two.html">Go</a>
<div data-nstest-role="popup" id="popupLogin">
<form>
<input type="text" name="user" id="textBox" value="" placeholder="username" />
</form>
</div>
</div>
</div>
@@ -495,4 +495,43 @@
}
]);
});
asyncTest( "Elements inside the popup lose focus when the popup is closed", function() {
expect( 5 );
var $popup = $( "#popupLogin" ),
$popupContainer = $( "#popupLogin-popup" ),
$textBox = $( "#textBox" ),
eventSuffix = ".ElementsInsideThePopupLoseFocus";
$.testHelper.detailedEventCascade( [
function() {
$popup.popup( "open" );
},
{
popupafteropen: { src: $popup, event: "popupafteropen" + eventSuffix + "1" }
},
function( result ) {
deepEqual( result.popupafteropen.timedOut, false, "Popup did open" );
$textBox.focus();
},
{
focusevent: { src: $textBox, event: "focus" + eventSuffix + "2" }
},
function( result ) {
deepEqual( result.focusevent.timedOut, false, "Text box did experience focus event" );
$popup.popup( "close" );
},
{
popupafterclose: { src: $popup, event: "popupafterclose" + eventSuffix + "3" }
},
function( result ) {
deepEqual( result.popupafterclose.timedOut, false, "Popup did close" );
deepEqual( $popupContainer.is( ":focus" ), false, "The popup container is not focused" );
deepEqual( $popupContainer.find( ":focus" ).length, 0, "The popup container contains no focused elements" );
start();
}
]);
});
})( jQuery );

0 comments on commit 273624b

Please sign in to comment.