tor-browser

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

content-visibility-anchor-positioning-007.html (1914B)


      1 <!doctype HTML>
      2 <meta charset=utf8>
      3 <title>CSS Content Visibility: auto not skipped due to being an indirect influence on anchoring</title>
      4 <link rel="author" title="Chris Harrelson" href="mailto:chrishtr@chromium.org">
      5 <link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#anchor-relevance">
      6 <script src="/web-animations/testcommon.js"></script>
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 
     10 <!DOCTYPE html>
     11 <style>
     12 @position-try --foo {
     13  right: anchor(--a2 left);
     14 }
     15 
     16 #container {
     17  position:relative;
     18  height: 10000px;
     19 }
     20 
     21 #lock {
     22  height: 400px;
     23  width: 400px;
     24  content-visibility: auto;
     25  border: 1px solid black;
     26 }
     27 
     28 
     29 #anchor {
     30  anchor-name: --a1;
     31  position: absolute;
     32 }
     33 
     34 #anchor2 {
     35  anchor-name: --a2;
     36  position: absolute;
     37  left: 60px;
     38 }
     39 
     40 #positioned {
     41  position: absolute;
     42  right: anchor(--a1 left);
     43  position-try: --foo;
     44 }
     45 
     46 </style>
     47 <div id=container>
     48  <!-- #positioned will anchor to anchor2, but only due to the presence of
     49    #anchor. This is an example of why #anchor needs to not be locked as
     50    long as #positioned is anchored to one of the other things it depends
     51    on.
     52  -->
     53  <div id=lock>
     54    <div id="anchor">--a1</div>
     55  </div>
     56  <div id=anchor2>--a2</div>
     57  <div id=positioned>OO
     58  </div>
     59 </div>
     60 
     61 <pre id=output>
     62 </pre>
     63 <script>
     64 "use strict";
     65 
     66 let skipped = false;
     67 lock.addEventListener("contentvisibilityautostatechange",
     68  (e) => {
     69    skipped = e.skipped;
     70  });
     71 
     72 promise_test(async t => {
     73 
     74  positioned.style.positionAnchor = "--anchor";
     75  await waitForAnimationFrames(2);
     76 
     77  assert_approx_equals(positioned.getBoundingClientRect().left, 44, 1,
     78    '#positioned should be anchored because #anchor is on-screen.');
     79 
     80  window.scrollTo(0, 10000);
     81  await waitForAnimationFrames(4);
     82  assert_false(skipped, "The content-visibility subtree is not skipped even though it's offscreen.");
     83 });
     84 
     85 </script>