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

Commit

Permalink
Pagecontainer: Hide loader and release transition lock at page load fail
Browse files Browse the repository at this point in the history
Fixes gh-3143
Closes gh-7915
  • Loading branch information
Gabriel Schulhof committed Apr 3, 2015
1 parent 1d6b533 commit 866fa98
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
4 changes: 4 additions & 0 deletions js/widgets/pagecontainer.js
Expand Up @@ -725,6 +725,10 @@ define( [
triggerData.textStatus = textStatus;
triggerData.errorThrown = errorThrown;

// Clean up internal pending operations like the loader and the transition lock
this._hideLoading();
this._releaseTransitionLock();

// Let listeners know the page load failed.
var plfEvent = this._triggerWithDeprecated( "loadfailed", triggerData );

Expand Down
40 changes: 40 additions & 0 deletions tests/integration/pagecontainer/page-load-failure-tests.html
@@ -0,0 +1,40 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery Mobile Pagecontainer Event Sequence Test Suite</title>

<script src="../../../external/requirejs/require.js"></script>
<script src="../../../js/requirejs.config.js"></script>
<script src="../../../js/jquery.tag.inserter.js"></script>
<script src="../../jquery.setNameSpace.js"></script>
<script src="../../../tests/jquery.testHelper.js"></script>

<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/>
<link rel="stylesheet" href="../../../external/qunit/qunit.css"/>
<link rel="stylesheet" href="../../jqm-tests.css"/>
<script src="../../../external/qunit/qunit.js"></script>
<script>
$.testHelper.asyncLoad([
[ "init" ],
[
"page_load_failure_core.js"
]
]);
</script>

<script src="../../swarminject.js"></script>
</head>
<body id="the-body">
<div id="qunit"></div>

<div data-nstest-role="page" id="start-page">
<div data-role="header"><h1>Start page</h1></div>
<div class="ui-content">
<a href="page-does-not-exist.html" id="go-to-nonexistent-page">Go to non-existent page</a>
<a href="other-page.html" id="go-to-other-page">Go to other page</a>
</div>
</div>
</body>
</html>
34 changes: 34 additions & 0 deletions tests/integration/pagecontainer/page_load_failure_core.js
@@ -0,0 +1,34 @@
module( "Pagecontainer" );

asyncTest( "hides loader and clears transition lock when page load fails", function() {
expect( 3 );

$( document ).on( "pagecontainerloadfailed", function( event ) {

// Prevent error message shown by default
event.preventDefault();
setTimeout( function() {
deepEqual( $.mobile.loading().is( ":visible" ), false, "Loader is hidden" );

$.testHelper.pageSequence([
function() {
$( "#go-to-other-page" ).click();
},
function() {
deepEqual( $.mobile.pageContainer.pagecontainer( "getActivePage" )
.attr( "id" ), "other-page",
"The other page is the active page" );
$.mobile.back();
},
function() {
deepEqual( $.mobile.pageContainer.pagecontainer( "getActivePage" )
.attr( "id" ), "start-page",
"Returned to start page" );
start();
}
]);
}, 500 );
});

$( "#go-to-nonexistent-page" ).click();
});

0 comments on commit 866fa98

Please sign in to comment.