Chromium Code Reviews| 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 var range = new Range(); | |
| 41 range.setStart(container.firstChild.firstChild, 0); // First <span>. | |
|
yosin_UTC9
2014/03/27 07:01:05
nit: You can use Selection.collapse(parentNode, of
Yuta Kitamura
2014/03/27 07:12:35
That's much better, thanks. Fixed.
| |
| 42 range.setEnd(container.firstChild.firstChild, 0); | |
| 43 var selection = window.getSelection(); | |
| 44 selection.removeAllRanges(); | |
| 45 selection.addRange(range); | |
| 46 | |
| 47 window.testRunner.execCommand('SelectParagraph'); | |
| 48 document.execCommand('InsertText', false, 'a'); | |
| 49 | |
| 50 check(); | |
| 51 | |
| 52 document.body.removeChild(container); | |
| 53 } | |
| 54 </script> | |
| 55 </body> | |
| 56 </html> | |
| OLD | NEW |