summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-scroll-anchoring/history-restore-anchors.html
blob: ecd7806bc935459195862d0e331c4f6130c9efac (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
<link rel="help" href="https://drafts.csswg.org/css-scroll-anchoring/">

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

<script>
  var win;
  var messageCount = 0;
  // Navigation steps:
  // 1- page gets loaded and anchor element gets scrolled into view.
  // 2- loaded page refreshed.
  async_test(function(t) {
    window.onmessage = function() {
      if (++messageCount == 1) {
        t.step(() => {
          var anchor = win.document.getElementById('anchor');
          anchor.scrollIntoView();
          assert_equals(win.scrollY, 1000);
          win.location.reload();
        });
      } else {
         t.step(() => {
            assert_equals(win.scrollY, 1000);
            // Change height of content above anchor.
            var ch = win.document.getElementById('changer');
            ch.style.height = 100;
            // Height of first + height changer.
            assert_equals(win.scrollY, 1100)
            t.done();
        });
        win.close();
      }
    };
    win = window.open('support/history-restore-anchors-new-window.html');
  }, 'Verify scroll anchoring interaction with history restoration');
</script>