summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/cssom-view/cssom-getBoundingClientRect-003.html
blob: 5eb9448f67645309f38aa1d8361926386447b408 (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
<!doctype html>
<title>{Element,Range}.prototype.getBoundingClientRect on SVG &lt;tspan&gt;</title>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect">
<link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-range-getboundingclientrect">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<svg>
  <text y="180" font-size="100" font-family="Ahem"
        fill="lightblue">X<tspan fill="blue">XX</tspan></text>
</svg>
<script>
  function check(object) {
    let rect = object.getBoundingClientRect();
    assert_equals(rect.left, 108, 'left');
    assert_equals(rect.top, 108, 'top');
    assert_equals(rect.width, 200, 'width');
    assert_equals(rect.height, 100, 'height');
  }
  async_test(t => {
    window.addEventListener("load", t.step_func_done(() => {
      let tspan = document.querySelector('tspan');
      check(tspan);
    }));
  }, document.title + ', Element');
  async_test(t => {
    window.addEventListener("load", t.step_func_done(() => {
      let tspan = document.querySelector('tspan');
      let range = new Range();
      range.selectNode(tspan);
      check(range);
    }));
  }, document.title + ', Range');
</script>