@@ -752,42 +752,39 @@ if ($.support.pjax) {
752
752
asyncTest ( "clicking back while loading cancels XHR" , function ( ) {
753
753
var frame = this . frame
754
754
755
- frame . $ ( "#main" ) . one ( 'pjax:complete' , function ( ) {
756
-
757
- frame . $ ( "#main" ) . one ( 'pjax:send' , function ( ) {
758
-
759
- // Check that our request is aborted (need to check
760
- // how robust this is across browsers)
761
- frame . $ ( "#main" ) . one ( 'pjax:complete' , function ( e , xhr , textStatus ) {
762
- equal ( xhr . status , 0 )
763
- equal ( textStatus , 'abort' )
764
- } )
755
+ frame . $ ( '#main' ) . on ( 'pjax:timeout' , function ( event ) {
756
+ event . preventDefault ( )
757
+ } )
765
758
766
- // Make sure the URL and content remain the same after the
767
- // XHR would have arrived (delay on timeout.html is 1s)
768
- setTimeout ( function ( ) {
769
- var afterBackLocation = frame . location . pathname
770
- var afterBackTitle = frame . document . title
759
+ frame . $ ( "#main" ) . one ( 'pjax:send' , function ( ) {
771
760
772
- setTimeout ( function ( ) {
773
- equal ( frame . location . pathname , afterBackLocation )
774
- equal ( frame . document . title , afterBackTitle )
775
- start ( )
776
- } , 1000 )
777
- } , 500 )
761
+ // Check that our request is aborted (need to check
762
+ // how robust this is across browsers )
763
+ frame . $ ( "#main" ) . one ( 'pjax:complete' , function ( e , xhr , textStatus ) {
764
+ equal ( xhr . status , 0 )
765
+ equal ( textStatus , 'abort' )
766
+ } )
778
767
768
+ setTimeout ( function ( ) {
779
769
frame . history . back ( )
770
+ } , 250 )
780
771
781
- } )
772
+ // Make sure the URL and content remain the same after the
773
+ // XHR would have arrived (delay on timeout.html is 1s)
774
+ setTimeout ( function ( ) {
775
+ var afterBackLocation = frame . location . pathname
776
+ var afterBackTitle = frame . document . title
782
777
783
- frame . $ . pjax ( {
784
- url : "timeout.html" ,
785
- container : "#main"
786
- } )
778
+ setTimeout ( function ( ) {
779
+ equal ( frame . location . pathname , afterBackLocation )
780
+ equal ( frame . document . title , afterBackTitle )
781
+ start ( )
782
+ } , 1000 )
783
+ } , 500 )
787
784
} )
788
785
789
786
frame . $ . pjax ( {
790
- url : "hello .html" ,
787
+ url : "timeout .html" ,
791
788
container : "#main"
792
789
} )
793
790
} )
0 commit comments