tor-browser

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

try-tactic-wm.html (2662B)


      1 <!DOCTYPE html>
      2 <title>CSS Anchor Positioning: try-tactic under different writing modes</title>
      3 <link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#typedef-position-try-fallbacks-try-tactic">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <style>
      7  @position-try --pf {
      8    left:10px;
      9    top:20px;
     10  }
     11  #cb {
     12    position: absolute;
     13    width: 400px;
     14    height: 400px;
     15    border: 1px solid black;
     16  }
     17  #target {
     18    position: absolute;
     19    left: 99999px; /* force fallback */
     20    width: 30px;
     21    height: 40px;
     22    background-color: skyblue;
     23  }
     24 </style>
     25 <div id=cb>
     26  <div id=target></div>
     27 </div>
     28 <script>
     29 
     30  function test_try_tactic_wm(try_tactic, writing_mode, direction, expected_offsets) {
     31    target.style.positionTryFallbacks = `--pf ${try_tactic}`;
     32    cb.style.writingMode = writing_mode;
     33    cb.style.direction = direction;
     34    test(() => {
     35      assert_equals(target.offsetLeft, expected_offsets.left, 'offsetLeft');
     36      assert_equals(target.offsetTop, expected_offsets.top, 'offsetTop');
     37      assert_equals(target.offsetWidth, expected_offsets.width, 'offsetWidth');
     38      assert_equals(target.offsetHeight, expected_offsets.height, 'offsetHeight');
     39    }, `${try_tactic} ${writing_mode} ${direction}`);
     40  }
     41 
     42  test_try_tactic_wm('', 'horizontal-tb', 'ltr', {left:10, top:20, width:30, height:40});
     43 
     44  // Effectively flips left:10px to right:10px:
     45  test_try_tactic_wm('flip-inline', 'horizontal-tb', 'ltr', {left:360, top:20, width:30, height:40});
     46  test_try_tactic_wm('flip-x', 'horizontal-tb', 'ltr', {left:360, top:20, width:30, height:40});
     47 
     48  // Effectively flips top:20px to bottom:20px:
     49  test_try_tactic_wm('flip-inline', 'vertical-lr', 'ltr', {left:10, top:340, width:30, height:40});
     50  test_try_tactic_wm('flip-inline', 'sideways-lr', 'ltr', {left:10, top:340, width:30, height:40});
     51  test_try_tactic_wm('flip-y', 'vertical-lr', 'ltr', {left:10, top:340, width:30, height:40});
     52  test_try_tactic_wm('flip-y', 'sideways-lr', 'ltr', {left:10, top:340, width:30, height:40});
     53 
     54  // Effectively flips left:10px to right:10px:
     55  test_try_tactic_wm('flip-block', 'sideways-rl', 'ltr', {left:360, top:20, width:30, height:40});
     56  test_try_tactic_wm('flip-x', 'sideways-rl', 'ltr', {left:360, top:20, width:30, height:40});
     57 
     58  // Mirror across the [left,top]=>[bottom,right] diagonal:
     59  test_try_tactic_wm('flip-start', 'horizontal-tb', 'ltr', {left:20, top:10, width:40, height:30});
     60 
     61  // Mirror across the [right,top]=>[bottom,left] diagonal:
     62  test_try_tactic_wm('flip-start', 'horizontal-tb', 'rtl', {left:340, top:360, width:40, height:30});
     63 
     64 </script>