blob: 9ee75762493b04360af01cd3966ecf3500d03041 [file] [log] [blame]
<!doctype html>
<meta charset=utf-8>
<title>Synthetic popstate events</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
assert_throws_js(
TypeError,
() => PopStateEvent(''),
"Calling PopStateEvent constructor without 'new' must throw"
);
}, "PopStateEvent constructor called as normal function");
test(function () {
assert_false('initPopStateEvent' in PopStateEvent.prototype,
'There should be no PopStateEvent#initPopStateEvent');
}, 'initPopStateEvent');
test(function () {
var popStateEvent = new PopStateEvent("popstate");
assert_equals(popStateEvent.state, null, "the PopStateEvent.state");
}, "Initial value of PopStateEvent.state must be null");
test(function () {
var popStateEvent = new PopStateEvent("popstate");
assert_false(popStateEvent.hasUAVisualTransition, "the PopStateEvent.hasUAVisualTransition");
}, "Initial value of PopStateEvent.hasUAVisualTransition must be false");
test(function () {
var state = history.state;
var data;
var hasUAVisualTransition = false;
window.addEventListener('popstate', function (e) {
data = e.state;
hasUAVisualTransition = e.hasUAVisualTransition;
});
window.dispatchEvent(new PopStateEvent('popstate', {
'state': {testdata:true},
'hasUAVisualTransition': true
}));
assert_true(data.testdata,'state data was corrupted');
assert_equals(history.state, state, "history.state was NOT set by dispatching the event");
assert_true(hasUAVisualTransition, 'hasUAVisualTransition not set correctly');
}, 'Dispatching a synthetic PopStateEvent');
</script>