mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-21 17:59:34 +00:00
Bug 612129 - Set the initial selection range to the beginning of the text field in order to be more compatible with other browsers; r=roc
This commit is contained in:
parent
2fe248944b
commit
e422c276a8
@ -833,6 +833,10 @@ function synthFocus(aNodeOrID, aCheckerOrEventSeq, aEventType)
|
||||
|
||||
this.invoke = function synthFocus_invoke()
|
||||
{
|
||||
if (this.DOMNode instanceof Components.interfaces.nsIDOMNSEditableElement ||
|
||||
this.DOMNode instanceof Components.interfaces.nsIDOMXULTextBoxElement) {
|
||||
this.DOMNode.selectionStart = this.DOMNode.selectionEnd = this.DOMNode.value.length;
|
||||
}
|
||||
this.DOMNode.focus();
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ function append(str) {
|
||||
|
||||
var edit = document.getElementById("edit");
|
||||
edit.focus();
|
||||
edit.selectionStart = edit.selectionEnd = edit.value.length;
|
||||
var editor = getEditor();
|
||||
|
||||
for (var i = 0; i < str.length; ++i) {
|
||||
|
@ -4,7 +4,9 @@
|
||||
|
||||
</textarea>
|
||||
<script>
|
||||
document.getElementById("t").focus();
|
||||
var t = document.getElementById("t");
|
||||
t.selectionStart = t.selectionEnd = t.value.length;
|
||||
t.focus();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -6,6 +6,7 @@
|
||||
<script>
|
||||
var t = document.querySelector("textarea");
|
||||
t.focus();
|
||||
t.selectionStart = t.selectionEnd = t.value.length;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -8,6 +8,7 @@
|
||||
<script>
|
||||
var t = document.querySelector("textarea");
|
||||
t.focus();
|
||||
t.selectionStart = t.selectionEnd = t.value.length;
|
||||
sendKey('ENTER', "target");
|
||||
document.body.appendChild(document.createTextNode(t.selectionStart + " - " + t.selectionEnd));
|
||||
</script>
|
||||
|
@ -8,6 +8,7 @@
|
||||
<script>
|
||||
var t = document.querySelector("textarea");
|
||||
t.focus();
|
||||
t.selectionStart = t.selectionEnd = t.value.length;
|
||||
sendKey('ENTER', "target");
|
||||
document.body.appendChild(document.createTextNode(t.selectionStart + " - " + t.selectionEnd));
|
||||
</script>
|
||||
|
@ -8,6 +8,7 @@
|
||||
<script>
|
||||
var t = document.querySelector("textarea");
|
||||
t.focus();
|
||||
t.selectionStart = t.selectionEnd = t.value.length;
|
||||
sendKey('ENTER', "target");
|
||||
document.body.appendChild(document.createTextNode(t.selectionStart + " - " + t.selectionEnd));
|
||||
</script>
|
||||
|
@ -1,8 +1,15 @@
|
||||
<!DOCTYPE HTML><html><head>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript">
|
||||
function loaded() {
|
||||
var t = document.querySelector("textarea");
|
||||
t.focus();
|
||||
t.selectionStart = t.selectionEnd = 4;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="document.querySelector('textarea').focus()">
|
||||
<body onload="loaded()">
|
||||
<textarea style="height: 200px; display: block;"
|
||||
>foo
|
||||
</textarea>
|
||||
|
@ -40,6 +40,7 @@ function startTest()
|
||||
{
|
||||
ta = document.getElementById('blah');
|
||||
ta.focus();
|
||||
ta.selectionStart = ta.selectionEnd = ta.value.length;
|
||||
|
||||
/* Put cursor at start and middle of "sheep" */
|
||||
synthesizeKey("VK_UP", {})
|
||||
|
@ -387,6 +387,9 @@ nsTextControlFrame::EnsureEditorInitialized()
|
||||
// editor.
|
||||
mUseEditor = PR_TRUE;
|
||||
|
||||
// Set the selection to the beginning of the text field.
|
||||
SetSelectionEndPoints(0, 0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -18,13 +18,13 @@
|
||||
doIs(t.value, "Test", "Shouldn't have lost our initial value");
|
||||
t.focus();
|
||||
sendString("Foo");
|
||||
doIs(t.value, "TestFoo", "Typing should work");
|
||||
doIs(t.value, "FooTest", "Typing should work");
|
||||
window.parent.postMessage("c", "*");
|
||||
} else {
|
||||
doIs(evt.data, "continue", "Unexpected message");
|
||||
doIs(t.value, "TestFoo", "Shouldn't have lost our typed value");
|
||||
doIs(t.value, "FooTest", "Shouldn't have lost our typed value");
|
||||
sendString("Bar");
|
||||
doIs(t.value, "TestFooBar", "Typing should still work");
|
||||
doIs(t.value, "BarFooTest", "Typing should still work");
|
||||
window.parent.postMessage("f", "*");
|
||||
}
|
||||
},
|
||||
|
@ -61,6 +61,7 @@ is($("u4").value, "abcdefghijkl",
|
||||
// Now start the editing tests
|
||||
is($("target").value, "abcdefghijklm", "Test starting state incorrect");
|
||||
$("target").focus();
|
||||
$("target").selectionStart = $("target").selectionEnd = 13;
|
||||
sendKey("back_space");
|
||||
is($("target").value, "abcdefghijkl", "Should only delete one char");
|
||||
sendKey("back_space");
|
||||
|
@ -41,7 +41,7 @@ addLoadEvent(function() {
|
||||
is(area.scrollTop, 0, "The textarea should not be scrolled initially");
|
||||
area.focus();
|
||||
setTimeout(function() {
|
||||
isnot(area.scrollTop, 0, "The textarea's insertion point should be scrolled into view");
|
||||
is(area.scrollTop, 0, "The textarea's insertion point should not be scrolled into view");
|
||||
|
||||
SimpleTest.finish();
|
||||
}, 0);
|
||||
|
@ -34,7 +34,7 @@ SimpleTest.waitForFocus(function() {
|
||||
|
||||
is(document.activeElement, i, "Should be focused before frame reconstruction");
|
||||
synthesizeKey("1", {});
|
||||
is(i.value, "test1", "Can accept keyboard events before frame reconstruction");
|
||||
is(i.value, "1test", "Can accept keyboard events before frame reconstruction");
|
||||
|
||||
// force frame reconstruction
|
||||
i.style.display = "none";
|
||||
@ -44,7 +44,7 @@ SimpleTest.waitForFocus(function() {
|
||||
|
||||
is(document.activeElement, i, "Should be focused after frame reconstruction");
|
||||
synthesizeKey("2", {});
|
||||
is(i.value, "test12", "Can accept keyboard events after frame reconstruction");
|
||||
is(i.value, "12test", "Can accept keyboard events after frame reconstruction");
|
||||
|
||||
// Make sure reframing happens gracefully
|
||||
var reframeDiv = document.getElementById("reframe");
|
||||
|
@ -79,9 +79,9 @@ function runTests(callback, type) {
|
||||
d.value = "new";
|
||||
is(d.value, "new", "Dynamic control's value can be set before initialization");
|
||||
sendChar("x", d);
|
||||
is(d.value, "newx", "Dynamic control accepts keyboard input without explicit initialization");
|
||||
is(d.value, "xnew", "Dynamic control accepts keyboard input without explicit initialization");
|
||||
$("display").removeChild(d);
|
||||
is(d.value, "newx", "Dynamic control retains value after being removed from the document");
|
||||
is(d.value, "xnew", "Dynamic control retains value after being removed from the document");
|
||||
|
||||
callback();
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=240933
|
||||
|
||||
t = document.getElementById("ta");
|
||||
t.focus();
|
||||
t.selectionStart = t.selectionEnd = t.value.length;
|
||||
var val = t.value;
|
||||
synthesizeKey("VK_ENTER", {});
|
||||
is(t.value, val + "\n", "Pressing enter right after focusing the textarea should work");
|
||||
|
@ -12,8 +12,8 @@ abc
|
||||
|
||||
</textarea>
|
||||
|
||||
<div id="coords1">6</div>
|
||||
<div id="coords2">6</div>
|
||||
<div id="coords1">0</div>
|
||||
<div id="coords2">0</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,6 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body onload="document.querySelector('textarea').focus();">
|
||||
<body onload="loaded()">
|
||||
<script>
|
||||
function loaded() {
|
||||
var t = document.querySelector('textarea');
|
||||
t.selectionStart = t.selectionEnd = t.value.length;
|
||||
t.focus();
|
||||
}
|
||||
</script>
|
||||
<textarea>foo</textarea>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,6 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body onload="document.querySelector('textarea').focus();">
|
||||
<body onload="loaded()">
|
||||
<script>
|
||||
function loaded() {
|
||||
var t = document.querySelector('textarea');
|
||||
t.selectionStart = t.selectionEnd = t.value.length;
|
||||
t.focus();
|
||||
}
|
||||
</script>
|
||||
<textarea>foo
|
||||
</textarea>
|
||||
</body>
|
||||
|
@ -588,7 +588,7 @@ function runTest(testNum) {
|
||||
sendChar("X", uname);
|
||||
// Trigger the 'blur' event on uname
|
||||
pword.focus();
|
||||
checkACForm("singleuser5X", "singlepass5");
|
||||
checkACForm("sXingleuser5", "singlepass5");
|
||||
|
||||
pwmgr.removeLogin(login5);
|
||||
testNum = 499;
|
||||
|
Loading…
x
Reference in New Issue
Block a user