Bug 565775 - The editor will not be correctly initialized for <input type=tel> on user events; r=roc

This commit is contained in:
Ehsan Akhgari 2010-05-13 18:56:24 -04:00
Родитель 083ba1cffe
Коммит 3403a0ab1a
2 изменённых файлов: 27 добавлений и 6 удалений

Просмотреть файл

@ -1622,13 +1622,12 @@ nsHTMLInputElement::Click()
PRBool
nsHTMLInputElement::NeedToInitializeEditorForEvent(nsEventChainPreVisitor& aVisitor) const
{
// We only need to initialize the editor for text input controls because they
// We only need to initialize the editor for single line input controls because they
// are lazily initialized. We don't need to initialize the control for
// certain types of events, because we know that those events are safe to be
// handled without the editor being initialized. These events include:
// mousein/move/out, and DOM mutation events.
if ((mType == NS_FORM_INPUT_TEXT ||
mType == NS_FORM_INPUT_PASSWORD) &&
if (IsSingleLineTextControl(PR_FALSE) &&
aVisitor.mEvent->eventStructType != NS_MUTATION_EVENT) {
switch (aVisitor.mEvent->message) {

Просмотреть файл

@ -25,7 +25,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=542914
/** Test for Bug 542914 **/
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
function runTests(callback, type) {
var a = $("a");
// Test that the initial value of the control is available to script
@ -70,7 +70,7 @@ addLoadEvent(function() {
is(c.value, "ab", "Control retains caret position after being re-focused");
var d = document.createElement("input");
d.setAttribute("type", "text");
d.setAttribute("type", type);
$("display").appendChild(d);
document.body.offsetHeight;
@ -83,7 +83,29 @@ addLoadEvent(function() {
$("display").removeChild(d);
is(d.value, "newx", "Dynamic control retains value after being removed from the document");
SimpleTest.finish();
callback();
}
var gPreviousType = "text";
function setTypes(aType) {
var content = document.getElementById("display");
content.innerHTML = content.innerHTML.replace(gPreviousType, aType);
gPreviousType = aType;
}
addLoadEvent(function() {
ok(true, "Running tests on <input type=text>");
runTests(function() {
ok(true, "Running tests on <input type=password>");
setTypes("password");
runTests(function() {
ok(true, "Running tests on <input type=tel>");
setTypes("tel");
runTests(function() {
SimpleTest.finish();
}, "tel");
}, "password");
}, "text");
});
</script>