1 description("Tests find for strings with soft hyphens 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 document.getElementById("console").style.display = "none";
17 var hyphen= String.fromCharCode(0x2010);
18 var softHyphen = String.fromCharCode(0x00AD);
20 shouldBe('canFind("ab", "a" + softHyphen + "b")', 'true');
21 shouldBe('canFind("ab", "a" + softHyphen + softHyphen + "b")', 'true');
22 shouldBe('canFind("a\u0300b", "a" + softHyphen + "b")', 'true');
23 shouldBe('canFind("ab", "a" + softHyphen + "\u0300b")', 'true');
24 shouldBe('canFind("ab", "a\u0300" + softHyphen + "b")', 'true');
25 shouldBe('canFind("a" + softHyphen + "b", "a" + softHyphen + "b")', 'true');
26 shouldBe('canFind("a" + softHyphen + "b", "ab")', 'true');
28 // Soft hyphen doesn't match hyphen and hyphen-minus.
29 shouldBe('canFind("a" + hyphen + "b", "a" + softHyphen + "b")', 'false');
30 shouldBe('canFind("a-b", "a" + softHyphen + "b")', 'false');
32 document.getElementById("console").style.removeProperty("display");