tor-browser

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

RemoveElementContainingSelection.htm (1092B)


      1 <!DOCTYPE HTML>
      2 <html>
      3    <head>
      4        <title id="desc">HTML5 Selection: Remove the element containing the selection</title>
      5        <script src="/resources/testharness.js"></script>
      6        <script src="/resources/testharnessreport.js"></script>
      7        <script type="text/javascript">
      8            function RunTest()
      9            {
     10                var selection = window.getSelection();
     11                var div1 = document.getElementById("div1");
     12                var span1 = document.getElementById("span1");
     13                var range = document.createRange();
     14                range.selectNode(span1);
     15                selection.addRange(range);
     16 
     17                assert_equals(selection.toString(), span1.textContent);
     18                document.body.removeChild(div1);
     19                assert_equals(selection.toString(), "");
     20            }
     21        </script>
     22    </head>
     23    <body onload="test(RunTest);">
     24        <div id="div1">some text
     25            <span id="span1">aaaaaaaa</span>
     26        </div>
     27        <div id="div2">Remove the element containing the selection</div>
     28    </body>
     29 </html>