summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/cssom-view/offsetTop-offsetLeft-with-zoom.html
blob: a60a18a4313b5c9ffd7f8d6c8d42a46062152cf4 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<title>OffsetTop and OffsetLeft 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/css-viewport/">"
<meta name="viewport" content="width=device-width,initial-scale=1">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<!DOCTYPE html>

<style>
  .outer_div {
    width: 100px;
    height: 100px;
    border: 1px solid black;
    position: relative;
    margin: 10px;
  }
  .square {
    width: 10px;
    height: 10px;
    background-color: green;
    margin: 1px;
    top:10x;
    left: 10x;

  }
  .one {
    position: relative;
    top: 10px;
    left: 10px;
  }
  .two {
    position: absolute;
    top: 20px;
    left: 20px;
    zoom: 2;
    }

  .three {
    position: absolute;
    top: 10px;
    left: 50px;
    zoom: 0.5;
  }
  span.square {
      display: inline-block;
  }
</style>

<div class="outer_div">
  <div id="unzoomed_one" class="square one"></div>
  <div id="unzoomed_two" class="square two"></div>
  <div id="unzoomed_three" class="square three"></div>
</div>
<div style="zoom:3" class=outer_div>
  <div id="zoomed_one" class="square one"></div>
  <div id="zoomed_two" class="square two"></div>
  <div id="zoomed_three" class="square three"></div>
</div>

<div class ="outer_div" style="margin: 30px;" id="outer_div">
    <div id="zoomed_middle" style="margin: 10px; zoom:2">
        <div class="square" id="unzoomed_inner"></div>
    </div>
</div>
<div class = outer_div style="margin: 30px;">
    <div id="unzoomed_middle">
        <div class="square" id="zoomed_inner" style="zoom:2; width: 100px; height: 100px; border: 1px solid black;"></div>
    </div>
</div>


<script>
test(() => {
  assert_equals(unzoomed_one.offsetTop, 11, 'unzoomed_one.offsetTop');
  assert_equals(unzoomed_one.offsetLeft, 11, 'unzoomed_one.offsetLeft');
  assert_equals(unzoomed_two.offsetTop, 21, 'unzoomed_two.offsetTop');
  assert_equals(unzoomed_two.offsetLeft, 21, 'unzoomed_two.offsetLeft');
  assert_equals(unzoomed_three.offsetTop, 11, 'unzoomed_three.offsetTop');
  assert_equals(unzoomed_three.offsetLeft, 51, 'unzoomed_three.offsetLeft');
  assert_equals(zoomed_one.offsetTop, 11, 'zoomed_one.offsetTop');
  assert_equals(zoomed_one.offsetLeft, 11, 'zoomed_one.offsetLeft');
  assert_equals(zoomed_two.offsetTop, 21, 'zoomed_two.offsetTop');
  assert_equals(zoomed_two.offsetLeft, 21, 'zoomed_two.offsetLeft');
  assert_equals(zoomed_three.offsetTop, 11, 'zoomed_three.offsetTop');
  assert_equals(zoomed_three.offsetLeft, 51, 'zoomed_three.offsetLeft');
  assert_equals(unzoomed_inner.offsetTop, 10, 'unzoomed_inner.offsetTop');
  assert_equals(unzoomed_inner.offsetLeft, 11, 'unzoomed_inner.offsetLeft');
  assert_equals(zoomed_inner.offsetTop, 0, 'zoomed_inner.offsetTop');
  assert_equals(zoomed_inner.offsetLeft, 1, 'zoomed_inner.offsetLeft');

  // check that offset is equal between elements when one of them has css zoom
  assert_equals(unzoomed_one.offsetWidth, zoomed_one.offsetWidth, "offsetWidth");
  assert_equals(unzoomed_one.offsetHeight, zoomed_one.offsetHeight, "offsetHeight");
  assert_equals(zoomed_inner.offsetWidth, outer_div.offsetWidth, "offsetWidth for nested element");
  assert_equals(zoomed_inner.offsetHeight, outer_div.offsetHeight, "offsetHeight for nested element");

}, 'Verifies that offsetTop and offsetLeft find the right OffsetParent and return values excluding the target zoom');
</script>