blob: 4b358929df5e9ac446c911571b860b43ea5fe5d7 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title> Testcase for bug crbug.com/242715 </title>
<script src="../../resources/js-test.js"></script>
<script>
function runTest() {
description('This test ensures WebKit clears IME composition inside an input element \
when the value is programmatically set.');
var test = document.getElementById('test');
test.addEventListener('keyup', function(event) {
if (event.keyCode == 40)
test.value = 'henhao';
});
test.focus();
test.selectionStart = 0;
test.selectionEnd = 0;
textInputController.setMarkedText("nihao", 0, 5);
debug('nihao should marked from 0 to 5');
shouldBeTrue("textInputController.hasMarkedText()");
shouldBeEqualToString("textInputController.markedRange().toString()", "0,5");
test.value = '';
debug('text was removed so there should be no marked text');
shouldBeFalse("textInputController.hasMarkedText()");
textInputController.setMarkedText("nihao", 0, 5);
debug('nihao should marked from 0 to 5');
shouldBeTrue("textInputController.hasMarkedText()");
shouldBeEqualToString("textInputController.markedRange().toString()", "0,5");
eventSender.keyDown('ArrowDown');
debug('the text was changed so there should be no marked text');
shouldBeFalse("textInputController.hasMarkedText()");
document.body.removeChild(test);
isSuccessfullyParsed();
}
</script>
</body>
<body onload="runTest();">
<input id="test" type="text">
<div id="description"></div>
<div id="console"></div>
</body>
</html>