OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>InsertText behavior after paragraph selection</title> |
| 5 <script src="../../resources/js-test.js"></script> |
| 6 </head> |
| 7 <body> |
| 8 <script> |
| 9 description('If you select a paragraph and type a character, block style propert
ies should not be inherited to the next paragraph.'); |
| 10 |
| 11 var container = document.createElement('div'); |
| 12 container.contentEditable = true; |
| 13 container.style.margin = '1em'; |
| 14 container.style.padding = '1em'; |
| 15 container.style.border = '4px gray solid'; |
| 16 container.innerHTML = '<p><span>Foo</span></p><p style="text-indent: 3em;"><span
>Bar</span></p>'; |
| 17 // This block must be placed at the beginning of the document, otherwise the bug
does not reproduce. |
| 18 document.body.insertBefore(container, document.body.firstChild); |
| 19 |
| 20 function check() |
| 21 { |
| 22 shouldBeEqualToString('container.innerHTML', '<p style="text-indent: 3em;"><
span>aBar</span></p>'); |
| 23 } |
| 24 |
| 25 if (!window.testRunner) { |
| 26 window.jsTestIsAsync = true; |
| 27 var manualInstruction = document.createElement('p'); |
| 28 manualInstruction.innerHTML = '<strong>This test can\'t be run automatically
without testRunner. To run this test manually, triple-click the paragraph conta
ining "Foo", type "a", then press the "Finish" button: </strong>'; |
| 29 var finishButton = document.createElement('input'); |
| 30 finishButton.type = 'button'; |
| 31 finishButton.value = 'Finish'; |
| 32 finishButton.addEventListener('click', function () { |
| 33 check(); |
| 34 window.finishJSTest(); |
| 35 }); |
| 36 manualInstruction.appendChild(finishButton); |
| 37 document.body.appendChild(manualInstruction); |
| 38 } else { |
| 39 container.focus(); |
| 40 window.getSelection().collapse(container.firstChild.firstChild, 0); // First
<span>. |
| 41 |
| 42 window.testRunner.execCommand('SelectParagraph'); |
| 43 document.execCommand('InsertText', false, 'a'); |
| 44 |
| 45 check(); |
| 46 |
| 47 document.body.removeChild(container); |
| 48 } |
| 49 </script> |
| 50 </body> |
| 51 </html> |
OLD | NEW |