mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-16 22:10:25 +00:00
Added unit test for issue #2537 - Add new pageremove event.
The test makes use of a pageremove callback that conditionally calls preventDefault() on the event so that the test can make sure a developer can prevent a specific page from being removed from the DOM.
This commit is contained in:
parent
34fb7b2dc1
commit
880df5fcf5
1 changed files with 50 additions and 0 deletions
|
|
@ -96,6 +96,56 @@
|
|||
]);
|
||||
});
|
||||
|
||||
asyncTest( "preventDefault on pageremove event can prevent external page from being removed from the DOM", function(){
|
||||
var preventRemoval = true,
|
||||
removeCallback = function( e ) {
|
||||
if ( preventRemoval ) {
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
$( document ).bind( "pageremove", removeCallback );
|
||||
|
||||
$.testHelper.pageSequence([
|
||||
navigateTestRoot,
|
||||
|
||||
function(){
|
||||
$.mobile.changePage( "external.html" );
|
||||
},
|
||||
|
||||
// page is pulled and displayed in the dom
|
||||
function(){
|
||||
same( $( "#external-test" ).length, 1 );
|
||||
window.history.back();
|
||||
},
|
||||
|
||||
// external-test *IS* cached in the dom after transitioning away
|
||||
function(){
|
||||
same( $( "#external-test" ).length, 1 );
|
||||
|
||||
// Switch back to the page again!
|
||||
$.mobile.changePage( "external.html" );
|
||||
},
|
||||
|
||||
// page is still present and displayed in the dom
|
||||
function(){
|
||||
same( $( "#external-test" ).length, 1 );
|
||||
|
||||
// Now turn off our removal prevention.
|
||||
preventRemoval = false;
|
||||
|
||||
window.history.back();
|
||||
},
|
||||
|
||||
// external-test is *NOT* cached in the dom after transitioning away
|
||||
function(){
|
||||
same( $( "#external-test" ).length, 0 );
|
||||
$( document ).unbind( "pageremove", removeCallback );
|
||||
start();
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
asyncTest( "external page is cached in the DOM after pagehide", function(){
|
||||
$.testHelper.pageSequence([
|
||||
navigateTestRoot,
|
||||
|
|
|
|||
Loading…
Reference in a new issue