tor-browser

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

visibility-hidden.html (1650B)


      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 {
      9  margin: 0;
     10 }
     11 pre, #log {
     12  position: absolute;
     13  top: 0;
     14  left: 200px;
     15 }
     16 .spacer {
     17  height: calc(100vh + 100px);
     18 }
     19 #target {
     20  width: 100px;
     21  height: 100px;
     22  visibility: hidden;
     23 }
     24 </style>
     25 
     26 <div class="spacer"></div>
     27 <div id="target"></div>
     28 <div class="spacer"></div>
     29 
     30 <script>
     31 var vw = document.documentElement.clientWidth;
     32 var vh = document.documentElement.clientHeight;
     33 var entries = [];
     34 
     35 runTestCycle(function() {
     36  target = document.getElementById("target");
     37  assert_true(!!target, "target exists");
     38  var observer = new IntersectionObserver(function(changes) {
     39    entries = entries.concat(changes)
     40  });
     41  observer.observe(target);
     42  entries = entries.concat(observer.takeRecords());
     43  assert_equals(entries.length, 0, "No initial notifications.");
     44  runTestCycle(step0, "First rAF.");
     45 }, "IntersectionObserver observing a visibility:hidden element.");
     46 
     47 function step0() {
     48  document.scrollingElement.scrollTop = 300;
     49  runTestCycle(step1, "document.scrollingElement.scrollTop = 300");
     50  // The numbers in brackets are target client rect; intersection rect;
     51  // and root bounds.
     52  checkLastEntry(entries, 0, [0, 100, vh + 100, vh + 200, 0, 0, 0, 0, 0, vw, 0, vh, false]);
     53 }
     54 
     55 function step1() {
     56  document.scrollingElement.scrollTop = 0;
     57  checkLastEntry(entries, 1, [0, 100, vh - 200, vh - 100, 0, 100, vh - 200, vh - 100, 0, vw, 0, vh, true]);
     58 }
     59 </script>