tor-browser

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

test_bug309731.html (1778B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=309731
      5 -->
      6 <head>
      7  <title>Test for Bug 309731</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script src="/tests/SimpleTest/EventUtils.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     11 </head>
     12 <body>
     13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=309731">Mozilla Bug 309731</a>
     14 <p id="display"></p>
     15 
     16 <div id="content">
     17  <div id="input" contentEditable="true"></div>
     18 </div>
     19 <pre id="test">
     20 <script type="application/javascript">
     21 /** Test for Bug 309731 */
     22 
     23 function selectNode(node) {
     24  getSelection().selectAllChildren(node);
     25 }
     26 
     27 function selectInNode(node) {
     28  getSelection().collapse(node, 0);
     29 }
     30 
     31 function doTest() {
     32  var input = document.getElementById("input");
     33 
     34  is(input.textContent, "", "Input node starts empty");
     35 
     36  selectInNode(input);
     37  ok(document.execCommand("inserthtml", false, ""), "execCommand should return true");
     38  is(input.textContent, "", "empty inserthtml with empty selection shouldn't change contents");
     39 
     40  selectInNode(input);
     41  ok(document.execCommand("inserthtml", false, "foo"), "execCommand should return true");
     42  is(input.textContent, "foo", "'foo'inserthtml with empty selection should add foo to contents");
     43 
     44  selectNode(input);
     45  ok(document.execCommand("inserthtml", false, "bar"), "execCommand should return true");
     46  is(input.textContent, "bar", "'bar' inserthtml with complete selection should replace contents with bar");
     47 
     48  selectNode(input);
     49  ok(document.execCommand("inserthtml", false, ""), "execCommand should return true");
     50  is(input.textContent, "", "empty inserthtml with complete selection should delete everything");
     51 }
     52 
     53 doTest();
     54 
     55 </script>
     56 </pre>
     57 </body>
     58 </html>