OLD | NEW |
1 <meta charset="utf-8"> | 1 <meta charset="utf-8"> |
2 <div id="container"></div> | 2 <div id="container"></div> |
3 <pre id="console" style="visibility: hidden;"></pre> | 3 <pre id="console" style="visibility: hidden;"></pre> |
4 <script> | 4 <script> |
5 function log(message) | 5 function log(message) |
6 { | 6 { |
7 document.getElementById("console").appendChild(document.createTextNode(m
essage + "\n")); | 7 document.getElementById("console").appendChild(document.createTextNode(m
essage + "\n")); |
8 } | 8 } |
9 | 9 |
10 function testFindString(text, target, options, expectedRanges) | 10 function testFindString(text, target, options, expectedRanges) |
(...skipping 27 matching lines...) Expand all Loading... |
38 testRunner.dumpAsText(); | 38 testRunner.dumpAsText(); |
39 | 39 |
40 testFindString("Lorem ipsum dolor sit amet", "o", [], [[1, 2], [13, 14], [15
, 16], []]); | 40 testFindString("Lorem ipsum dolor sit amet", "o", [], [[1, 2], [13, 14], [15
, 16], []]); |
41 testFindString("Lorem ipsum dolor sit amet", "o", ["WrapAround"], [[1, 2], [
13, 14], [15, 16], [1, 2]]); | 41 testFindString("Lorem ipsum dolor sit amet", "o", ["WrapAround"], [[1, 2], [
13, 14], [15, 16], [1, 2]]); |
42 testFindString("Lorem ipsum dolor sit amet", "o", ["Backwards"], [[15, 16],
[13, 14], [1, 2], []]); | 42 testFindString("Lorem ipsum dolor sit amet", "o", ["Backwards"], [[15, 16],
[13, 14], [1, 2], []]); |
43 testFindString("Lorem ipsum dolor sit amet", "o", ["Backwards", "WrapAround"
], [[15, 16], [13, 14], [1, 2], [15, 16]]); | 43 testFindString("Lorem ipsum dolor sit amet", "o", ["Backwards", "WrapAround"
], [[15, 16], [13, 14], [1, 2], [15, 16]]); |
44 testFindString("Lorem ipsum dolor sit amet", "O", [], [[]]); | 44 testFindString("Lorem ipsum dolor sit amet", "O", [], [[]]); |
45 testFindString("Lorem ipsum dolor sit amet", "O", ["CaseInsensitive"], [[1,
2], [13, 14], [15, 16]]); | 45 testFindString("Lorem ipsum dolor sit amet", "O", ["CaseInsensitive"], [[1,
2], [13, 14], [15, 16]]); |
46 | 46 |
47 testFindString("insurmountable mountain", "mount", [], [[5, 10], [15, 20], [
]]); | 47 testFindString("insurmountable mountain", "mount", [], [[5, 10], [15, 20], [
]]); |
48 testFindString("insurmountable mountain", "mount", ["AtWordStarts"], [[15, 2
0], []]); | 48 testFindString("insurmountable mountain", "mount", ["AtWordStarts"], [[5, 10
], [15, 20]]); |
49 | 49 |
50 testFindString("cocoa", "co", [], [[0, 2], [2, 4], []]); | 50 testFindString("cocoa", "co", [], [[0, 2], [2, 4], []]); |
51 testFindString("cocoa", "co", ["AtWordStarts"], [[0, 2], []]); | 51 testFindString("cocoa", "co", ["AtWordStarts"], [[0, 2], []]); |
52 | 52 |
53 testFindString("webkit.org", "org", ["AtWordStarts"], [[]]); | 53 testFindString("webkit.org", "org", ["AtWordStarts"], [[7, 10]]); |
54 testFindString("webkit.org", ".org", ["AtWordStarts"], [[6, 10], []]); | 54 testFindString("webkit.org", ".org", ["AtWordStarts"], [[6, 10], []]); |
55 | 55 |
56 testFindString("webkit.org", "rg", ["AtWordStarts", "TreatMedialCapitalAsWor
dStart"], [[]]); | 56 testFindString("webkit.org", "rg", ["AtWordStarts", "TreatMedialCapitalAsWor
dStart"], [[8, 10]]); |
57 testFindString("webkit.org", "org", ["AtWordStarts", "TreatMedialCapitalAsWo
rdStart"], [[7, 10], []]); | 57 testFindString("webkit.org", "org", ["AtWordStarts", "TreatMedialCapitalAsWo
rdStart"], [[7, 10], []]); |
58 testFindString("webkit.org", ".org", ["AtWordStarts", "TreatMedialCapitalAsW
ordStart"], [[6, 10], []]); | 58 testFindString("webkit.org", ".org", ["AtWordStarts", "TreatMedialCapitalAsW
ordStart"], [[6, 10], []]); |
59 testFindString("webkit.org", "t.org", ["AtWordStarts", "TreatMedialCapitalAs
WordStart"], [[]]); | 59 testFindString("webkit.org", "t.org", ["AtWordStarts", "TreatMedialCapitalAs
WordStart"], [[5, 10]]); |
60 | 60 |
61 testFindString("WebKit", "it", ["AtWordStarts", "TreatMedialCapitalAsWordSta
rt"], [[]]); | 61 testFindString("WebKit", "it", ["AtWordStarts", "TreatMedialCapitalAsWordSta
rt"], [[4, 6]]); |
62 testFindString("WebKit", "Kit", ["AtWordStarts", "TreatMedialCapitalAsWordSt
art"], [[3, 6], []]); | 62 testFindString("WebKit", "Kit", ["AtWordStarts", "TreatMedialCapitalAsWordSt
art"], [[3, 6], []]); |
63 testFindString("WebKit", "bKit", ["AtWordStarts", "TreatMedialCapitalAsWordS
tart"], [[]]); | 63 testFindString("WebKit", "bKit", ["AtWordStarts", "TreatMedialCapitalAsWordS
tart"], [[2, 6]]); |
64 | 64 |
65 testFindString("XMLHTTPRequest", "equest", ["AtWordStarts", "TreatMedialCapi
talAsWordStart"], [[]]); | 65 testFindString("XMLHTTPRequest", "equest", ["AtWordStarts", "TreatMedialCapi
talAsWordStart"], [[8, 14]]); |
66 testFindString("XMLHTTPRequest", "Request", ["AtWordStarts", "TreatMedialCap
italAsWordStart"], [[7, 14], []]); | 66 testFindString("XMLHTTPRequest", "Request", ["AtWordStarts", "TreatMedialCap
italAsWordStart"], [[7, 14], []]); |
67 testFindString("XMLHTTPRequest", "PRequest", ["AtWordStarts", "TreatMedialCa
pitalAsWordStart"], [[]]); | 67 testFindString("XMLHTTPRequest", "PRequest", ["AtWordStarts", "TreatMedialCa
pitalAsWordStart"], [[6, 14]]); |
68 | 68 |
69 testFindString("LP64", "64", ["AtWordStarts"], [[]]); | 69 testFindString("LP64", "64", ["AtWordStarts"], [[2, 4]]); |
70 testFindString("LP64", "4", ["AtWordStarts", "TreatMedialCapitalAsWordStart"
], [[]]); | 70 testFindString("LP64", "4", ["AtWordStarts", "TreatMedialCapitalAsWordStart"
], [[3, 4]]); |
71 testFindString("LP64", "64", ["AtWordStarts", "TreatMedialCapitalAsWordStart
"], [[2, 4], []]); | 71 testFindString("LP64", "64", ["AtWordStarts", "TreatMedialCapitalAsWordStart
"], [[2, 4], []]); |
72 testFindString("LP64", "P64", ["AtWordStarts", "TreatMedialCapitalAsWordStar
t"], [[]]); | 72 testFindString("LP64", "P64", ["AtWordStarts", "TreatMedialCapitalAsWordStar
t"], [[1, 4]]); |
73 | 73 |
74 testFindString("\u8d77\u52d5\u6226\u58eb", "\u52d5\u6226\u58eb", ["AtWordSta
rts"], [[1, 4], []]); | 74 testFindString("\u8d77\u52d5\u6226\u58eb", "\u52d5\u6226\u58eb", ["AtWordSta
rts"], [[1, 4], []]); |
75 testFindString("\u8d77\u52d5\u6226\u58eb", "\u6226\u58eb", ["AtWordStarts"],
[[2, 4], []]); | 75 testFindString("\u8d77\u52d5\u6226\u58eb", "\u6226\u58eb", ["AtWordStarts"],
[[2, 4], []]); |
76 testFindString("\u8d77\u52d5\u6226\u58eb", "\u58eb", ["AtWordStarts"], [[3,
4], []]); | 76 testFindString("\u8d77\u52d5\u6226\u58eb", "\u58eb", ["AtWordStarts"], [[3,
4], []]); |
77 | 77 |
78 const searchBufferSize = 8192; | 78 const searchBufferSize = 8192; |
79 const searchBufferOverlapSize = searchBufferSize / 4; | 79 const searchBufferOverlapSize = searchBufferSize / 4; |
80 const searchBufferUnoverlappedSize = searchBufferSize - searchBufferOverlapS
ize; | 80 const searchBufferUnoverlappedSize = searchBufferSize - searchBufferOverlapS
ize; |
81 var bufferSizedString = "X"; | 81 var bufferSizedString = "X"; |
82 while (bufferSizedString.length < searchBufferSize) | 82 while (bufferSizedString.length < searchBufferSize) |
83 bufferSizedString += bufferSizedString; | 83 bufferSizedString += bufferSizedString; |
84 bufferSizedString = bufferSizedString.substring(0, searchBufferSize); | 84 bufferSizedString = bufferSizedString.substring(0, searchBufferSize); |
85 | 85 |
86 testFindString(bufferSizedString.substring(0, searchBufferUnoverlappedSize -
2) + " ba a" + bufferSizedString, "a", ["AtWordStarts"], [[searchBufferUnoverla
ppedSize + 2, searchBufferUnoverlappedSize + 3], []]); | 86 testFindString(bufferSizedString.substring(0, searchBufferUnoverlappedSize -
2) + " ba a" + bufferSizedString, "a", ["AtWordStarts"], [[searchBufferUnoverla
ppedSize, searchBufferUnoverlappedSize + 1], [searchBufferUnoverlappedSize +2, s
earchBufferUnoverlappedSize + 3]]); |
87 | 87 |
88 var thaiWords = [ | 88 var thaiWords = [ |
89 "\u0e01\u0e23", | 89 "\u0e01\u0e23", |
90 "\u0e1b\u0e39\u0e40\u0e25", | 90 "\u0e1b\u0e39\u0e40\u0e25", |
91 "\u0e01\u0e0a", | 91 "\u0e01\u0e0a", |
92 "\u0e01\u0e0a\u0e01\u0e23", // thaiWords[2] + thaiWords[0] | 92 "\u0e01\u0e0a\u0e01\u0e23", // thaiWords[2] + thaiWords[0] |
93 "\u0e01\u0e23\u0e01\u0e0a", // thaiWords[0] + thaiWords[2] | 93 "\u0e01\u0e23\u0e01\u0e0a", // thaiWords[0] + thaiWords[2] |
94 "\u0e1a\u0e07\u0e01\u0e0a", // ends with thaiWords[2] | 94 "\u0e1a\u0e07\u0e01\u0e0a", // ends with thaiWords[2] |
95 ]; | 95 ]; |
96 | 96 |
97 testFindString(thaiWords.join(""), thaiWords[0], [], [[0, 2], [10, 12], [12,
14], []]); | 97 testFindString(thaiWords.join(""), thaiWords[0], [], [[0, 2], [10, 12], [12,
14], []]); |
98 testFindString(thaiWords.join(""), thaiWords[0], ["AtWordStarts"], [[0, 2],
[12, 14], []]); | 98 testFindString(thaiWords.join(""), thaiWords[0], ["AtWordStarts"], [[0, 2],
[12, 14], []]); |
99 | 99 |
100 testFindString(thaiWords.join(""), thaiWords[2], [], [[6, 8], [8, 10], [14,
16], [18, 20], []]); | 100 testFindString(thaiWords.join(""), thaiWords[2], [], [[6, 8], [8, 10], [14,
16], [18, 20], []]); |
101 testFindString(thaiWords.join(""), thaiWords[2], ["AtWordStarts"], [[6, 8],
[8, 10], []]); | 101 testFindString(thaiWords.join(""), thaiWords[2], ["AtWordStarts"], [[6, 8],
[8, 10], []]); |
102 | 102 |
103 testFindString(bufferSizedString.substring(0, searchBufferUnoverlappedSize)
+ thaiWords.join("") + bufferSizedString, thaiWords[0], [], [[searchBufferUnover
lappedSize, searchBufferUnoverlappedSize + 2], [searchBufferUnoverlappedSize + 1
0, searchBufferUnoverlappedSize + 12], [searchBufferUnoverlappedSize + 12, searc
hBufferUnoverlappedSize + 14], []]); | 103 testFindString(bufferSizedString.substring(0, searchBufferUnoverlappedSize)
+ thaiWords.join("") + bufferSizedString, thaiWords[0], [], [[searchBufferUnover
lappedSize, searchBufferUnoverlappedSize + 2], [searchBufferUnoverlappedSize + 1
0, searchBufferUnoverlappedSize + 12], [searchBufferUnoverlappedSize + 12, searc
hBufferUnoverlappedSize + 14], []]); |
104 testFindString(bufferSizedString.substring(0, searchBufferUnoverlappedSize)
+ thaiWords.join("") + bufferSizedString, thaiWords[0], ["AtWordStarts"], [[sear
chBufferUnoverlappedSize + 12, searchBufferUnoverlappedSize + 14], []]); | 104 testFindString(bufferSizedString.substring(0, searchBufferUnoverlappedSize)
+ thaiWords.join("") + bufferSizedString, thaiWords[0], ["AtWordStarts"], [[sear
chBufferUnoverlappedSize, searchBufferUnoverlappedSize + 2], [searchBufferUnover
lappedSize + 10, searchBufferUnoverlappedSize + 12]]); |
105 testFindString(bufferSizedString.substring(0, searchBufferUnoverlappedSize -
1) + " " + thaiWords.join("") + bufferSizedString, thaiWords[0], ["AtWordStarts
"], [[searchBufferUnoverlappedSize, searchBufferUnoverlappedSize + 2], [searchBu
fferUnoverlappedSize + 12, searchBufferUnoverlappedSize + 14], []]); | 105 testFindString(bufferSizedString.substring(0, searchBufferUnoverlappedSize -
1) + " " + thaiWords.join("") + bufferSizedString, thaiWords[0], ["AtWordStarts
"], [[searchBufferUnoverlappedSize, searchBufferUnoverlappedSize + 2], [searchBu
fferUnoverlappedSize + 12, searchBufferUnoverlappedSize + 14], []]); |
106 testFindString(bufferSizedString.substring(0, searchBufferUnoverlappedSize -
3) + " " + thaiWords[4] + bufferSizedString, thaiWords[2], ["AtWordStarts"], [[
]]); | 106 testFindString(bufferSizedString.substring(0, searchBufferUnoverlappedSize -
3) + " " + thaiWords[4] + bufferSizedString, thaiWords[2], ["AtWordStarts"], [[
searchBufferUnoverlappedSize, searchBufferUnoverlappedSize + 2]]); |
107 | 107 |
108 testFindString("Spaces, the final frontier", " ", ["AtWordStarts"], [[7, 8],
[11, 12], [17, 18], []]); | 108 testFindString("Spaces, the final frontier", " ", ["AtWordStarts"], [[7, 8],
[11, 12], [17, 18], []]); |
109 testFindString("Use an @import rule", "@", ["AtWordStarts"], [[7, 8], []]); | 109 testFindString("Use an @import rule", "@", ["AtWordStarts"], [[7, 8], []]); |
110 testFindString("If ((x + 5) * 2) = 14, then x = 2", "(x", ["AtWordStarts"],
[[4, 6], []]); | 110 testFindString("If ((x + 5) * 2) = 14, then x = 2", "(x", ["AtWordStarts"],
[[4, 6], []]); |
111 | 111 |
112 document.getElementById("console").style.removeProperty("visibility"); | 112 document.getElementById("console").style.removeProperty("visibility"); |
113 </script> | 113 </script> |
OLD | NEW |