Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<!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
You can’t perform that action at this time.