@@ -125,12 +125,31 @@ if ($.support.pjax) {
125125 var frame = this . frame
126126
127127 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+ } )
131149 }
150+
132151 frame . $ . pjax ( {
133- url : "scripts.html" ,
152+ url : "scripts.html?name=one " ,
134153 container : "#main"
135154 } )
136155 } )
@@ -927,7 +946,6 @@ if ($.support.pjax) {
927946 } )
928947 } )
929948
930- // Test is fragile
931949 asyncTest ( "no initial pjax:popstate event" , function ( ) {
932950 var frame = this . frame
933951 var count = 0
@@ -944,19 +962,16 @@ if ($.support.pjax) {
944962 } else if ( count == 3 ) {
945963 equal ( frame . location . pathname , "/env.html" )
946964 frame . history . back ( )
947- setTimeout ( function ( ) { window . iframeLoad ( frame ) } , 1000 )
948965 } else if ( count == 4 ) {
949966 equal ( frame . location . pathname , "/hello.html" )
950967 frame . history . back ( )
951- setTimeout ( function ( ) { window . iframeLoad ( frame ) } , 1000 )
952968 } else if ( count == 5 ) {
953969 equal ( frame . location . pathname , "/home.html" )
954970 frame . history . forward ( )
955- setTimeout ( function ( ) { window . iframeLoad ( frame ) } , 1000 )
956971 } else if ( count == 6 ) {
957- // Should skip pjax:popstate since there's no initial pjax.state
958972 frame . $ ( '#main' ) . on ( 'pjax:popstate' , function ( event ) {
959973 if ( count == 6 ) {
974+ // Should skip pjax:popstate since there's no initial pjax.state
960975 ok ( event . state . url . match ( "/hello.html" ) , event . state . url )
961976 ok ( false )
962977 } else if ( count == 7 ) {
@@ -969,11 +984,13 @@ if ($.support.pjax) {
969984 if ( count == 6 ) {
970985 count ++
971986 frame . history . forward ( )
972- setTimeout ( function ( ) { window . iframeLoad ( frame ) } , 1000 )
973- } else {
974- setTimeout ( function ( ) { start ( ) } , 1000 )
975987 }
976988 } )
989+
990+ // Browsers that don't fire initial "popstate" should just resume
991+ setTimeout ( function ( ) {
992+ start ( )
993+ } , 100 )
977994 }
978995 }
979996
0 commit comments