tor-browser

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

iframe-no-root-with-wrapping-scroller.html (2209B)


      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, #log {
      9  position: absolute;
     10  top: 0;
     11  left: 200px;
     12 }
     13 .spacer {
     14  height: calc(100vh + 100px);
     15 }
     16 iframe {
     17  height: 100px;
     18  width: 150px;
     19 }
     20 </style>
     21 
     22 <div class="spacer"></div>
     23 <div style="overflow: hidden">
     24  <iframe id="target-iframe" src="resources/iframe-no-root-subframe.html"></iframe>
     25 </div>
     26 <div class="spacer"></div>
     27 
     28 <script>
     29 var vw = document.documentElement.clientWidth;
     30 var vh = document.documentElement.clientHeight;
     31 
     32 var iframe = document.getElementById("target-iframe");
     33 var target;
     34 var entries = [];
     35 
     36 iframe.onload = function() {
     37  runTestCycle(function() {
     38    assert_true(!!iframe, "iframe exists");
     39 
     40    target = iframe.contentDocument.getElementById("target");
     41    assert_true(!!target, "Target element exists.");
     42    var observer = new IntersectionObserver(function(changes) {
     43      entries = entries.concat(changes)
     44    });
     45    observer.observe(target);
     46    entries = entries.concat(observer.takeRecords());
     47    assert_equals(entries.length, 0, "No initial notifications.");
     48    runTestCycle(step0, "First rAF.");
     49  }, "Observer with the implicit root; target in a same-origin iframe.");
     50 };
     51 
     52 function step0() {
     53  document.scrollingElement.scrollTop = 200;
     54  runTestCycle(step1, "document.scrollingElement.scrollTop = 200");
     55  checkLastEntry(entries, 0, [8, 108, 208, 308, 0, 0, 0, 0, 0, vw, 0, vh, false]);
     56 }
     57 
     58 function step1() {
     59  iframe.contentDocument.scrollingElement.scrollTop = 250;
     60  runTestCycle(step2, "iframe.contentDocument.scrollingElement.scrollTop = 250");
     61  assert_equals(entries.length, 1, "entries.length == 1");
     62 }
     63 
     64 function step2() {
     65  document.scrollingElement.scrollTop = 100;
     66  runTestCycle(step3, "document.scrollingElement.scrollTop = 100");
     67  checkLastEntry(entries, 1, [8, 108, -42, 58, 8, 108, 0, 58, 0, vw, 0, vh, true]);
     68 }
     69 
     70 function step3() {
     71  checkLastEntry(entries, 2, [8, 108, -42, 58, 0, 0, 0, 0, 0, vw, 0, vh, false]);
     72  document.scrollingElement.scrollTop = 0;
     73 }
     74 </script>