tor-browser

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

same-document-with-document-root.html (1775B)


      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    pre,
      9    #log {
     10        position: absolute;
     11        top: 0;
     12        left: 200px;
     13    }
     14 
     15    .spacer {
     16        height: calc(100vh + 100px);
     17    }
     18 
     19    #target {
     20        width: 100px;
     21        height: 100px;
     22        background-color: green;
     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 
     34    var entries = [];
     35    var target;
     36 
     37    runTestCycle(function () {
     38        target = document.getElementById("target");
     39        assert_true(!!target, "target exists");
     40        var observer = new IntersectionObserver(function (changes) {
     41            entries = entries.concat(changes)
     42        }, {root: document});
     43        observer.observe(target);
     44        entries = entries.concat(observer.takeRecords());
     45        assert_equals(entries.length, 0, "No initial notifications.");
     46        runTestCycle(step0, "First rAF.");
     47    }, "IntersectionObserver in a single document using document as root.");
     48 
     49    function step0() {
     50        document.scrollingElement.scrollTop = 300;
     51        runTestCycle(step1, "document.scrollingElement.scrollTop = 300");
     52        checkLastEntry(entries, 0, [8, 108, vh + 108, vh + 208, 0, 0, 0, 0, 0, vw, 0, vh, false]);
     53    }
     54 
     55    function step1() {
     56        document.scrollingElement.scrollTop = 0;
     57        checkLastEntry(entries, 1, [8, 108, vh - 192, vh - 92, 8, 108, vh - 192, vh - 92, 0, vw, 0, vh, true]);
     58    }
     59 </script>