tor-browser

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

observer-attributes.html (1486B)


      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 
      6 <div id="root"></div>
      7 
      8 <script>
      9 test(function() {
     10  var observer = new IntersectionObserver(function(e) {}, {});
     11  test(function() { assert_equals(observer.root, null) },
     12       "observer.root");
     13  test(function() { assert_array_equals(observer.thresholds, [0]) },
     14       "observer.thresholds");
     15  test(function() { assert_equals(observer.rootMargin, "0px 0px 0px 0px") },
     16       "observer.rootMargin");
     17 
     18  observer = new IntersectionObserver(function(e) {}, {
     19    rootMargin: " ",
     20    threshold: []
     21  });
     22  test(function() { assert_array_equals(observer.thresholds, [0]) },
     23       "empty observer.thresholds");
     24  test(function() { assert_equals(observer.rootMargin, "0px 0px 0px 0px") },
     25       "whitespace observer.rootMargin");
     26 
     27  var rootDiv = document.getElementById("root");
     28  observer = new IntersectionObserver(function(e) {}, {
     29    root: rootDiv,
     30    threshold: [0, 0.25, 0.5, 1.0],
     31    rootMargin: "10% 20px"
     32  });
     33  test(function() { assert_equals(observer.root, rootDiv) },
     34       "set observer.root");
     35  test(function() { assert_array_equals(observer.thresholds, [0, 0.25, 0.5, 1.0]) },
     36       "set observer.thresholds");
     37  test(function() { assert_equals(observer.rootMargin, "10% 20px 10% 20px") },
     38       "set observer.rootMargin");
     39 }, "Observer attribute getters.");
     40 
     41 </script>