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 102 103 104 105 106 107 108 109 110 111 112 113 114 115
  
     | 
    
      <!DOCTYPE html>
<title>Tests that anchors in a popover are discoverable</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#determining">
<link rel="author" title="Kiet Ho" href="mailto:kiet.ho@apple.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script src="support/test-common.js"></script>
<style>
  body {
    margin: 0;
  }
  #containing-block {
    position: relative;
    width: 100px;
    height: 100px;
    border: 1px black solid;
  }
  #anchor-1 {
    width: 50px;
    height: 50px;
    position: absolute;
    top: 25px;
    left: 25px;
    background: green;
    anchor-name: --anchor-1;
  }
  #popover-1 {
    margin: 0;
    border: 1px black solid;
    padding: 0;
    width: 100px;
    height: 100px;
    position: absolute;
    position-anchor: --anchor-1;
    position-area: bottom right;
  }
  #anchor-2 {
    width: 50px;
    height: 50px;
    position: absolute;
    top: 25px;
    left: 25px;
    background: cyan;
    anchor-name: --anchor-2;
  }
  #popover-2 {
    margin: 0;
    border: 1px black solid;
    padding: 0;
    width: 100px;
    height: 100px;
    position: absolute;
    position-anchor: --anchor-2;
    position-area: bottom right;
  }
</style>
<body>
  <div id="containing-block">
    <div id="anchor-1"></div>
  </div>
  <!--
    1px border of #containing-block
  + 25px gap between #containing-block and #anchor-1
  + 50px width of #anchor-1
  = 76px
  -->
  <div class="target" id="popover-1" popover data-offset-x="76" data-offset-y="76">
    <div id="anchor-2">
      <!--
        76px left offset of #anchor-1
      + 1px border of #popover-2
      + 25px gap between #popover-2 and #anchor-2
      + 50px width of #anchor-2
      = 152px
      -->
      <!-- #popover-2 has to be here to trigger a bug in Safari -->
      <div class="target" id="popover-2" popover data-offset-x="152" data-offset-y="152"></div>
    </div>
  </div>
  <script>
    const popover1 = document.getElementById("popover-1");
    const popover2 = document.getElementById("popover-2");
    popover1.showPopover();
    popover2.showPopover();
    checkLayoutForAnchorPos('.target');
  </script>
</body> 
     |