OLD | NEW |
| (Empty) |
1 <meta charset="UTF-8"> | |
2 <script src="../../resources/js-test.js"></script> | |
3 <div id="test"></div> | |
4 <script> | |
5 description("This test checks that we have simple caret motion up to a certain l
imit"); | |
6 | |
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) | |
15 return false; | |
16 } | |
17 return true; | |
18 } | |
19 | |
20 function toHex(i) { | |
21 var hex = i.toString(16); | |
22 while (hex.length < 4) | |
23 hex = "0" + hex; | |
24 return hex; | |
25 } | |
26 | |
27 var element = document.getElementById("test"); | |
28 | |
29 debug("Positive control:"); | |
30 shouldBeTrue("hasSimpleCaretMovement(0x0041)"); | |
31 debug(""); | |
32 | |
33 debug("Negative control:"); | |
34 shouldBeFalse("hasSimpleCaretMovement(0x0300)"); | |
35 debug(""); | |
36 | |
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)); | |
41 else | |
42 shouldBeTrue("hasSimpleCaretMovement(i) // i = U+" + toHex(i)); | |
43 } | |
44 | |
45 element.textContent = ""; | |
46 </script> | |
OLD | NEW |