@@ -125,12 +125,31 @@ if ($.support.pjax) {
125
125
var frame = this . frame
126
126
127
127
frame . evaledScriptLoaded = function ( ) {
128
- equal ( 2 , frame . evaledSrcScriptNum )
129
- equal ( true , frame . evaledInlineScript )
130
- start ( )
128
+ equal ( frame . evaledSrcScriptNum , 2 )
129
+ deepEqual ( frame . evaledInlineLog , [ "one" ] )
130
+
131
+ frame . $ . pjax ( {
132
+ url : "scripts.html?name=two" ,
133
+ container : "#main"
134
+ } )
135
+
136
+ frame . $ ( "#main" ) . one ( "pjax:end" , function ( ) {
137
+ deepEqual ( frame . evaledInlineLog , [ "one" , "two" ] )
138
+
139
+ goBack ( frame , function ( ) {
140
+ deepEqual ( frame . evaledInlineLog , [ "one" , "two" , "one" ] )
141
+
142
+ goForward ( frame , function ( ) {
143
+ deepEqual ( frame . evaledInlineLog , [ "one" , "two" , "one" , "two" ] )
144
+ equal ( frame . evaledSrcScriptNum , 2 )
145
+ start ( )
146
+ } )
147
+ } )
148
+ } )
131
149
}
150
+
132
151
frame . $ . pjax ( {
133
- url : "scripts.html" ,
152
+ url : "scripts.html?name=one " ,
134
153
container : "#main"
135
154
} )
136
155
} )
@@ -927,7 +946,6 @@ if ($.support.pjax) {
927
946
} )
928
947
} )
929
948
930
- // Test is fragile
931
949
asyncTest ( "no initial pjax:popstate event" , function ( ) {
932
950
var frame = this . frame
933
951
var count = 0
@@ -944,19 +962,16 @@ if ($.support.pjax) {
944
962
} else if ( count == 3 ) {
945
963
equal ( frame . location . pathname , "/env.html" )
946
964
frame . history . back ( )
947
- setTimeout ( function ( ) { window . iframeLoad ( frame ) } , 1000 )
948
965
} else if ( count == 4 ) {
949
966
equal ( frame . location . pathname , "/hello.html" )
950
967
frame . history . back ( )
951
- setTimeout ( function ( ) { window . iframeLoad ( frame ) } , 1000 )
952
968
} else if ( count == 5 ) {
953
969
equal ( frame . location . pathname , "/home.html" )
954
970
frame . history . forward ( )
955
- setTimeout ( function ( ) { window . iframeLoad ( frame ) } , 1000 )
956
971
} else if ( count == 6 ) {
957
- // Should skip pjax:popstate since there's no initial pjax.state
958
972
frame . $ ( '#main' ) . on ( 'pjax:popstate' , function ( event ) {
959
973
if ( count == 6 ) {
974
+ // Should skip pjax:popstate since there's no initial pjax.state
960
975
ok ( event . state . url . match ( "/hello.html" ) , event . state . url )
961
976
ok ( false )
962
977
} else if ( count == 7 ) {
@@ -969,11 +984,13 @@ if ($.support.pjax) {
969
984
if ( count == 6 ) {
970
985
count ++
971
986
frame . history . forward ( )
972
- setTimeout ( function ( ) { window . iframeLoad ( frame ) } , 1000 )
973
- } else {
974
- setTimeout ( function ( ) { start ( ) } , 1000 )
975
987
}
976
988
} )
989
+
990
+ // Browsers that don't fire initial "popstate" should just resume
991
+ setTimeout ( function ( ) {
992
+ start ( )
993
+ } , 100 )
977
994
}
978
995
}
979
996
0 commit comments