summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/browsing-the-web/history-traversal/pageswap/pageswap-initial-navigation.html
blob: 5483b9394d4e4b5762966a80e19158955805d353 (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
29
30
31
32
33
34
35
<!DOCTYPE HTML>
<title>Tests pageswap dispatch on initial doc navigation</title>
<link rel="author" title="Khushal Sagar"  href="mailto:khushalsagar@chromium.org">
<link rel="help" href="https://html.spec.whatwg.org/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script>
setup({explicit_done: true});

function runTest(frame) {
  let frameWindow = frame.contentWindow;

  let pageswapfired = false;
  frameWindow.onpageswap = (e) => {
      pageswapfired = true;
  }

  frameWindow.onpagehide = (e) => {
      assert_true(pageswapfired, 'pageswap fired');
      done();
  }

  frame.srcdoc = '<html></html>';
}

promise_test(async t => {
  onload = () => {
    let frame = document.createElement('iframe');
    document.body.appendChild(frame);
    runTest(frame);
  };
});
</script>