OLD | NEW |
1 <body contentEditable="true"> | 1 <body contentEditable="true"> |
2 <b id="bold">bold</b>regular text<br> | 2 <b id="bold">bold</b>regular text<br> |
3 </body> | 3 </body> |
4 <script src="../editing.js"></script> | 4 <script src="../editing.js"></script> |
5 <script> | 5 <script> |
6 if (window.testRunner) | 6 if (window.testRunner) |
7 testRunner.dumpAsText(); | 7 testRunner.dumpAsText(); |
8 | 8 |
9 function fail(msg) { | 9 function fail(msg) { |
10 console.log(msg); | 10 console.log(msg); |
11 throw msg; | 11 throw msg; |
12 } | 12 } |
13 | 13 |
14 // Inserting HTML over "regular text" shouldn't be in the bold tag. | 14 // Inserting HTML over "regular text" shouldn't be in the bold tag. |
15 var bold = document.getElementById("bold"); | 15 var bold = document.getElementById("bold"); |
16 var unboldText = bold.nextSibling; | 16 var unboldText = bold.nextSibling; |
17 execSetSelectionCommand(unboldText, 0, unboldText, unboldText.textContent.le
ngth); | 17 execSetSelectionCommand(unboldText, 0, unboldText, unboldText.textContent.le
ngth); |
18 document.execCommand("insertHTML", false, "<img id='img' src='../resources/a
be.png' /> not bold"); | 18 document.execCommand("insertHTML", false, "<img id='img' src='../resources/a
be.png' /> not bold"); |
19 | 19 |
20 // Verify that the image isn't in the bold tag. | 20 // Verify that the image isn't in the bold tag. |
21 var image = document.getElementById("img"); | 21 var image = document.getElementById("img"); |
22 if (image.previousSibling != bold) | 22 if (image.previousSibling != bold) |
23 fail("Image should be adjacent to the bold node."); | 23 fail("Image should be adjacent to the bold node."); |
24 | 24 |
25 // Now try inserting HTML over the image. | 25 // Now try inserting HTML over the image. |
26 execSetSelectionCommand(image, 0, image, 1); | 26 execSetSelectionCommand(image, 0, image, 0); |
27 document.execCommand("inserthtml", false, "<span id='red' style='color:red'>
red text</span>"); | 27 document.execCommand("inserthtml", false, "<span id='red' style='color:red'>
red text</span>"); |
28 | 28 |
29 // Verify that the red text isn't in the bold tag. | 29 // Verify that the red text isn't in the bold tag. |
30 var red = document.getElementById("red"); | 30 var red = document.getElementById("red"); |
31 if (red.previousSibling != bold) | 31 if (red.previousSibling != bold) |
32 fail("Red text should be adjacent to the bold node."); | 32 fail("Red text should be adjacent to the bold node."); |
33 | 33 |
34 // Replace text with SUCCESS. | 34 // Replace text with SUCCESS. |
35 document.body.innerHTML = "SUCCESS"; | 35 document.body.innerHTML = "SUCCESS"; |
36 </script> | 36 </script> |
OLD | NEW |