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