tor-browser

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

test_bug455992.html (3421B)


      1 <!DOCTYPE HTML>
      2 <html><head>
      3 <title>Test for bug 455992</title>
      4 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
      5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6 <script src="/tests/SimpleTest/EventUtils.js"></script>
      7 
      8 <script class="testbody" type="application/javascript">
      9 function runTest() {
     10  function select(id) {
     11    var e = document.getElementById(id);
     12    e.focus();
     13    return e;
     14  }
     15 
     16  function setupIframe(id) {
     17    var e = document.getElementById(id);
     18    var doc = e.contentDocument;
     19    doc.body.innerHTML = String.fromCharCode(10) + '<span id="' + id + '_span" style="border:1px solid blue" contenteditable="true">X</span>' + String.fromCharCode(10);
     20    e = doc.getElementById(id + "_span");
     21    e.focus();
     22    return e;
     23  }
     24 
     25  function test_begin_bs(e) {
     26    const msg = "BACKSPACE at beginning of contenteditable inline element";
     27    var before = e.parentNode.childNodes[0].nodeValue;
     28    sendKey("back_space");
     29    is(e.parentNode.childNodes[0].nodeValue, before, msg + " with id=" + e.id);
     30    is(e.innerHTML, "X", msg + " with id=" + e.id);
     31  }
     32 
     33  function test_begin_space(e) {
     34    const msg = "SPACE at beginning of contenteditable inline element";
     35    var before = e.parentNode.childNodes[0].nodeValue;
     36    sendChar(" ");
     37    is(e.parentNode.childNodes[0].nodeValue, before, msg + " with id=" + e.id);
     38    is(e.innerHTML, "&nbsp;X", msg + " with id=" + e.id);
     39  }
     40 
     41  function test_end_delete(e) {
     42    const msg = "DEL at end of contenteditable inline element";
     43    var before = e.parentNode.childNodes[2].nodeValue;
     44    sendKey("right");
     45    sendKey("delete");
     46    is(e.parentNode.childNodes[2].nodeValue, before, msg + " with id=" + e.id);
     47    is(e.innerHTML, "X", msg + " with id=" + e.id);
     48  }
     49 
     50  function test_end_space(e) {
     51    const msg = "SPACE at end of contenteditable inline element";
     52    var before = e.parentNode.childNodes[2].nodeValue;
     53    sendKey("right");
     54    sendChar(" ");
     55    is(e.parentNode.childNodes[2].nodeValue, before, msg + " with id=" + e.id);
     56    is(e.innerHTML, "X&nbsp;", msg + " with id=" + e.id);
     57  }
     58 
     59  test_begin_bs(select("t1"));
     60  test_begin_space(select("t2"));
     61  test_end_delete(select("t3"));
     62  test_end_space(select("t4"));
     63  test_end_space(select("t5"));
     64 
     65  test_begin_bs(setupIframe("i1"));
     66  test_begin_space(setupIframe("i2"));
     67  test_end_delete(setupIframe("i3"));
     68  test_end_space(setupIframe("i4"));
     69 
     70  SimpleTest.finish();
     71 }
     72 
     73 SimpleTest.waitForExplicitFinish();
     74 addLoadEvent(runTest);
     75 </script>
     76 </head>
     77 <body>
     78 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=455992">Mozilla Bug 455992</a>
     79 <p id="display"></p>
     80 
     81 <pre id="test">
     82 </pre>
     83 
     84 <div> <span id="t1" style="border:1px solid blue" contenteditable="true">X</span> Y</div>
     85 <div> <span id="t2" style="border:1px solid blue" contenteditable="true">X</span> Y</div>
     86 <div> <span id="t3" style="border:1px solid blue" contenteditable="true">X</span> Y</div>
     87 <div> <span id="t4" style="border:1px solid blue" contenteditable="true">X</span> Y</div>
     88 <div> <div id="t5" style="border:1px solid blue" contenteditable="true">X</div> Y</div>
     89 
     90 <iframe id="i1" width="200" height="100" src="about:blank"></iframe><br>
     91 <iframe id="i2" width="200" height="100" src="about:blank"></iframe><br>
     92 <iframe id="i3" width="200" height="100" src="about:blank"></iframe><br>
     93 <iframe id="i4" width="200" height="100" src="about:blank"></iframe><br>
     94 
     95 </body>
     96 </html>