Skip to content

Commit c7915b7

Browse files
committed
Test history when clicking back during load
1 parent 63c99e6 commit c7915b7

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test/unit/pjax.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,55 @@ if ($.support.pjax) {
912912

913913
})
914914

915+
asyncTest("clicking back while loading maintains history", function() {
916+
var frame = this.frame
917+
918+
equal(frame.location.pathname, "/home.html")
919+
equal(frame.document.title, "Home")
920+
921+
frame.$("#main").on('pjax:timeout', function(e) {
922+
e.preventDefault();
923+
})
924+
925+
frame.$("#main").one('pjax:complete', function() {
926+
927+
equal(frame.location.pathname, "/hello.html")
928+
equal(frame.document.title, "Hello")
929+
930+
frame.$("#main").one('pjax:send', function() {
931+
932+
// don't use goBack here, because pjax:end isn't triggered
933+
// when clicking back while loading
934+
935+
frame.history.back();
936+
937+
setTimeout(function() {
938+
equal(frame.location.pathname, "/home.html")
939+
equal(frame.document.title, "Home")
940+
941+
frame.history.forward()
942+
943+
setTimeout(function() {
944+
equal(frame.location.pathname, "/hello.html")
945+
equal(frame.document.title, "Hello")
946+
start()
947+
}, 250)
948+
949+
}, 1500)
950+
})
951+
952+
frame.$.pjax({
953+
url: "timeout.html",
954+
container: "#main"
955+
})
956+
})
957+
958+
frame.$.pjax({
959+
url: "hello.html",
960+
container: "#main"
961+
})
962+
})
963+
915964
asyncTest("popstate going back to page", function() {
916965
var frame = this.frame
917966

0 commit comments

Comments
 (0)