Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding hashchange test.

  • Loading branch information...
commit 923954ff00b22536979ed30e488f31c505dcf39d 1 parent f906014
@mattwkelly mattwkelly authored
View
4 tests/hashchange/config.yml
@@ -0,0 +1,4 @@
+---
+ r: 1
+ spec: "http://www.w3.org/TR/html5/history.html"
+ title: "Hashchange"
View
1  tests/hashchange/fixture.html
@@ -0,0 +1 @@
+<iframe id="hashchange" src="/tests/hashchange/iframe.html"></iframe>
View
3  tests/hashchange/iframe.html
@@ -0,0 +1,3 @@
+<script>
+location.hash = (new Date()).getTime();
+</script>
View
50 tests/hashchange/test.js
@@ -0,0 +1,50 @@
+test("HashChangeEvent", function() {
+ var HashChangeEvent = window.HashChangeEvent;
+
+ assert( !!HashChangeEvent, "HashChangeEvent supported" );
+});
+
+test("onhashchange", function() {
+ assert( "onhashchange" in window, "onhashchange exists in some form" );
+ assert( window.onhashchange == null, "onhashchange is TreatNonCallableAsNull" );
+});
+
+// test("HashChangeEvent in Practice", function( async ) {
+// var HashChangeEvent = window.HashChangeEvent,
+// event;
+//
+// if ( !HashChangeEvent ) {
+// assert( false, "HashChangeEvent is not implemented" );
+// } else {
+// event = typeof HashChangeEvent === "function" ?
+// document.createEvent("HashChangeEvent") : HashChangeEvent;
+//
+// assert( "oldURL" in event, "event.oldURL supported" );
+// assert( "newURL" in event, "event.newURL supported" );
+// }
+// });
+
+asyncTest("onhashchange In Practice", function( async ) {
+ var iframe = document.getElementById("hashchange").contentWindow,
+ dead = false;
+
+ iframe.onhashchange = function( event ) {
+ if ( !dead ) {
+ async.step(function() {
+ assert( true, "onhashchange event fired" );
+ dead = true;
+ async.done();
+ });
+ }
+ };
+
+ setTimeout(function() {
+ if ( !dead ) {
+ async.step(function() {
+ assert( false, "onhashchange event did not fire" );
+ dead = true;
+ async.done();
+ });
+ }
+ }, 1000);
+});
Please sign in to comment.
Something went wrong with that request. Please try again.