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

Commit e3093f3

Browse files
author
Gabriel Schulhof
committed
Tests: Integration: Popup: Add test to make sure popup elements do not have focus after the popup is closed. Tests #5974. (applied by hand from 273624b)
1 parent 1330309 commit e3093f3

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

tests/unit/popup/index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@
7878
<p>This is the test popup</p>
7979
</div>
8080
<a id="go-to-another-page" href="back-two.html">Go</a>
81+
82+
<div data-nstest-role="popup" id="popupLogin">
83+
<form>
84+
<input type="text" name="user" id="textBox" value="" placeholder="username" />
85+
</form>
86+
</div>
87+
8188
</div>
8289
</div>
8390

tests/unit/popup/popup_core.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,4 +553,43 @@
553553
}
554554
]);
555555
});
556+
557+
asyncTest( "Elements inside the popup lose focus when the popup is closed", function() {
558+
559+
expect( 5 );
560+
561+
var $popup = $( "#popupLogin" ),
562+
$popupContainer = $( "#popupLogin-popup" ),
563+
$textBox = $( "#textBox" ),
564+
eventSuffix = ".ElementsInsideThePopupLoseFocus";
565+
566+
$.testHelper.detailedEventCascade( [
567+
function() {
568+
$popup.popup( "open" );
569+
},
570+
{
571+
popupafteropen: { src: $popup, event: "popupafteropen" + eventSuffix + "1" }
572+
},
573+
function( result ) {
574+
deepEqual( result.popupafteropen.timedOut, false, "Popup did open" );
575+
$textBox.focus();
576+
},
577+
{
578+
focusevent: { src: $textBox, event: "focus" + eventSuffix + "2" }
579+
},
580+
function( result ) {
581+
deepEqual( result.focusevent.timedOut, false, "Text box did experience focus event" );
582+
$popup.popup( "close" );
583+
},
584+
{
585+
popupafterclose: { src: $popup, event: "popupafterclose" + eventSuffix + "3" }
586+
},
587+
function( result ) {
588+
deepEqual( result.popupafterclose.timedOut, false, "Popup did close" );
589+
deepEqual( $popupContainer.is( ":focus" ), false, "The popup container is not focused" );
590+
deepEqual( $popupContainer.find( ":focus" ).length, 0, "The popup container contains no focused elements" );
591+
start();
592+
}
593+
]);
594+
});
556595
})( jQuery );

0 commit comments

Comments
 (0)