tor-browser

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

Range-commonAncestorContainer.html (1116B)


      1 <!doctype html>
      2 <title>Range.commonAncestorContainer tests</title>
      3 <link rel="author" title="Aryeh Gregor" href=ayg@aryeh.name>
      4 <meta name=timeout content=long>
      5 <div id=log></div>
      6 <script src=/resources/testharness.js></script>
      7 <script src=/resources/testharnessreport.js></script>
      8 <script src=../common.js></script>
      9 <script>
     10 "use strict";
     11 
     12 testRanges.unshift("[detached]");
     13 
     14 for (var i = 0; i < testRanges.length; i++) {
     15  test(function() {
     16    var range;
     17    if (i == 0) {
     18      range = document.createRange();
     19      range.detach();
     20    } else {
     21      range = rangeFromEndpoints(eval(testRanges[i]));
     22    }
     23 
     24    // "Let container be start node."
     25    var container = range.startContainer;
     26 
     27    // "While container is not an inclusive ancestor of end node, let
     28    // container be container's parent."
     29    while (container != range.endContainer
     30    && !isAncestor(container, range.endContainer)) {
     31      container = container.parentNode;
     32    }
     33 
     34    // "Return container."
     35    assert_equals(range.commonAncestorContainer, container);
     36  }, i + ": range " + testRanges[i]);
     37 }
     38 
     39 testDiv.style.display = "none";
     40 </script>