Skip to content
Browse files

Merge pull request #32 from facebook/history

Adding history test.
NOTE: needs to do more
  • Loading branch information...
2 parents 5e8b47e + 3f76a9e commit 2ce5fb2396edfeeb2678b82b4bb7ce1ca46391ae @darobin darobin committed Jun 6, 2012
Showing with 55 additions and 0 deletions.
  1. +4 −0 tests/history/config.yml
  2. +51 −0 tests/history/test.js
View
4 tests/history/config.yml
@@ -0,0 +1,4 @@
+---
+ r: 1
+ spec: "http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html"
+ title: "History"
View
51 tests/history/test.js
@@ -0,0 +1,51 @@
+test("history", function() {
+ var history = window.history;
+ assert( !!history, "history supported" );
+});
+
+test("history.pushState", function() {
+ var history = window.history;
+ assert( !!history.pushState, "history.pushState supported" );
+ assert( typeof history.pushState === "function", "history.pushState is a function" );
+});
+
+test("history.replaceState", function() {
+ var history = window.history;
+ assert( typeof history.replaceState === "function", "history.replaceState is a function" );
+});
+
+test("history PopStateEvent", function() {
+ var PopStateEvent = window.PopStateEvent,
+ event;
+
+ if ( !PopStateEvent ) {
+ assert( false, "PopStateEvent not supported, skipping tests" );
+ } else {
+ event = document.createEvent("PopStateEvent");
+ assert( "state" in event, "event.state supported" );
+ }
+});
+
+// TODO: Move this to run in a pop-up window
+// asyncTest("history In Practice", function( async ) {
+// var history = window.history;
+//
+// window.onpopstate = function( event ) {
+//
+// async.step(function() {
+//
+// assert( !!event.state.a, "event.state is as we expected" );
+//
+// // Restore
+// history.replaceState({ spec: "history" }, "Spec", "" );
+//
+// async.done();
+// });
+// window.onpopstate = null;
+// };
+//
+// history.pushState({ a: "alpha" }, "Alpha", "?" + (new Date()).getTime() );
+// history.pushState({ b: "beta" }, "Beta" );
+// // This will push back to "alpha"
+// history.back();
+// });

0 comments on commit 2ce5fb2

Please sign in to comment.
Something went wrong with that request. Please try again.