Permalink
Browse files

fix for pagechange value and test of 3 page change events

  • Loading branch information...
1 parent 9b6cd5b commit d7dc1f3547de20a3bbc24ac6e5bb8675fe47479d @johnbender johnbender committed Oct 1, 2012
Showing with 31 additions and 2 deletions.
  1. +2 −2 js/jquery.mobile.navigation.js
  2. +29 −0 tests/unit/navigation/navigation_core.js
@@ -1030,8 +1030,8 @@ define( [
options.duplicateCachedPage = dupCachedPage;
// store the original absolute url so that it can be provided
- // to events in the triggerData
- newPage.data( 'absUrl', triggerData.url );
+ // to events in the triggerData of the subsequent changePage call
+ newPage.data( 'absUrl', triggerData.absUrl );
$.mobile.changePage( newPage, options );
})
.fail(function( url, options ) {
@@ -1312,4 +1312,33 @@
}
]);
});
+
+
+ var absHomeUrl = $.mobile.path.parseLocation().hrefNoHash,
+ homeDomain = $.mobile.path.parseLocation().domain;
+
+ asyncTest( "page load events are providided with the absolute url for the content", function() {
+ var requestPath;
+
+ expect( 3 );
+
+ $( document ).one( "pagebeforechange", function( event, data ) {
+ equal( data.absUrl, absHomeUrl + "#bar");
+ });
+
+ $( document ).one( "pagechange", function( event, data ) {
+ equal( data.absUrl, absHomeUrl + "#bar" );
+ });
+
+ $.mobile.changePage( "#bar" );
+
+ requestPath = "/theres/no/way/this/page/exists.html";
+
+ $( document ).one( "pagechangefailed", function( event, data ) {
+ equal( data.absUrl, homeDomain + requestPath );
+ start();
+ });
+
+ $.mobile.changePage( requestPath );
+ });
})(jQuery);

0 comments on commit d7dc1f3

Please sign in to comment.