Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add simple test illustrating hashchange event breakage #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions test/test_hashchange.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
QUnit.asyncTest('update window.location.hash', function(assert) {
var onhashchange = null,
wait_time = 14; // a reasonable wait time

expect(1);

// first reset hash in case we are re-running test
// this can be removed without affecting test results
// as long as you load the page fresh
window.location.hash = '';

setTimeout(function() {
window.addEventListener('hashchange', function(e) {
onhashchange = e;
}, false);

window.location.hash = "#/path";

// allow onhashchange to fire
setTimeout(function() {
assert.ok(onhashchange != null, "hashchange event was not fired!");
QUnit.start();
}, wait_time);
}, wait_time);
});
15 changes: 15 additions & 0 deletions test/test_hashchange_html5.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>QUnit Example</title>
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.14.0.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="http://code.jquery.com/qunit/qunit-1.14.0.js"></script>
<script src="../history.js"></script>
<script src="test_hashchange.js"></script>
</body>
</html>
14 changes: 14 additions & 0 deletions test/test_hashchange_nohtml5.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>QUnit Example</title>
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.14.0.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="http://code.jquery.com/qunit/qunit-1.14.0.js"></script>
<script src="test_hashchange.js"></script>
</body>
</html>