1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
<html>
<head>
<script>
function canFind(target, specimen)
{
getSelection().empty();
document.body.innerHTML = specimen;
document.execCommand("FindString", false, target);
var result = getSelection().rangeCount != 0;
getSelection().empty();
return result;
}
function runTests()
{
if (window.layoutTestController)
layoutTestController.dumpAsText();
var success = true;
var nbsp = String.fromCharCode(0xA0);
var message = "FAILURE:";
if (canFind("", "a b")) {
success = false;
message += " Was able to find the empty string.";
}
if (!canFind(" ", "a b")) {
success = false;
message += " Cannot find space.";
}
if (canFind(" ", "a b")) {
success = false;
message += " Two spaces are matching even though they should be collapsed.";
}
if (!canFind(" ", "<pre>a b</pre>")) {
success = false;
message += " Cannot find two spaces in a <pre> element.";
}
if (!canFind(" ", "a b")) {
success = false;
message += " Cannot find an &nbsp; when searching for a space.";
}
if (!canFind(" ", "a b")) {
success = false;
message += " Cannot find a space followed by &nbsp; when searching for two spaces.";
}
if (!canFind(" ", "a b")) {
success = false;
message += " Cannot find an &nbsp; followed by a space when searching for two spaces.";
}
if (!canFind(nbsp, "a b")) {
success = false;
message += " Cannot find space.";
}
if (canFind(nbsp + nbsp, "a b")) {
success = false;
message += " Two spaces are matching even though they should be collapsed.";
}
if (!canFind(nbsp + nbsp, "<pre>a b</pre>")) {
success = false;
message += " Cannot find two spaces in a <pre> element.";
}
if (!canFind(nbsp, "a b")) {
success = false;
message += " Cannot find an &nbsp; when searching for a space.";
}
if (!canFind(nbsp + nbsp, "a b")) {
success = false;
message += " Cannot find a space followed by &nbsp; when searching for two spaces.";
}
if (!canFind(nbsp + nbsp, "a b")) {
success = false;
message += " Cannot find an &nbsp; followed by a space when searching for two spaces.";
}
if (success)
message = "SUCCESS: Found all the spaces as expected.";
document.body.innerHTML = message;
}
</script>
</head>
<body onload="runTests()"></body>
</html>
|