1 description("Tests find for strings with Russian letters й and ё in them.");
3 function canFind(target, specimen)
5 getSelection().empty();
6 var textNode = document.createTextNode(specimen);
7 document.body.appendChild(textNode);
8 document.execCommand("FindString", false, target);
9 var result = getSelection().rangeCount != 0;
10 getSelection().empty();
11 document.body.removeChild(textNode);
15 var letterCyrillicI = String.fromCharCode(0x0418);
16 var letterCyrillicSmallI = String.fromCharCode(0x0438);
17 var letterCyrillicShortI = String.fromCharCode(0x0419);
18 var letterCyrillicSmallShortI = String.fromCharCode(0x0439);
19 var letterCyrillicE = String.fromCharCode(0x0415);
20 var letterCyrillicSmallE = String.fromCharCode(0x0435);
21 var letterCyrillicYO = String.fromCharCode(0x0401);
22 var letterCyrillicSmallYO = String.fromCharCode(0x0451);
23 var combiningDiaeresis = String.fromCharCode(0x0308);
24 var combiningBreve = String.fromCharCode(0x0306);
26 var decomposedCyrillicShortI = letterCyrillicI + combiningBreve;
27 var decomposedCyrillicSmallShortI = letterCyrillicSmallI + combiningBreve;
28 var decomposedCyrillicYO = letterCyrillicE + combiningDiaeresis;
29 var decomposedCyrillicSmallYO = letterCyrillicSmallE + combiningDiaeresis;
31 debug('Exact matches first as a baseline');
34 shouldBe('canFind(decomposedCyrillicShortI, decomposedCyrillicShortI)', 'true');
35 shouldBe('canFind(decomposedCyrillicSmallShortI, decomposedCyrillicSmallShortI)', 'true');
36 shouldBe('canFind(letterCyrillicShortI, letterCyrillicShortI)', 'true');
37 shouldBe('canFind(letterCyrillicSmallShortI, letterCyrillicSmallShortI)', 'true');
38 shouldBe('canFind("й", "йод")', 'true');
39 shouldBe('canFind("ё", "мумиё")', 'true');
43 debug('Composed and decomposed forms: Must be treated as equal');
46 shouldBe('canFind(decomposedCyrillicYO, decomposedCyrillicYO)', 'true');
47 shouldBe('canFind(decomposedCyrillicSmallYO, decomposedCyrillicSmallYO)', 'true');
48 shouldBe('canFind(letterCyrillicShortI, decomposedCyrillicShortI)', 'true');
49 shouldBe('canFind(letterCyrillicSmallShortI, decomposedCyrillicSmallShortI)', 'true');
50 shouldBe('canFind(letterCyrillicYO, decomposedCyrillicYO)', 'true');
51 shouldBe('canFind(letterCyrillicSmallYO, decomposedCyrillicSmallYO)', 'true');
52 shouldBe('canFind(decomposedCyrillicShortI, letterCyrillicShortI)', 'true');
53 shouldBe('canFind(decomposedCyrillicSmallShortI, letterCyrillicSmallShortI)', 'true');
54 shouldBe('canFind(decomposedCyrillicYO, letterCyrillicYO)', 'true');
55 shouldBe('canFind(decomposedCyrillicSmallYO, letterCyrillicSmallYO)', 'true');
58 debug('Small and capital letters: Must be treated as equal');
61 shouldBe('canFind(letterCyrillicSmallI, letterCyrillicI)', 'true');
62 shouldBe('canFind(letterCyrillicSmallYO, letterCyrillicYO)', 'true');
63 shouldBe('canFind(letterCyrillicI, letterCyrillicSmallI)', 'true');
64 shouldBe('canFind(letterCyrillicYO, letterCyrillicSmallYO)', 'true');
65 shouldBe('canFind(decomposedCyrillicSmallShortI, letterCyrillicI)', 'true');
66 shouldBe('canFind(decomposedCyrillicSmallYO, letterCyrillicYO)', 'true');
67 shouldBe('canFind(decomposedCyrillicShortI, letterCyrillicSmallI)', 'true');
68 shouldBe('canFind(decomposedCyrillicYO, letterCyrillicSmallYO)', 'true');
69 shouldBe('canFind(letterCyrillicSmallI + letterCyrillicSmallYO, letterCyrillicSmallI + letterCyrillicYO)', 'true');
70 shouldBe('canFind("й", "Йод")', 'true');
71 shouldBe('canFind("ё", "МУМИЁ")', 'true');
72 shouldBe('canFind("Й", "йод")', 'true');
73 shouldBe('canFind("Ё", "мумиё")', 'true');
76 debug('Е and Ё: Must be treated as equal');
79 shouldBe('canFind("мумие", "мумиё")', 'true');
80 shouldBe('canFind("МУМИЕ", "МУМИЁ")', 'true');
81 shouldBe('canFind("мумиё", "мумие")', 'true');
82 shouldBe('canFind("МУМИЁ", "МУМИЕ")', 'true');
85 debug('Й and и: Must *not* be treated as equal');
88 shouldBe('canFind("зайка", "заика")', 'false');
89 shouldBe('canFind("заика", "зайка")', 'false');