editor/libeditor/html/tests/test_bug456244.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html><head>
michael@0 3 <title>Test for bug 456244</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_end_bs(e) {
michael@0 27 const msg = "Deleting all text in contenteditable inline element";
michael@0 28 var before = e.parentNode.childNodes[0].nodeValue;
michael@0 29 sendKey("right");
michael@0 30 sendKey("back_space");
michael@0 31 sendKey("back_space");
michael@0 32 is(e.parentNode.childNodes[0].nodeValue, before, msg + " with id=" + e.id);
michael@0 33 is(e.innerHTML, "", msg + " with id=" + e.id);
michael@0 34 }
michael@0 35
michael@0 36 test_end_bs(select("t1"));
michael@0 37 test_end_bs(setupIframe('i1',0));
michael@0 38
michael@0 39 {
michael@0 40 const msg = "Deleting all text in contenteditable body element";
michael@0 41 var e = document.getElementById('i2');
michael@0 42 var doc = e.contentDocument;
michael@0 43 doc.body.setAttribute("contenteditable", "true");
michael@0 44 doc.body.focus();
michael@0 45 sendKey("right");
michael@0 46 sendKey("back_space");
michael@0 47 is(doc.body.innerHTML, "<br>", msg + " with id=" + e.id);
michael@0 48 }
michael@0 49
michael@0 50 SimpleTest.finish();
michael@0 51 }
michael@0 52
michael@0 53 SimpleTest.waitForExplicitFinish();
michael@0 54 addLoadEvent(runTest);
michael@0 55 </script>
michael@0 56 </head>
michael@0 57 <body>
michael@0 58 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=456244">Mozilla Bug 456244</a>
michael@0 59 <p id="display"></p>
michael@0 60
michael@0 61 <pre id="test">
michael@0 62 </pre>
michael@0 63
michael@0 64 <div> <span id="t1" style="border:1px solid blue" contenteditable="true">X</span> Y</div>
michael@0 65
michael@0 66 <iframe id="i1" width="200" height="100" src="about:blank"></iframe><br>
michael@0 67 <iframe id="i2" width="200" height="100" src="about:blank">X</iframe><br>
michael@0 68
michael@0 69 </body>
michael@0 70 </html>

mercurial