|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=668599 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 668599</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <script type="text/javascript" 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=668599">Mozilla Bug 668599</a> |
|
14 <p id="display"></p> |
|
15 <div id="content"> |
|
16 <div id="test1"> |
|
17 block <span contenteditable>type here</span> block |
|
18 </div> |
|
19 <div id="test2"> |
|
20 <p contenteditable> |
|
21 block <span>type here</span> block |
|
22 </p> |
|
23 </div> |
|
24 </div> |
|
25 |
|
26 <pre id="test"> |
|
27 <script type="application/javascript"> |
|
28 |
|
29 /** Test for Bug 668599 **/ |
|
30 SimpleTest.waitForExplicitFinish(); |
|
31 SimpleTest.waitForFocus(runTests); |
|
32 |
|
33 function select(element) { |
|
34 // select the element text content |
|
35 var userSelection = window.getSelection(); |
|
36 window.getSelection().removeAllRanges(); |
|
37 var range = document.createRange(); |
|
38 range.setStart(element.firstChild, 0); |
|
39 range.setEnd(element.firstChild, element.textContent.length); |
|
40 userSelection.addRange(range); |
|
41 }; |
|
42 |
|
43 function runTests() { |
|
44 var span = document.querySelector("#test1 span"); |
|
45 |
|
46 // editable <span> => the <span> *content* should be deleted |
|
47 select(span); |
|
48 span.focus(); |
|
49 synthesizeKey("x", {}); |
|
50 is(span.textContent, "x", "The <span> content should have been replaced by 'x'."); |
|
51 |
|
52 // same thing, but using [Del] instead of typing some text |
|
53 document.execCommand("Undo", false, null); |
|
54 select(span); |
|
55 span.focus(); |
|
56 synthesizeKey("VK_DELETE", {}); |
|
57 is(span.textContent, "", "The <span> content should have been deleted."); |
|
58 |
|
59 // <span> in editable block => the <span> *element* should be deleted |
|
60 select(document.querySelector("#test2 span")); |
|
61 document.querySelector("#test2 [contenteditable]").focus(); |
|
62 synthesizeKey("VK_DELETE", {}); |
|
63 is(document.querySelector("#test2 span"), null, |
|
64 "The <span> element should have been deleted."); |
|
65 |
|
66 // done |
|
67 SimpleTest.finish(); |
|
68 } |
|
69 |
|
70 </script> |
|
71 </pre> |
|
72 </body> |
|
73 </html> |