summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/shadow-dom/offsetTop-offsetLeft-across-shadow-boundaries.html
blob: 27b1faa17100fa37f3fba7cd8f7ec12c0450e7f2 (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
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<style>
.box {
  width: 10px;
  height: 10px;
}
</style>

<div>
  <template shadowrootmode=open>
    <style>
    .box {
      width: 10px;
      height: 10px;
    }
    </style>
    <div class=box></div>
    <div style="position: relative">
      <div class=box></div>
      <slot></slot>
    </div>
  </template>
  <div class=box></div>
  <div id=target1 style="position: absolute" class=box></div>
</div>

<span>
  <template shadowrootmode=open>
    <style>
    .box {
      width: 10px;
      height: 10px;
    }
    </style>
    <span class=box></span>
    <span style="position: relative">
      <span class=box></span>
      <slot></slot>
    </span>
  </template>
  <span class=box></span>
  <span id=target2 style="position: absolute" class=box></span>
</span>

<div>
  <template shadowrootmode=open>
    <style>
    .box {
      width: 10px;
      height: 10px;
    }
    </style>
    <div class=box></div>
    <div style="position: relative">
      <div class=box></div>
      <div>
        <template shadowrootmode=open>
          <style>
          .box {
            width: 10px;
            height: 10px;
          }
          </style>
          <div class=box></div>
          <div style="position: relative">
            <div class=box></div>
            <slot></slot>
          </div>
        </template>
        <slot></slot>
      </div>
    </div>
  </template>
  <div class=box></div>
  <div id=target3 style="position: absolute" class=box></div>
</div>

<script>
test(() => {
  assert_equals(target1.offsetTop, 38);
}, 'Verifies that HTMLElement.offsetTop accounts for shadow boundaries.');

test(() => {
  assert_equals(target2.offsetLeft, 8);
}, 'Verifies that HTMLElement.offsetLeft accounts for shadow boundaries.');

test(() => {
  assert_equals(target3.offsetTop, 88);
}, 'Verifies that HTMLElement.offsetTop accounts for shadow boundaries when nested in multiple shadow roots.');
</script>