diff options
Diffstat (limited to 'testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/PopStateEvent.html')
-rw-r--r-- | testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/PopStateEvent.html | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/PopStateEvent.html b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/PopStateEvent.html new file mode 100644 index 0000000000..9ee7576249 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/PopStateEvent.html @@ -0,0 +1,47 @@ +<!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> |