tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

PopStateEvent.html (1689B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>Synthetic popstate events</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <div id="log"></div>
      7 <script>
      8 test(function() {
      9  assert_throws_js(
     10    TypeError,
     11    () => PopStateEvent(''),
     12    "Calling PopStateEvent constructor without 'new' must throw"
     13  );
     14 }, "PopStateEvent constructor called as normal function");
     15 
     16 test(function () {
     17  assert_false('initPopStateEvent' in PopStateEvent.prototype,
     18               'There should be no PopStateEvent#initPopStateEvent');
     19 }, 'initPopStateEvent');
     20 
     21 test(function () {
     22  var popStateEvent = new PopStateEvent("popstate");
     23  assert_equals(popStateEvent.state, null, "the PopStateEvent.state");
     24 }, "Initial value of PopStateEvent.state must be null");
     25 
     26 test(function () {
     27  var popStateEvent = new PopStateEvent("popstate");
     28  assert_false(popStateEvent.hasUAVisualTransition, "the PopStateEvent.hasUAVisualTransition");
     29 }, "Initial value of PopStateEvent.hasUAVisualTransition must be false");
     30 
     31 test(function () {
     32  var state = history.state;
     33  var data;
     34  var hasUAVisualTransition = false;
     35  window.addEventListener('popstate', function (e) {
     36    data = e.state;
     37    hasUAVisualTransition = e.hasUAVisualTransition;
     38  });
     39  window.dispatchEvent(new PopStateEvent('popstate', {
     40    'state': {testdata:true},
     41    'hasUAVisualTransition': true
     42  }));
     43  assert_true(data.testdata,'state data was corrupted');
     44  assert_equals(history.state, state, "history.state was NOT set by dispatching the event");
     45  assert_true(hasUAVisualTransition, 'hasUAVisualTransition not set correctly');
     46 }, 'Dispatching a synthetic PopStateEvent');
     47 </script>