summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/event-order/before-load-pushState.html
blob: a08afa474f0ea496b184dc255e2d9e635edf29d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<meta charset="utf-8">
<title>Popstate/hashchange/load event ordering</title>

<script>
// Set these up super-early before we hit the network for the test harness, just in case.
window.eventOrder = [];
window.onhashchange = () => window.eventOrder.push("hashchange");
window.onpopstate = () => window.eventOrder.push("popstate");
window.onload = () => window.eventOrder.push("load");
</script>

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>
async_test(t => {
  assert_array_equals(window.eventOrder, []);

  window.addEventListener("load", t.step_func(() => {
    t.step_timeout(t.step_func_done(() => {
      assert_array_equals(window.eventOrder, ["load"]);
    }), 100);
  }));

  history.pushState({ state: "new state" }, "");
}, "when pushing state, before load");
</script>