4 function canFind(target
, specimen
)
6 getSelection().empty();
7 document
.body
.innerHTML
= specimen
;
8 document
.execCommand("FindString", false, target
);
9 var result
= getSelection().rangeCount
!= 0;
10 getSelection().empty();
15 var hebrewPunctuationGeresh
= String
.fromCharCode(0x05F3);
16 var hebrewPunctuationGershayim
= String
.fromCharCode(0x05F4);
17 var leftDoubleQuotationMark
= String
.fromCharCode(0x201C);
18 var leftSingleQuotationMark
= String
.fromCharCode(0x2018);
19 var quotationMark
= '"';
20 var rightDoubleQuotationMark
= String
.fromCharCode(0x201D);
21 var rightSingleQuotationMark
= String
.fromCharCode(0x2019);
25 var message
= "FAILURE:";
27 function testFindExpectingSuccess(targetName
, specimenName
)
29 var target
= eval(targetName
);
30 var specimen
= eval(specimenName
);
31 if (canFind(target
, specimen
))
34 message
+= " Cannot find " + specimenName
+ " when searching for " + targetName
+ ".";
37 function testFindExpectingFailure(targetName
, specimenName
)
39 var target
= eval(targetName
);
40 var specimen
= eval(specimenName
);
41 if (!canFind(target
, specimen
))
44 message
+= " Found " + specimenName
+ " when searching for " + targetName
+ ".";
49 if (window
.testRunner
)
50 testRunner
.dumpAsText();
52 var singleQuotes
= [ "apostrophe", "hebrewPunctuationGeresh", "leftSingleQuotationMark", "rightSingleQuotationMark" ];
53 var doubleQuotes
= [ "quotationMark", "hebrewPunctuationGershayim", "leftDoubleQuotationMark", "rightDoubleQuotationMark" ];
55 for (var i
= 0; i
< singleQuotes
.length
; ++i
) {
56 for (var j
= 0; j
< singleQuotes
.length
; ++j
)
57 testFindExpectingSuccess(singleQuotes
[i
], singleQuotes
[j
]);
60 for (var i
= 0; i
< doubleQuotes
.length
; ++i
) {
61 for (var j
= 0; j
< doubleQuotes
.length
; ++j
)
62 testFindExpectingSuccess(doubleQuotes
[i
], doubleQuotes
[j
]);
65 for (var i
= 0; i
< singleQuotes
.length
; ++i
) {
66 for (var j
= 0; j
< doubleQuotes
.length
; ++j
)
67 testFindExpectingFailure(singleQuotes
[i
], doubleQuotes
[j
]);
70 for (var i
= 0; i
< doubleQuotes
.length
; ++i
) {
71 for (var j
= 0; j
< singleQuotes
.length
; ++j
)
72 testFindExpectingFailure(doubleQuotes
[i
], singleQuotes
[j
]);
76 message
= "SUCCESS: Found all the quotes as expected.";
78 document
.body
.innerHTML
= message
;
82 <body onload=
"runTests()"></body>