1 <p id=
"description" style=
"display: none;">
2 Test for
<i><a href=
"https://bugs.webkit.org/show_bug.cgi?id=7023">https://bugs.webkit.org/show_bug.cgi?id=
7023</a> Searching in text areas
</i>.
5 Lorem ip
<textarea id=
"textarea">sum dolor si
</textarea>t amet
6 Lorem ip
<input id=
"input: text" type=
"text" value=
"sum dolor si">t amet
7 Lorem ip
<input id=
"input: search" type=
"search" value=
"sum dolor si">t amet
8 Lorem ip
<input id=
"input: password" type=
"password" value=
"sum dolor si">t amet
11 if (window
.testRunner
)
12 testRunner
.dumpAsText();
16 function textNodeIndex(node
)
19 while (node
= node
.previousSibling
) {
20 if (node
.nodeType
== Node
.TEXT_NODE
)
26 function clearSelection()
28 getSelection().selectAllChildren(document
.body
);
29 getSelection().empty();
32 function selectionLocationAsString()
34 if (document
.activeElement
.selectionStart
!= document
.activeElement
.selectionEnd
)
35 return document
.activeElement
.id
+ ", at offset " + document
.activeElement
.selectionStart
;
36 if (getSelection().rangeCount
== 0)
38 var range
= getSelection().getRangeAt(0);
39 return "outer text node " + textNodeIndex(range
.startContainer
) + ", at offset " + range
.startOffset
;
42 function findAll(target
)
44 var sel
= getSelection();
48 document
.execCommand("FindString", false, target
);
50 var firstMatch
= selectionLocationAsString();
51 if (firstMatch
== "") {
52 result
+= "Target " + target
+ " not matched\n";
56 result
+= "Target " + target
+ " matched at:\n " + firstMatch
+ "\n";
58 document
.execCommand("FindString", false, target
);
59 var match
= selectionLocationAsString();
60 while (match
!== firstMatch
) {
61 result
+= " " + match
+ "\n";
62 document
.execCommand("FindString", false, target
);
63 match
= selectionLocationAsString();
77 document
.body
.appendChild(document
.createElement("pre")).appendChild(document
.createTextNode(result
));
78 document
.getElementById("description").style
.display
= "";