blob: 484b2b6354deddc03f1c30a6fa033d2a250f8a5e [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head/>
<body>
<script>
description('This test calls pushState with state objects of all the different object types supported by the HTML5 "internal structured cloning algorithm" and makes sure the state attribute returns the expected objects.');
if (window.testRunner)
testRunner.clearBackForwardList();
shouldBeDefined("history.state");
debug("\nhistory.state should initially be null.");
shouldBeNull("history.state");
debug("");
history.pushState(undefined, "undefined entry");
shouldBeUndefined("history.state");
history.pushState(null, "null entry");
shouldBeNull("history.state");
history.pushState(false, "false entry");
shouldBeFalse("history.state");
history.pushState(true, "true entry");
shouldBeTrue("history.state");
history.pushState(42, "Number entry");
shouldBe("history.state", "42");
history.pushState("String", "String entry");
shouldBeEqualToString("history.state", "String");
history.pushState(new Date(0), "Date entry");
shouldBe("+history.state", "+(new Date(0))");
history.pushState(new RegExp("foo", "gi"), "RegExp entry");
shouldEvaluateTo("history.state", new RegExp("foo", "gi"));
history.pushState(new Array, "Array entry");
shouldEvaluateTo("history.state", new Array);
history.pushState(new Object, "Object entry");
shouldEvaluateTo("history.state", new Object);
history.pushState(document.createElement("canvas").getContext("2d").createImageData(10,10), "ImageData entry");
shouldEvaluateTo("history.state", document.createElement("canvas").getContext("2d").createImageData(10,10));
</script>
</body>
</html>