summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/cssom-view/scroll-zoom.html
blob: 85808887fd348ff11a5e3b6b34e3982a271384df (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<title>scroll properties for elements with css zoom</title>
<link rel="author" title="Yotam Hacohen" href="mailto:yotha@chromium.org">
<link rel="author" title="Google" href="http://www.google.com/">
<link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-element-scroll">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
  <head>
    <style>
      .container {
        height: 100px;
        width: 100px;
        overflow: scroll;
      }
      .content {
        height: 250px;
        width: 250px;
        background-image: linear-gradient(red, yellow);
      }
      #x4_zoom_container {
        zoom: 4;
      }
    </style>
  </head>
  <body>
    <div class="container" id="no_zoom_container">
      <div class="content"></div>
    </div>
    <div class="container" id="x4_zoom_container">
      <div class="content"></div>
    </div>
    <div class="container" id="container_with_zoomed_content">
      <div class="content" style="zoom: 2;"></div>
    </div>
    <div style="zoom: 2;">
      <div class="container" id="scroller_in_zoomed_element">
        <div class="content"></div>
      </div>
    </div>
    <script>
        setup(() => {
          window.noZoom = document.getElementById("no_zoom_container");
          window.withZoom = document.getElementById("x4_zoom_container");
          window.scrollerWithZoomContent = document.getElementById("container_with_zoomed_content");
          window.scrollerInZoomedElement = document.getElementById("scroller_in_zoomed_element");
        });
        test(function() {
          assert_true(!!noZoom, "no zoom target exists");
          assert_true(!!withZoom, "zoom target exists");
        });
        test(function() {
            // We remove zoom effects for scroll height and scroll width so values
            // should be same for elements with and without zoom
            // However scroll values should be changed by zoom on content
          assert_equals(noZoom.scrollHeight, withZoom.scrollHeight, 'scrollHeight');
          assert_equals(noZoom.scrollWidth, withZoom.scrollWidth, 'scrollWidth');
          assert_equals(noZoom.scrollHeight*2, scrollerWithZoomContent.scrollHeight, 'scroll height for zoomed content');
          assert_equals(noZoom.scrollWidth*2, scrollerWithZoomContent.scrollWidth, 'scroll width for zoomed content');
          assert_equals(noZoom.scrollHeight, scrollerInZoomedElement.scrollHeight, 'scroll height for scroller in zoomed element');
          assert_equals(noZoom.scrollWidth, scrollerInZoomedElement.scrollWidth, 'scroll width for scroller in zoomed element');
        }, `scroll{Width, Height}`);

        test(function() {
          assert_equals(noZoom.scrollTop, 0, 'scrollTop should be 0');
          assert_equals(noZoom.scrollLeft, 0, 'scrollLeft should be 0');

          assert_equals(noZoom.scrollTop, withZoom.scrollTop, 'scrollTop');
          assert_equals(noZoom.scrollLeft, withZoom.scrollLeft, 'scrollLeft');

          noZoom.scrollTo(noZoom.scrollWidth / 2, noZoom.scrollHeight / 2);
          withZoom.scrollTo(withZoom.scrollWidth / 2, withZoom.scrollHeight / 2);

          assert_not_equals(noZoom.scrollTop, 0, 'scrollTop should not be 0');
          assert_not_equals(noZoom.scrollLeft, 0, 'scrollLeft should not be 0');

          assert_equals(noZoom.scrollTop, withZoom.scrollTop, 'scrollTop after scrollTo');
          assert_equals(noZoom.scrollLeft, withZoom.scrollLeft, 'scrollLeft after scrollTo');

          noZoom.scrollBy(2, 2);
          withZoom.scrollBy(2, 2);

          assert_equals(noZoom.scrollTop, withZoom.scrollTop, 'scrollTop after scrollBy');
          assert_equals(noZoom.scrollLeft, withZoom.scrollLeft, 'scrollLeft after scrollBy');
        }, `scroll{Top, Left}`);
      </script>
  </body>