Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Tests: Integration: Popup: Add test to make sure popup elements do no…
Browse files Browse the repository at this point in the history
…t have focus after the popup is closed. Tests #5974.
  • Loading branch information
Gabriel Schulhof committed May 7, 2013
1 parent 7d59d30 commit 273624b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/integration/popup/index.html
Expand Up @@ -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>

Expand Down
39 changes: 39 additions & 0 deletions tests/integration/popup/popup_core.js
Expand Up @@ -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.