Skip to content

Instantly share code, notes, and snippets.

@hober
Created August 11, 2015 17:00
Show Gist options
  • Save hober/a29b6c28ac1744c800dd to your computer and use it in GitHub Desktop.
Save hober/a29b6c28ac1744c800dd to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Radar 22169467</title>
<script>
function log(text) {
var logEl = document.getElementById("log");
logEl.innerHTML = logEl.innerHTML + text + "<br>";
}
function assert(test, description) {
if (test) {
log("PASS: " + description);
} else {
log("FAIL: " + description);
}
}
function testthebug() {
var newhash = "x" + location.hash.substring(1);
location.hash = newhash;
var syncval = location.hash;
setTimeout(function() {
var asyncval = location.hash;
assert(asyncval.substring(1)==newhash,
"After setting location.hash and spinning the runloop,"
+ " getting location.hash should return the new value.");
assert(syncval==asyncval,
"You shouldn't have to setTimeout to get the new value.");
}, 10);
};
window.onload = function() {
document.getElementsByTagName("button")[0].onclick = testthebug;
}
</script>
</head>
<body>
<p><button>Test</button></p>
<div id=log></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment