Skip to content

Commit 00b886f

Browse files
committed
Test history when clicking back during load
1 parent e4a3b0f commit 00b886f

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
@@ -889,6 +889,55 @@ if ($.support.pjax) {
889889
})
890890
})
891891

892+
asyncTest("clicking back while loading maintains history", function() {
893+
var frame = this.frame
894+
895+
equal(frame.location.pathname, "/home.html")
896+
equal(frame.document.title, "Home")
897+
898+
frame.$("#main").on('pjax:timeout', function(e) {
899+
e.preventDefault();
900+
})
901+
902+
frame.$("#main").one('pjax:complete', function() {
903+
904+
equal(frame.location.pathname, "/hello.html")
905+
equal(frame.document.title, "Hello")
906+
907+
frame.$("#main").one('pjax:send', function() {
908+
909+
// don't use goBack here, because pjax:end isn't triggered
910+
// when clicking back while loading
911+
912+
frame.history.back();
913+
914+
setTimeout(function() {
915+
equal(frame.location.pathname, "/home.html")
916+
equal(frame.document.title, "Home")
917+
918+
frame.history.forward()
919+
920+
setTimeout(function() {
921+
equal(frame.location.pathname, "/hello.html")
922+
equal(frame.document.title, "Hello")
923+
start()
924+
}, 250)
925+
926+
}, 1500)
927+
})
928+
929+
frame.$.pjax({
930+
url: "timeout.html",
931+
container: "#main"
932+
})
933+
})
934+
935+
frame.$.pjax({
936+
url: "hello.html",
937+
container: "#main"
938+
})
939+
})
940+
892941
asyncTest("popstate going back to page", function() {
893942
var frame = this.frame
894943

0 commit comments

Comments
 (0)