editor/libeditor/html/tests/test_bug455992.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial