@@ -1015,6 +1015,7 @@ if ($.support.pjax) {
10151015 asyncTest ( "handles going back to pjaxed state after reloading a fragment navigation" , function ( ) {
10161016 var iframe = this . iframe
10171017 var frame = this . frame
1018+ var supportsHistoryState = 'state' in window . history
10181019
10191020 // Get some pjax state in the history.
10201021 frame . $ . pjax ( {
@@ -1023,28 +1024,33 @@ if ($.support.pjax) {
10231024 } )
10241025 frame . $ ( "#main" ) . on ( "pjax:complete" , function ( ) {
10251026 var state = frame . history . state
1026- ok ( frame . history . state )
10271027 ok ( frame . $ . pjax . state )
1028+ if ( supportsHistoryState )
1029+ ok ( frame . history . state )
10281030
10291031 // Navigate to a fragment, which will result in a new history entry with
10301032 // no state object. $.pjax.state remains unchanged however.
10311033 iframe . src = frame . location . href + '#foo'
1032- ok ( ! frame . history . state )
10331034 ok ( frame . $ . pjax . state )
1035+ if ( supportsHistoryState )
1036+ ok ( ! frame . history . state )
10341037
10351038 // Reload the frame. This will clear out $.pjax.state.
10361039 frame . location . reload ( )
10371040 $ ( iframe ) . one ( "load" , function ( ) {
1038- ok ( ! frame . history . state )
10391041 ok ( ! frame . $ . pjax . state )
1042+ if ( supportsHistoryState )
1043+ ok ( ! frame . history . state )
10401044
10411045 // Go back to #main. We'll get a popstate event with a pjax state
10421046 // object attached from the initial pjax navigation, even though
10431047 // $.pjax.state is null.
10441048 window . iframeLoad = function ( ) {
1045- ok ( frame . history . state )
10461049 ok ( frame . $ . pjax . state )
1047- equal ( frame . $ . pjax . state . id , state . id )
1050+ if ( supportsHistoryState ) {
1051+ ok ( frame . history . state )
1052+ equal ( frame . $ . pjax . state . id , state . id )
1053+ }
10481054 start ( )
10491055 }
10501056 frame . history . back ( )
0 commit comments