<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<script>

description("This tests the constructor for the PopStateEvent DOM class.");

// No initializer is passed.
shouldBe("new PopStateEvent('eventType').bubbles", "false");
shouldBe("new PopStateEvent('eventType').cancelable", "false");
shouldBe("new PopStateEvent('eventType').state", "null");

// bubbles is passed.
shouldBe("new PopStateEvent('eventType', { bubbles: false }).bubbles", "false");
shouldBe("new PopStateEvent('eventType', { bubbles: true }).bubbles", "true");

// cancelable is passed.
shouldBe("new PopStateEvent('eventType', { cancelable: false }).cancelable", "false");
shouldBe("new PopStateEvent('eventType', { cancelable: true }).cancelable", "true");

// state is passed.
var object1 = {nyannyan: 123};
shouldBe("new PopStateEvent('eventType', { state: object1 }).state", "object1");
shouldBe("new PopStateEvent('eventType', { state: document }).state", "document");
shouldBe("new PopStateEvent('eventType', { state: undefined }).state", "null");
shouldBe("new PopStateEvent('eventType', { state: null }).state", "null");
shouldBe("new PopStateEvent('eventType', { state: false }).state", "false");
shouldBe("new PopStateEvent('eventType', { state: true }).state", "true");
shouldBeEqualToString("new PopStateEvent('eventType', { state: '' }).state", "");
shouldBeEqualToString("new PopStateEvent('eventType', { state: 'doremi' }).state", "doremi");
shouldBe("new PopStateEvent('eventType', { state: 12345 }).state", "12345");
shouldBe("new PopStateEvent('eventType', { state: 18446744073709551615 }).state", "18446744073709552000");
shouldBe("new PopStateEvent('eventType', { state: NaN }).state", "NaN");
var object2 = {nyannyan: 456};
// Note that valueOf() is not called when the left hand side is evaluated.
shouldBeFalse("new PopStateEvent('eventType', { state: {valueOf: function () { return object2; } } }).state == object2");
shouldBe("new PopStateEvent('eventType', { get state() { return 123; } }).state", "123");
shouldThrow("new PopStateEvent('eventType', { get state() { throw 'PopState Error'; } })");

// All initializers are passed.
var object3 = {nyannyan: 789};
shouldBe("new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).bubbles", "true");
shouldBe("new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).cancelable", "true");
shouldBe("new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).state", "object3");
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>
