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

Commit 22b486b

Browse files
author
Gabriel Schulhof
committed
[popup unit tests] Test for non-dismissable behaviour
1 parent 352fb0b commit 22b486b

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

tests/unit/popup/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
<div data-nstest-role="popup" id="test-destroy-popup" data-nstest-history="false">
5959
<p>This is the test popup</p>
6060
</div>
61+
62+
<div data-nstest-role="popup" id="test-popup-dismissable" data-nstest-dismissable="false">
63+
<p>This is the test popup</p>
64+
</div>
6165
</div>
6266
</div>
6367

tests/unit/popup/popup_core.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,4 +399,42 @@
399399
})
400400
.popup( "open" );
401401
});
402+
403+
asyncTest( "Cannot close a non-dismissable popup by clicking on the screen", function() {
404+
var $popup = $( "#test-popup-dismissable" ), eventNs = ".cannotCloseNonDismissablePopup";
405+
406+
$.testHelper.detailedEventCascade([
407+
function() {
408+
$popup.popup( "open" );
409+
},
410+
{
411+
navigate: { src: $( window ), event: "navigate" + eventNs + "0" },
412+
popupafteropen: { src: $popup, event: "popupafteropen" + eventNs + "0" }
413+
},
414+
function( results ) {
415+
ok( !results.navigate.timedOut, "A 'navigate' event has occurred" );
416+
ok( !results.popupafteropen.timedOut, "The popup has emitted a 'popupafteropen' event" );
417+
// Click on popup screen
418+
$popup.parent().prev().click();
419+
},
420+
{
421+
navigate: { src: $( window ), event: "navigate" + eventNs + "1" },
422+
popupafterclose: { src: $popup, event: "popupafterclose" + eventNs + "1" }
423+
},
424+
function( results ) {
425+
ok( results.navigate.timedOut, "A 'navigate' event has not occurred" );
426+
ok( results.popupafterclose.timedOut, "The popup has not emitted a 'popupafterclose' event" );
427+
$.mobile.back();
428+
},
429+
{
430+
navigate: { src: $( window ), event: "navigate" + eventNs + "2" },
431+
popupafterclose: { src: $popup, event: "popupafterclose" + eventNs + "2" }
432+
},
433+
function( results ) {
434+
ok( !results.navigate.timedOut, "A 'navigate' event has occurred" );
435+
ok( !results.popupafterclose.timedOut, "The popup has emitted a 'popupafterclose' event" );
436+
start();
437+
}
438+
]);
439+
});
402440
})( jQuery );

0 commit comments

Comments
 (0)