summaryrefslogtreecommitdiffstats
path: root/docshell/test/mochitest/test_history_length_during_pageload.html
blob: c1ac332791c54ba57af2654c9223fff269cb9f8b (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
36
37
38
39
40
41
42
43
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test history.length during page load</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
  <script>
    SimpleTest.waitForExplicitFinish();

    function runTest(testAsyncLength) {
      return new Promise(function(resolve) {
        var initialLength;
        var messageCount = 0;
        var win;
        window.onmessage = function(event) {
          if (event.data.initialLength) {
            initialLength = event.data.initialLength;
          } else {
            is(event.data.length, initialLength + 1,
               "history.length should increase by one when loading a new page");
          }
          if (++messageCount == 3) {
            win.close();
            resolve();
          }
        }
        win = window.open("file_history_length_during_pageload.html?testAsyncLength=" + testAsyncLength);
      });
    }

    async function runTests() {
      await runTest(!SpecialPowers.Services.appinfo.sessionHistoryInParent);
      SimpleTest.finish();
    }
  </script>
</head>
<body onload="runTests();">
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
</body>
</html>