@@ -912,6 +912,55 @@ if ($.support.pjax) {
912912
913913 } )
914914
915+ asyncTest ( "clicking back while loading maintains history" , function ( ) {
916+ var frame = this . frame
917+
918+ equal ( frame . location . pathname , "/home.html" )
919+ equal ( frame . document . title , "Home" )
920+
921+ frame . $ ( "#main" ) . on ( 'pjax:timeout' , function ( e ) {
922+ e . preventDefault ( ) ;
923+ } )
924+
925+ frame . $ ( "#main" ) . one ( 'pjax:complete' , function ( ) {
926+
927+ equal ( frame . location . pathname , "/hello.html" )
928+ equal ( frame . document . title , "Hello" )
929+
930+ frame . $ ( "#main" ) . one ( 'pjax:send' , function ( ) {
931+
932+ // don't use goBack here, because pjax:end isn't triggered
933+ // when clicking back while loading
934+
935+ frame . history . back ( ) ;
936+
937+ setTimeout ( function ( ) {
938+ equal ( frame . location . pathname , "/home.html" )
939+ equal ( frame . document . title , "Home" )
940+
941+ frame . history . forward ( )
942+
943+ setTimeout ( function ( ) {
944+ equal ( frame . location . pathname , "/hello.html" )
945+ equal ( frame . document . title , "Hello" )
946+ start ( )
947+ } , 250 )
948+
949+ } , 1500 )
950+ } )
951+
952+ frame . $ . pjax ( {
953+ url : "timeout.html" ,
954+ container : "#main"
955+ } )
956+ } )
957+
958+ frame . $ . pjax ( {
959+ url : "hello.html" ,
960+ container : "#main"
961+ } )
962+ } )
963+
915964 asyncTest ( "popstate going back to page" , function ( ) {
916965 var frame = this . frame
917966
0 commit comments