tor-browser

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

addRange.htm (953B)


      1 <!DOCTYPE HTML>
      2 <meta charset=utf-8>
      3 <title>Selection: Add a range to the selection</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script>
      7 window.onload = function() {
      8  test(function() {
      9    var selection = window.getSelection();
     10    var p1 = document.getElementById("p1");
     11 
     12    var range = document.createRange();
     13    range.selectNode(p1);
     14    selection.addRange(range);
     15 
     16    assert_equals(selection.anchorNode, range.startContainer);
     17    assert_equals(selection.anchorOffset, range.startOffset);
     18    assert_equals(selection.focusNode, range.endContainer);
     19    assert_equals(selection.focusOffset, range.endOffset);
     20    assert_equals(selection.isCollapsed, range.collapsed);
     21    assert_equals(selection.rangeCount, 1);
     22    assert_equals(selection.toString(), p1.firstChild.nodeValue);
     23  });
     24 };
     25 </script>
     26 <div id=log></div>
     27 <p id="p1">Add a range to the selection</p>
     28 </body>
     29 </html>