summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/history/history-length.html
blob: 8c92c6f516c3a87b8ad8622d20f7dae5b811a030 (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
44
<script>
onload = function() {
  if (location.search.substring(1).length == 0) {
    sessionStorage.testStage = 0;
    if (window.testRunner) {
      testRunner.dumpAsText();
      testRunner.clearBackForwardList();
      testRunner.waitUntilDone();
    }
  }

  // Location changes need to happen outside the onload handler to generate history entries.
  setTimeout(function() {
    // This test advances history by 2 pages, then navigates back one, and
    // records history.length.  We expect history.length to indicate the total
    // length of session history.  At the end of the test, it should be 2 greater
    // than it was at the start of the test.
    switch (sessionStorage.testStage++) {
    case 0:
      sessionStorage.initialLength = history.length;
      location = "?a";
      break;
    case 1:
      location = "?b";
      break;
    case 2:
      history.back();
      break;
    case 3:
      if (history.length == (sessionStorage.initialLength - 0) + 2)
        document.body.innerHTML = "PASS";
      else
        document.body.innerHTML = "FAIL: initialLength=" + sessionStorage.initialLength + ", history.length=" + history.length;
      if (window.testRunner)
        testRunner.notifyDone();
      break;
    }
  }, 0);
}
onunload = function() {
  // disable page cache
}
</script>
<body></body>