tor-browser

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

addRange.tentative.html (901B)


      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 p = document.querySelector("p");
     11 
     12    var range = document.createRange();
     13    range.selectNode(p);
     14    selection.addRange(range);
     15 
     16    // In Safari the anchorNode is the Text node, elsewhere it's the Element.
     17    assert_equals(selection.anchorNode, document.body);
     18    assert_equals(selection.anchorOffset, 1);
     19    assert_equals(selection.focusNode, document.body);
     20    assert_equals(selection.focusOffset, 2);
     21    assert_equals(selection.isCollapsed, range.collapsed);
     22    assert_equals(selection.rangeCount, 1);
     23  });
     24 };
     25 </script>
     26 <body>
     27  <p>Add a range to the selection</p>
     28 </body>
     29 </html>