diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp index b10a146b1c67..b0d192fb5688 100644 --- a/content/html/content/src/nsHTMLInputElement.cpp +++ b/content/html/content/src/nsHTMLInputElement.cpp @@ -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) { diff --git a/layout/forms/test/test_bug542914.html b/layout/forms/test/test_bug542914.html index a7a3909f6018..62498baf4280 100644 --- a/layout/forms/test/test_bug542914.html +++ b/layout/forms/test/test_bug542914.html @@ -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 "); + runTests(function() { + ok(true, "Running tests on "); + setTypes("password"); + runTests(function() { + ok(true, "Running tests on "); + setTypes("tel"); + runTests(function() { + SimpleTest.finish(); + }, "tel"); + }, "password"); + }, "text"); });