summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-anchor-position/inset-area-align-justify.html
blob: 7f7f05ccf3a9857566de7b9fb92d3f84d1ba10ec (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
<!DOCTYPE html>
<title>CSS Anchor Positioning: inset-area positioning - alignment</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#inset-area">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
  /* A 300x300 container with a 100x100 centered anchor */
  #container {
    position: relative;
    width: 300px;
    height: 300px;
  }
  #anchor {
    position: absolute;
    top: 100px;
    left: 100px;
    width: 100px;
    height: 100px;
    anchor-name: --anchor;
  }
  #anchored {
    position: absolute;
    width: 10px;
    height: 10px;
    inset: 10px;
    position-anchor: --anchor;
  }
</style>
<div id="container">
  <div id="anchor"></div>
  <div id="anchored"></div>
</div>
<script>
  function test_inset_area(inset_area, expected_offsets) {
    anchored.style.insetArea = inset_area;

    test(() => {
      assert_equals(anchored.offsetLeft, expected_offsets.left, "Check expected offsetLeft");
      assert_equals(anchored.offsetTop, expected_offsets.top, "Check expected offsetTop");
      assert_equals(anchored.offsetWidth, expected_offsets.width, "Check expected offsetWidth");
      assert_equals(anchored.offsetHeight, expected_offsets.height, "Check expected offsetHeight");
    }, "Offsets for inset-area: " + inset_area);
  }

  // anchor-center in both directions
  test_inset_area("span-all", {left:145, top:145, width:10, height:10});

  // Single region spans
  test_inset_area("top left", {left:80, top:80, width:10, height:10});
  test_inset_area("top center", {left:145, top:80, width:10, height:10});
  test_inset_area("top right", {left:210, top:80, width:10, height:10});
  test_inset_area("center left", {left:80, top:145, width:10, height:10});
  test_inset_area("center center", {left:145, top:145, width:10, height:10});
  test_inset_area("center right", {left:210, top:145, width:10, height:10});
  test_inset_area("bottom left", {left:80, top:210, width:10, height:10});
  test_inset_area("bottom center", {left:145, top:210, width:10, height:10});
  test_inset_area("bottom right", {left:210, top:210, width:10, height:10});

  // Multi-region spans
  test_inset_area("top span-left", {left:180, top:80, width:10, height:10});
  test_inset_area("top span-right", {left:110, top:80, width:10, height:10});
  test_inset_area("span-top left", {left:80, top:180, width:10, height:10});
  test_inset_area("span-bottom left", {left:80, top:110, width:10, height:10});

</script>