blob: 1f80226ddbc7bea62d4e721debb59d2f29f5f4ca [file] [log] [blame]
<meta charset="UTF-8">
<script src="../../fast/js/resources/js-test-pre.js"></script>
<div id="test"></div>
<script>
description("This test checks that we have simple caret motion up to a certain limit");
function hasSimpleCaretMovement(charCode) {
var testString = "aaaaa" + String.fromCharCode(charCode) + "bbbb";
element.textContent = testString;
var selection = window.getSelection();
selection.setPosition(element, 0);
for (var i = 0; i < testString.length; ++i) {
selection.modify("move", "forward", "character");
if (selection.baseOffset != i + 1)
return false;
}
return true;
}
function toHex(i) {
var hex = i.toString(16);
while (hex.length < 4)
hex = "0" + hex;
return hex;
}
var element = document.getElementById("test");
debug("Positive control:");
shouldBeTrue("hasSimpleCaretMovement(0x0041)");
debug("");
debug("Negative control:");
shouldBeFalse("hasSimpleCaretMovement(0x0300)");
debug("");
debug("Brute force:");
for (var i = 1; i < 1024; ++i) {
if (i >= 0x0300 && i <= 0x036F)
shouldBeFalse("hasSimpleCaretMovement(i) // i = U+" + toHex(i));
else
shouldBeTrue("hasSimpleCaretMovement(i) // i = U+" + toHex(i));
}
element.textContent = "";
</script>
<script src="../../fast/js/resources/js-test-post.js"></script>