OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/testharness.js"></script> |
| 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <meta charset="UTF-8"> |
| 5 <div id="sample"></div> |
| 6 <div id="log"></div> |
| 7 <script> |
| 8 test(function(){ |
| 9 function hasSimpleCaretMovement(charCode) { |
| 10 var testString = "aaaaa" + String.fromCharCode(charCode) + "bbbb"; |
| 11 sample.textContent = testString; |
| 12 var selection = window.getSelection(); |
| 13 selection.collapse(sample, 0); |
| 14 for (var i = 0; i < testString.length; ++i) { |
| 15 selection.modify("move", "forward", "character"); |
| 16 if (selection.baseOffset != i + 1) |
| 17 return false; |
| 18 } |
| 19 return true; |
| 20 } |
| 21 |
| 22 function toHex(i) { |
| 23 var hex = i.toString(16); |
| 24 while (hex.length < 4) |
| 25 hex = "0" + hex; |
| 26 return hex; |
| 27 } |
| 28 |
| 29 |
| 30 assert_true(hasSimpleCaretMovement(0x0041)); |
| 31 |
| 32 assert_false(hasSimpleCaretMovement(0x0300)); |
| 33 |
| 34 for (var i = 1; i < 1024; ++i) { |
| 35 if (i >= 0x0300 && i <= 0x036F) |
| 36 assert_false(hasSimpleCaretMovement(i)); |
| 37 else |
| 38 assert_true(hasSimpleCaretMovement(i)); |
| 39 } |
| 40 }, "This test checks that we have simple caret motion up to a certain limit"); |
| 41 </script> |
OLD | NEW |