Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / selection / move-by-character-brute-force.html
blobc2acd65c200cb5d7f083ebf428033e8006a35e2b
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 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)
15 return false;
17 return true;
20 function toHex(i) {
21 var hex = i.toString(16);
22 while (hex.length < 4)
23 hex = "0" + hex;
24 return hex;
27 var element = document.getElementById("test");
29 debug("Positive control:");
30 shouldBeTrue("hasSimpleCaretMovement(0x0041)");
31 debug("");
33 debug("Negative control:");
34 shouldBeFalse("hasSimpleCaretMovement(0x0300)");
35 debug("");
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));
45 element.textContent = "";
46 </script>