tor-browser

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

simple-occlusion-svg-foreign-object.html (1990B)


      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 <svg id="svg" style="display: block">
     30  <foreignObject>
     31    <div id="occluder"></div>
     32  </foreignObject>
     33 </svg>
     34 
     35 <script>
     36 var delay = 100;
     37 var entries = [];
     38 var target;
     39 var occluder;
     40 
     41 runTestCycle(function() {
     42  target = document.getElementById("target");
     43  occluder = document.getElementById("occluder");
     44  assert_true(!!target, "target exists");
     45  assert_true(!!occluder, "occluder exists");
     46  var observer = new IntersectionObserver(function(changes) {
     47    entries = entries.concat(changes)
     48  }, {trackVisibility: true, delay: delay});
     49  observer.observe(target);
     50  entries = entries.concat(observer.takeRecords());
     51  assert_equals(entries.length, 0, "No initial notifications.");
     52  runTestCycle(step0, "First rAF.", delay);
     53 }, "IntersectionObserverV2 in a single document using the implicit root, with an occluding element.", delay);
     54 
     55 function step0() {
     56  svg.style.marginTop = "-10px";
     57  runTestCycle(step1, "svg.style.marginTop = '-10px'", delay);
     58  checkLastEntry(entries, 0, [0, 100, 0, 100, 0, 100, 0, 100, 0, 800, 0, 600, true, true]);
     59 }
     60 
     61 function step1() {
     62  // Occluding elements with opacity=0 should not affect target visibility.
     63  svg.style.opacity = "0";
     64  runTestCycle(step2, "occluder.style.opacity = 0", delay);
     65  checkLastEntry(entries, 1, [0, 100, 0, 100, 0, 100, 0, 100, 0, 800, 0, 600, true, false]);
     66 }
     67 
     68 function step2() {
     69  checkLastEntry(entries, 2, [0, 100, 0, 100, 0, 100, 0, 100, 0, 800, 0, 600, true, true]);
     70 }
     71 </script>