blob: b75b80ac3fc02c534d66fdd6ef73bb8aa883aae2 [file] [log] [blame]
<meta charset="UTF-8">
<script src="../../resources/js-test-pre.js"></script>
<div id="test"></div>
<script>
if (window.internals)
internals.setContinuousSpellCheckingEnabled(false); // For performance.
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="../../resources/js-test-post.js"></script>