tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

anchor-transition-003.html (2052B)


      1 <!DOCTYPE html>
      2 <title>Tests CSS transition of anchor() across three tree scopes</title>
      3 <link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/">
      4 <link rel="help" href="https://github.com/w3c/csswg-drafts/issues/8180"></script>
      5 <link rel="author" href="mailto:xiaochengh@chromium.org">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 
      9 <style>
     10 body {
     11  margin: 0;
     12 }
     13 
     14 #anchor1 {
     15  width: 100px;
     16  height: 100px;
     17  background: orange;
     18  anchor-name: --a;
     19 }
     20 
     21 #host.after::part(target) {
     22  left: anchor(--a left);
     23 }
     24 </style>
     25 
     26 <div id="anchor1"></div>
     27 <div id="host"></div>
     28 
     29 <script>
     30 setup(() => {
     31 let shadow = host.attachShadow({mode: 'open'});
     32 shadow.innerHTML = `
     33  <style>
     34    div {
     35      width: 100px;
     36      height: 100px;
     37      background: orange;
     38    }
     39    #anchor2 {
     40      margin-left: 200px;
     41      anchor-name: --a;
     42    }
     43    #anchor3 {
     44      margin-left: 400px;
     45    }
     46    #target {
     47      position: fixed;
     48      background: lime;
     49      top: 300px;
     50      transition: left 10s -5s linear;
     51    }
     52    #target.after {
     53      left: anchor(--a left);
     54    }
     55  </style>
     56  <div id="anchor2"></div>
     57  <div id="anchor3">
     58    <div id="target" part="target"></div>
     59  </div>
     60 `;
     61 
     62 let anchor3 = shadow.getElementById('anchor3');
     63 let innerShadow = anchor3.attachShadow({mode: 'open'});
     64 innerShadow.innerHTML = `
     65  <style>
     66    :host { anchor-name: --a; }
     67    ::slotted(*) { left: anchor(--a left); }
     68  </style>
     69  <slot></slot>
     70 `;
     71 });
     72 
     73 test(() => {
     74  let target = host.shadowRoot.getElementById('target');
     75 
     76  // Forces layout
     77  target.offsetLeft;
     78 
     79  // Triggers a transition from using #anchor3 to using #anchor2,
     80  // starting immediately at 50% progress
     81  target.classList.add('after');
     82  assert_equals(target.offsetLeft, 300);
     83 
     84  // Triggers another transition to using #anchor1 while the previous
     85  // transition is still in progress.
     86  host.classList.add('after');
     87  assert_equals(target.offsetLeft, 150);
     88 }, 'Transition with anchor names defined in three different tree scopes');
     89 </script>