2 <script src=
"../../resources/js-test.js"></script>
5 description("This test checks that we have simple caret motion up to a certain limit");
7 function hasSimpleCaretMovement(charCode
) {
8 var testString
= "aaaaa" + String
.fromCharCode(charCode
) + "bbbb";
9 element
.textContent
= testString
;
10 var selection
= window
.getSelection();
11 selection
.collapse(element
, 0);
12 for (var i
= 0; i
< testString
.length
; ++i
) {
13 selection
.modify("move", "forward", "character");
14 if (selection
.baseOffset
!= i
+ 1)
21 var hex
= i
.toString(16);
22 while (hex
.length
< 4)
27 var element
= document
.getElementById("test");
29 debug("Positive control:");
30 shouldBeTrue("hasSimpleCaretMovement(0x0041)");
33 debug("Negative control:");
34 shouldBeFalse("hasSimpleCaretMovement(0x0300)");
37 debug("Brute force:");
38 for (var i
= 1; i
< 1024; ++i
) {
39 if (i
>= 0x0300 && i
<= 0x036F)
40 shouldBeFalse("hasSimpleCaretMovement(i) // i = U+" + toHex(i
));
42 shouldBeTrue("hasSimpleCaretMovement(i) // i = U+" + toHex(i
));
45 element
.textContent
= "";