tor-browser

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

simple-occlusion.html (1919B)


      1 <!DOCTYPE html>
      2 <meta name="viewport" content="width=device-width,initial-scale=1">
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="../resources/intersection-observer-test-utils.js"></script>
      6 
      7 <style>
      8 body, html {
      9  margin: 0;
     10 }
     11 pre, #log {
     12  position: absolute;
     13  top: 0;
     14  left: 200px;
     15 }
     16 #target {
     17  width: 100px;
     18  height: 100px;
     19  background-color: green;
     20 }
     21 #occluder {
     22  width: 100px;
     23  height: 100px;
     24  background-color: blue;
     25 }
     26 </style>
     27 
     28 <div id="target"></div>
     29 <div id="occluder"></div>
     30 
     31 <script>
     32 var delay = 100;
     33 var entries = [];
     34 var target;
     35 var occluder;
     36 
     37 runTestCycle(function() {
     38  target = document.getElementById("target");
     39  occluder = document.getElementById("occluder");
     40  assert_true(!!target, "target exists");
     41  assert_true(!!occluder, "occluder exists");
     42  var observer = new IntersectionObserver(function(changes) {
     43    entries = entries.concat(changes)
     44  }, {trackVisibility: true, delay: delay});
     45  observer.observe(target);
     46  entries = entries.concat(observer.takeRecords());
     47  assert_equals(entries.length, 0, "No initial notifications.");
     48  runTestCycle(step0, "First rAF.", delay);
     49 }, "IntersectionObserverV2 in a single document using the implicit root, with an occluding element.", delay);
     50 
     51 function step0() {
     52  occluder.style.marginTop = "-10px";
     53  runTestCycle(step1, "occluder.style.marginTop = '-10px'", delay);
     54  checkLastEntry(entries, 0, [0, 100, 0, 100, 0, 100, 0, 100, 0, 800, 0, 600, true, true]);
     55 }
     56 
     57 function step1() {
     58  // Occluding elements with opacity=0 should not affect target visibility.
     59  occluder.style.opacity = "0";
     60  runTestCycle(step2, "occluder.style.opacity = 0", delay);
     61  checkLastEntry(entries, 1, [0, 100, 0, 100, 0, 100, 0, 100, 0, 800, 0, 600, true, false]);
     62 }
     63 
     64 function step2() {
     65  checkLastEntry(entries, 2, [0, 100, 0, 100, 0, 100, 0, 100, 0, 800, 0, 600, true, true]);
     66 }
     67 </script>