Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: third_party/WebKit/LayoutTests/editing/selection/move-by-character-brute-force.html

Issue 1809963002: [Editing][CodeHealth] Use w3c testharness in editing/seletion/move-by-* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698