tor-browser

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

collapseToStart.htm (1140B)


      1 <!DOCTYPE HTML>
      2 <html>
      3    <head>
      4        <title id="desc">HTML5 Selection: Collapse the selection with collapseToStart()</title>
      5        <script src="/resources/testharness.js"></script>
      6        <script src="/resources/testharnessreport.js"></script>
      7        <script src="common.js"></script>
      8        <script type="text/javascript">
      9            function RunTest()
     10            {
     11                var selection = window.getSelection();
     12                var p1 = document.getElementById("p1");
     13 
     14                var range = document.createRange();
     15                range.selectNode(p1);
     16                selection.addRange(range);
     17 
     18                checkSelectionAttributes(document.body, 1, document.body, 2, false, 1);
     19                assert_equals(selection.toString(), p1.textContent);
     20 
     21                selection.collapseToStart();
     22 
     23                checkSelectionAttributes(document.body, 1, document.body, 1, true, 1);
     24                assert_equals(selection.toString(), "")
     25            }
     26        </script>
     27    </head>
     28    <body onload="test(RunTest);">
     29        <p id="p1">Collapse the selection with collapseToStart()</p>
     30    </body>
     31 </html>