Chromium Code Reviews| Index: LayoutTests/editing/execCommand/insert-text-not-inheriting-block-properties.html |
| diff --git a/LayoutTests/editing/execCommand/insert-text-not-inheriting-block-properties.html b/LayoutTests/editing/execCommand/insert-text-not-inheriting-block-properties.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..055289608aee703dc6387acffcbdc7d441e74b14 |
| --- /dev/null |
| +++ b/LayoutTests/editing/execCommand/insert-text-not-inheriting-block-properties.html |
| @@ -0,0 +1,56 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| +<title>InsertText behavior after paragraph selection</title> |
| +<script src="../../resources/js-test.js"></script> |
| +</head> |
| +<body> |
| +<script> |
| +description('If you select a paragraph and type a character, block style properties should not be inherited to the next paragraph.'); |
| + |
| +var container = document.createElement('div'); |
| +container.contentEditable = true; |
| +container.style.margin = '1em'; |
| +container.style.padding = '1em'; |
| +container.style.border = '4px gray solid'; |
| +container.innerHTML = '<p><span>Foo</span></p><p style="text-indent: 3em;"><span>Bar</span></p>'; |
| +// This block must be placed at the beginning of the document, otherwise the bug does not reproduce. |
| +document.body.insertBefore(container, document.body.firstChild); |
| + |
| +function check() |
| +{ |
| + shouldBeEqualToString('container.innerHTML', '<p style="text-indent: 3em;"><span>aBar</span></p>'); |
| +} |
| + |
| +if (!window.testRunner) { |
| + window.jsTestIsAsync = true; |
| + var manualInstruction = document.createElement('p'); |
| + manualInstruction.innerHTML = '<strong>This test can\'t be run automatically without testRunner. To run this test manually, triple-click the paragraph containing "Foo", type "a", then press the "Finish" button: </strong>'; |
| + var finishButton = document.createElement('input'); |
| + finishButton.type = 'button'; |
| + finishButton.value = 'Finish'; |
| + finishButton.addEventListener('click', function () { |
| + check(); |
| + window.finishJSTest(); |
| + }); |
| + manualInstruction.appendChild(finishButton); |
| + document.body.appendChild(manualInstruction); |
| +} else { |
| + container.focus(); |
| + var range = new Range(); |
| + 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.
|
| + range.setEnd(container.firstChild.firstChild, 0); |
| + var selection = window.getSelection(); |
| + selection.removeAllRanges(); |
| + selection.addRange(range); |
| + |
| + window.testRunner.execCommand('SelectParagraph'); |
| + document.execCommand('InsertText', false, 'a'); |
| + |
| + check(); |
| + |
| + document.body.removeChild(container); |
| +} |
| +</script> |
| +</body> |
| +</html> |