1 <body onload=
"runTest()">
2 <script src=
"../../resources/js-test.js"></script>
7 if (!window
.testRunner
)
10 var accessKeyModifiers
= ["altKey"];
11 if (navigator
.userAgent
.search(/\bMac OS X\b/) != -1)
12 accessKeyModifiers
= ["ctrlKey", "altKey"];
14 testRunner
.dumpEditingCallbacks();
15 testRunner
.dumpAsText();
17 shouldBe("first.selectionStart", "11");
18 shouldBe("first.selectionEnd", "18");
19 eventSender
.keyDown("\t");
20 shouldBe("first.selectionStart", "11");
21 shouldBe("first.selectionEnd", "18");
23 shouldBe("second.selectionStart", "11");
24 shouldBe("second.selectionEnd", "18");
25 eventSender
.keyDown("J", accessKeyModifiers
);
26 shouldBe("second.selectionStart", "11");
27 shouldBe("second.selectionEnd", "18");
29 shouldBe("third.selectionStart", "11");
30 shouldBe("third.selectionEnd", "18");
32 shouldBe("third.selectionStart", "11");
33 shouldBe("third.selectionEnd", "18");
35 shouldBe("fourth.selectionStart", "11");
36 shouldBe("fourth.selectionEnd", "18");
37 eventSender
.mouseMoveTo(fourth
.offsetLeft
+ 4, fourth
.offsetTop
+ 4);
38 eventSender
.mouseDown();
39 eventSender
.mouseUp();
40 shouldBe("fourth.selectionStart", "0");
41 shouldBe("fourth.selectionEnd", "0");
43 shouldBe("fifth.selectionStart", "11");
44 shouldBe("fifth.selectionEnd", "18");
45 var fifthLabel
= document
.getElementById("fifthLabel");
46 eventSender
.mouseMoveTo(fifthLabel
.offsetLeft
+ 4, fifthLabel
.offsetTop
+ 4);
47 eventSender
.mouseDown();
48 eventSender
.mouseUp();
49 shouldBe("fifth.selectionStart", "11");
50 shouldBe("fifth.selectionEnd", "18");
52 shouldBe("sixth.selectionStart", "11");
53 shouldBe("sixth.selectionEnd", "18");
54 eventSender
.keyDown("U", accessKeyModifiers
);
55 shouldBe("sixth.selectionStart", "11");
56 shouldBe("sixth.selectionEnd", "18");
58 shouldBe("seventh.selectionStart", "11");
59 shouldBe("seventh.selectionEnd", "18");
60 var seventLabel
= document
.getElementById("seventhLabel");
62 shouldBe("seventh.selectionStart", "11");
63 shouldBe("seventh.selectionEnd", "18");
65 shouldBe("eighth.selectionStart", "11");
66 shouldBe("eighth.selectionEnd", "18");
67 var eighthLegend
= document
.getElementById("eighthLegend");
69 shouldBe("eighth.selectionStart", "11");
70 shouldBe("eighth.selectionEnd", "18");
72 shouldBe("ninth.selectionStart", "11");
73 shouldBe("ninth.selectionEnd", "18");
74 eventSender
.keyDown("I", accessKeyModifiers
);
75 shouldBe("ninth.selectionStart", "11");
76 shouldBe("ninth.selectionEnd", "18");
81 <h2><textarea
> focus selection
</h2>
83 <p>This test checks whether the selection is restored, cleared, or set
84 to the full range when using different ways to focus a text
85 area. These results all match Mozilla. When running manually, please
86 follow the steps below. In the test harness, the test runs
89 1) Hit tab, only the word
"SUCCESS" should be selected:
90 <textarea id=
"first">FAILURE or SUCCESS
</textarea>
92 var first
= document
.getElementById("first");
94 first
.setSelectionRange(11, 18);
100 2) Hit Ctrl-Option-J (or Alt-J on Windows), only the word
"SUCCESS" should be selected:
101 <textarea id=
"second" accesskey=
"j">FAILURE or SUCCESS
</textarea>
103 var second
= document
.getElementById("second");
105 second
.setSelectionRange(11, 18);
111 3)
<input type=
"button" onclick=
"document.getElementById('third').focus()" value=
"Click this button">, only the word
"SUCCESS" should be selected:
112 <textarea id=
"third">FAILURE or SUCCESS
</textarea>
114 var third
= document
.getElementById("third");
116 third
.setSelectionRange(11, 18);
122 4) Click in the input field, nothing should be selected:
123 <textarea id=
"fourth">FAILURE and FAILURE
</textarea>
125 var fourth
= document
.getElementById("fourth");
127 fourth
.setSelectionRange(11, 18);
133 5)
<label id=
"fifthLabel" for=
"fifth" style=
"color: blue">Click this label, only the word
"SUCCESS" should be selected:
</label>
134 <textarea id=
"fifth">FAILURE or SUCCESS
</textarea>
136 var second
= document
.getElementById("fifth");
138 fifth
.setSelectionRange(11, 18);
144 6)
<label id=
"sixthLabel" for=
"sixth" accesskey=
"u">Hit Ctrl-Option-U (or Alt-U on Windows), only the word
"SUCCESS" should be selected:
</label>
145 <textarea id=
"sixth">FAILURE or SUCCESS
</textarea>
147 var sixth
= document
.getElementById("sixth");
149 sixth
.setSelectionRange(11, 18);
155 7)
<input type=
"button" onclick=
"document.getElementById('seventhLabel').focus()" value=
"Click this button"><label id=
"seventhLabel" for=
"seventh">, only the word
"SUCCESS" should be selected:
</label>
156 <textarea id=
"seventh">FAILURE or SUCCESS
</textarea>
158 var seventh
= document
.getElementById("seventh");
160 seventh
.setSelectionRange(11, 18);
166 8)
<input type=
"button" onclick=
"document.getElementById('eighthLegend').focus()" value=
"Click this button">
168 <legend id=
"eighthLegend">, only the word
"SUCCESS" should be selected:
</legend>
169 <textarea id=
"eighth">FAILURE or SUCCESS
</textarea>
171 var eighth
= document
.getElementById("eighth");
173 eighth
.setSelectionRange(11, 18);
181 <legend id=
"eighthLegend" accesskey=
"i">Hit Ctrl-Option-I (or Alt-I on Windows), only the word
"SUCCESS" should be selected:
</legend>
182 <textarea id=
"ninth">FAILURE or SUCCESS
</textarea>
184 var ninth
= document
.getElementById("ninth");
186 ninth
.setSelectionRange(11, 18);
192 <p id=
"description"></p>
193 <div id=
"console"></div>