197 lines
6.2 KiB
HTML
197 lines
6.2 KiB
HTML
<body onload="runTest()">
|
|
<script src="../../resources/js-test-pre.js"></script>
|
|
|
|
<script>
|
|
function runTest()
|
|
{
|
|
if (!window.testRunner)
|
|
return;
|
|
|
|
var accessKeyModifiers = ["altKey"];
|
|
if (navigator.userAgent.search(/\bMac OS X\b/) != -1)
|
|
accessKeyModifiers = ["ctrlKey", "altKey"];
|
|
|
|
testRunner.dumpEditingCallbacks();
|
|
testRunner.dumpAsText();
|
|
|
|
shouldBe("first.selectionStart", "12");
|
|
shouldBe("first.selectionEnd", "19");
|
|
eventSender.keyDown("\t");
|
|
shouldBe("first.selectionStart", "0");
|
|
shouldBe("first.selectionEnd", "19");
|
|
|
|
shouldBe("second.selectionStart", "11");
|
|
shouldBe("second.selectionEnd", "18");
|
|
eventSender.keyDown("J", accessKeyModifiers);
|
|
shouldBe("second.selectionStart", "11");
|
|
shouldBe("second.selectionEnd", "18");
|
|
|
|
shouldBe("third.selectionStart", "11");
|
|
shouldBe("third.selectionEnd", "18");
|
|
third.focus();
|
|
shouldBe("third.selectionStart", "11");
|
|
shouldBe("third.selectionEnd", "18");
|
|
|
|
shouldBe("fourth.selectionStart", "12");
|
|
shouldBe("fourth.selectionEnd", "19");
|
|
eventSender.mouseMoveTo(fourth.offsetLeft + 4, fourth.offsetTop + 4);
|
|
eventSender.mouseDown();
|
|
eventSender.mouseUp();
|
|
shouldBe("fourth.selectionStart", "0");
|
|
shouldBe("fourth.selectionEnd", "0");
|
|
|
|
shouldBe("fifth.selectionStart", "11");
|
|
shouldBe("fifth.selectionEnd", "18");
|
|
var fifthLabel = document.getElementById("fifthLabel");
|
|
eventSender.mouseMoveTo(fifthLabel.offsetLeft + 4, fifthLabel.offsetTop + 4);
|
|
eventSender.mouseDown();
|
|
eventSender.mouseUp();
|
|
shouldBe("fifth.selectionStart", "11");
|
|
shouldBe("fifth.selectionEnd", "18");
|
|
|
|
shouldBe("sixth.selectionStart", "12");
|
|
shouldBe("sixth.selectionEnd", "19");
|
|
eventSender.keyDown("U", accessKeyModifiers);
|
|
shouldBe("sixth.selectionStart", "0");
|
|
shouldBe("sixth.selectionEnd", "19");
|
|
|
|
shouldBe("seventh.selectionStart", "11");
|
|
shouldBe("seventh.selectionEnd", "18");
|
|
var seventLabel = document.getElementById("seventhLabel");
|
|
seventhLabel.focus();
|
|
shouldBe("seventh.selectionStart", "11");
|
|
shouldBe("seventh.selectionEnd", "18");
|
|
|
|
shouldBe("eighth.selectionStart", "12");
|
|
shouldBe("eighth.selectionEnd", "19");
|
|
var eighthLegend = document.getElementById("eighthLegend");
|
|
eighthLegend.focus();
|
|
shouldBe("eighth.selectionStart", "0");
|
|
shouldBe("eighth.selectionEnd", "19");
|
|
|
|
shouldBe("ninth.selectionStart", "12");
|
|
shouldBe("ninth.selectionEnd", "19");
|
|
eventSender.keyDown("I", accessKeyModifiers);
|
|
shouldBe("ninth.selectionStart", "0");
|
|
shouldBe("ninth.selectionEnd", "19");
|
|
|
|
}
|
|
</script>
|
|
|
|
<h2><input type="text"> focus selection</h2>
|
|
|
|
<p>This test checks whether the selection is restored, cleared, or set
|
|
to the full range when using different ways to focus a text field. These
|
|
results all match Mozilla, except test 6, which selects
|
|
the whole field contents to match all other cases of keyboard
|
|
focus. When running manually, please follow the steps below. In the
|
|
test harness, the test runs automatically.</p>
|
|
|
|
1) Hit tab, the whole phrase "SUCCESS and SUCCESS" should be selected:
|
|
<input type="text" id="first" value="SUCCESS and SUCCESS">
|
|
<script>
|
|
var first = document.getElementById("first");
|
|
first.focus();
|
|
first.setSelectionRange(12, 19);
|
|
first.blur();
|
|
</script>
|
|
|
|
<br>
|
|
|
|
2) Hit Ctrl-Option-J (or Alt-J on Windows), the whole phrase "SUCCESS and SUCCESS" should be selected:
|
|
<input type="text" id="second" accesskey="j" value="SUCCESS and SUCCESS">
|
|
<script>
|
|
var second = document.getElementById("second");
|
|
second.focus();
|
|
second.setSelectionRange(12, 19);
|
|
second.blur();
|
|
</script>
|
|
|
|
<br>
|
|
|
|
3) <input type="button" onclick="document.getElementById('third').focus()" value="Click this button">, only the word "SUCCESS" should be selected:
|
|
<input type="text" id="third" value="FAILURE or SUCCESS">
|
|
<script>
|
|
var third = document.getElementById("third");
|
|
third.focus();
|
|
third.setSelectionRange(11, 18);
|
|
third.blur();
|
|
</script>
|
|
|
|
<br>
|
|
|
|
4) Click in the input field, nothing should be selected:
|
|
<input type="text" id="fourth" value="FAILURE and FAILURE">
|
|
<script>
|
|
var fourth = document.getElementById("fourth");
|
|
fourth.focus();
|
|
fourth.setSelectionRange(12, 19);
|
|
fourth.blur();
|
|
</script>
|
|
|
|
<br>
|
|
|
|
5) <label id="fifthLabel" for="fifth" style="color: blue">Click this label, only the word "SUCCESS" should be selected:</label>
|
|
<input type="text" id="fifth" value="FAILURE or SUCCESS">
|
|
<script>
|
|
var second = document.getElementById("fifth");
|
|
fifth.focus();
|
|
fifth.setSelectionRange(11, 18);
|
|
fifth.blur();
|
|
</script>
|
|
|
|
<br>
|
|
|
|
6) <label id="sixthLabel" for="sixth" accesskey="u">Hit Ctrl-Option-U (or Alt-U on Windows), the whole phrase "SUCCESS and SUCCESS" should be selected:</label>
|
|
<input type="text" id="sixth" value="SUCCESS and SUCCESS">
|
|
<script>
|
|
var sixth = document.getElementById("sixth");
|
|
sixth.focus();
|
|
sixth.setSelectionRange(12, 19);
|
|
sixth.blur();
|
|
</script>
|
|
|
|
<br>
|
|
|
|
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>
|
|
<input type="text" id="seventh" value="FAILURE or SUCCESS">
|
|
<script>
|
|
var seventh = document.getElementById("seventh");
|
|
seventh.focus();
|
|
seventh.setSelectionRange(11, 18);
|
|
seventh.blur();
|
|
</script>
|
|
|
|
<br>
|
|
|
|
8) <input type="button" onclick="document.getElementById('eighthLegend').focus()" value="Click this button">
|
|
<fieldset>
|
|
<legend id="eighthLegend">, the whole phrase "SUCCESS and SUCCESS" should be selected:</legend>
|
|
<input type="text" id="eighth" value="SUCCESS and SUCCESS">
|
|
<script>
|
|
var eighth = document.getElementById("eighth");
|
|
eighth.focus();
|
|
eighth.setSelectionRange(12, 19);
|
|
eighth.blur();
|
|
</script>
|
|
</fieldset>
|
|
<br>
|
|
|
|
|
|
9) <fieldset>
|
|
<legend id="eighthLegend" accesskey="i">Hit Ctrl-Option-I (or Alt-I on Windows), the whole phrase "SUCCESS and SUCCESS" should be selected:</legend>
|
|
<input type="text" id="ninth" value="SUCCESS and SUCCESS">
|
|
<script>
|
|
var ninth = document.getElementById("ninth");
|
|
ninth.focus();
|
|
ninth.setSelectionRange(12, 19);
|
|
ninth.blur();
|
|
</script>
|
|
</fieldset>
|
|
<br>
|
|
|
|
<p id="description"></p>
|
|
<div id="console"></div>
|
|
|
|
</body>
|