@@ -861,41 +861,55 @@ if ($.support.pjax) {
861
861
asyncTest ( "clicking back while loading cancels XHR" , function ( ) {
862
862
var frame = this . frame
863
863
864
- frame . $ ( '#main' ) . on ( 'pjax:timeout' , function ( event ) {
865
- event . preventDefault ( )
864
+ equal ( frame . location . pathname , "/home.html" )
865
+ equal ( frame . document . title , "Home" )
866
+
867
+ frame . $ ( "#main" ) . on ( 'pjax:timeout' , function ( e ) {
868
+ e . preventDefault ( ) ;
866
869
} )
867
870
868
- frame . $ ( "#main" ) . one ( 'pjax:send ' , function ( ) {
871
+ frame . $ ( "#main" ) . one ( 'pjax:complete ' , function ( ) {
869
872
870
- // Check that our request is aborted (need to check
871
- // how robust this is across browsers)
872
- frame . $ ( "#main" ) . one ( 'pjax:complete' , function ( e , xhr , textStatus ) {
873
- equal ( xhr . status , 0 )
874
- equal ( textStatus , 'abort' )
875
- } )
873
+ equal ( frame . location . pathname , "/hello.html" )
874
+ equal ( frame . document . title , "Hello" )
876
875
877
- setTimeout ( function ( ) {
878
- frame . history . back ( )
879
- } , 250 )
876
+ frame . $ ( "#main" ) . one ( 'pjax:send' , function ( ) {
880
877
881
- // Make sure the URL and content remain the same after the
882
- // XHR would have arrived (delay on timeout.html is 1s)
883
- setTimeout ( function ( ) {
884
- var afterBackLocation = frame . location . pathname
885
- var afterBackTitle = frame . document . title
878
+ // don't use goBack here, because pjax:end isn't triggered
879
+ // when clicking back while loading
880
+
881
+ frame . $ ( "#main" ) . one ( 'pjax:complete' , function ( e , xhr , textStatus ) {
882
+ equal ( xhr . status , 0 ) ;
883
+ equal ( textStatus , 'abort' )
884
+ } )
885
+
886
+ frame . history . back ( ) ;
886
887
888
+ // Make sure the URL and content remain the same after the
889
+ // XHR would have arrived (delay on timeout.html is 1s)
887
890
setTimeout ( function ( ) {
888
- equal ( frame . location . pathname , afterBackLocation )
889
- equal ( frame . document . title , afterBackTitle )
890
- start ( )
891
- } , 1000 )
892
- } , 500 )
891
+ var afterBackLocation = frame . location . pathname
892
+ var afterBackTitle = frame . document . title
893
+
894
+ setTimeout ( function ( ) {
895
+ equal ( frame . location . pathname , afterBackLocation )
896
+ equal ( frame . document . title , afterBackTitle )
897
+ start ( )
898
+ } , 1000 )
899
+ } , 500 )
900
+ } )
901
+
902
+ frame . $ . pjax ( {
903
+ url : "timeout.html" ,
904
+ container : "#main"
905
+ } )
893
906
} )
894
907
895
908
frame . $ . pjax ( {
896
- url : "timeout .html" ,
909
+ url : "hello .html" ,
897
910
container : "#main"
898
911
} )
912
+
899
913
} )
900
914
901
915
asyncTest ( "popstate going back to page" , function ( ) {
0 commit comments