tor-browser

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

deleteFromDocument.htm (1303B)


      1 <!DOCTYPE HTML>
      2 <html>
      3    <head>
      4        <title id="desc">HTML5 Selection: Delete some text from the document while it is part of a selection</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 p2 = document.getElementById("p2");
     13 
     14                var range = document.createRange();
     15                range.setStart(p2.firstChild, 5);
     16                range.setEnd(p2.firstChild, 20);
     17                selection.addRange(range);
     18 
     19                checkSelectionAttributes(p2.firstChild, 5, p2.firstChild, 20, false, 1);
     20                assert_equals(p2.firstChild.data, p2.textContent)
     21 
     22                selection.deleteFromDocument();
     23 
     24                checkSelectionAttributes(p2.firstChild, 5, p2.firstChild, 5, true, 1);
     25                assert_equals(p2.firstChild.data, "abcdeuvwxyz")
     26            }
     27        </script>
     28    </head>
     29    <body onload="test(RunTest);">
     30        <p id="p1">Delete some text from the document while it is part of a selection</p>
     31        <p id="p2">abcdefghijklmnopqrstuvwxyz</p>
     32    </body>
     33 </html>