blob: 232a836509548953a9a8e14680531d78895b3c50 [file] [log] [blame]
<!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();
window.getSelection().collapse(container.firstChild.firstChild, 0); // First <span>.
testRunner.execCommand('SelectParagraph');
document.execCommand('InsertText', false, 'a');
check();
document.body.removeChild(container);
}
</script>
</body>
</html>