Skip to content

Commit

Permalink
Bug 424698. Don't treat it as a value set if a text input with a defa…
Browse files Browse the repository at this point in the history
…ult value has its frame go away. r+sr=sicking
  • Loading branch information
bzbarsky committed Jul 21, 2008
1 parent 19e9446 commit c00a3cd
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
1 change: 0 additions & 1 deletion content/html/content/src/nsHTMLInputElement.cpp
Expand Up @@ -825,7 +825,6 @@ nsHTMLInputElement::TakeTextFrameValue(const nsAString& aValue)
nsMemory::Free(mValue);
}
mValue = ToNewUTF8String(aValue);
SetValueChanged(PR_TRUE);
return NS_OK;
}

Expand Down
5 changes: 3 additions & 2 deletions content/html/content/test/Makefile.in
Expand Up @@ -108,12 +108,13 @@ _TEST_FILES = test_bug589.html \
test_bug394700.html \
test_bug395107.html \
test_bug401160.xhtml \
test_bug406596.html \
test_bug408231.html \
test_bug417760.html \
file_bug417760.png \
test_bug428135.xhtml \
test_bug406596.html \
test_bug421640.html \
test_bug424698.html \
test_bug428135.xhtml \
test_bug430351.html \
test_bug430392.html \
$(NULL)
Expand Down
61 changes: 61 additions & 0 deletions content/html/content/test/test_bug424698.html
@@ -0,0 +1,61 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=424698
-->
<head>
<title>Test for Bug 424698</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=424698">Mozilla Bug 424698</a>
<p id="display">
<input id="i1">
<input id="target">
</p>
<div id="content" style="display: none">

</div>
<pre id="test">
<script class="testbody" type="text/javascript">

/** Test for Bug 424698 **/
var i = $("i1");
is(i.value, "", "Value should be empty string");
i.defaultValue = "test";
is(i.value, "test", "Setting defaultValue should work");
i.defaultValue = "test2";
is(i.value, "test2", "Setting defaultValue multiple times should work");

// Now let's hide and reshow things
i.style.display = "none";
is(i.offsetWidth, 0, "Input didn't hide?");
i.style.display = "";
isnot(i.offsetWidth, 0, "Input didn't show?");
is(i.value, "test2", "Hiding/showing should not affect value");
i.defaultValue = "test3";
is(i.value, "test3", "Setting defaultValue after hide/show should work");

// Make sure typing works ok
i = $("target");
i.focus(); // Otherwise editor gets confused when we send the key events
is(i.value, "", "Value should be empty string in second control");
sendString("2test2");
is(i.value, "2test2", 'We just typed the string "2test2"');
i.defaultValue = "2test3";
is(i.value, "2test2", "Setting defaultValue after typing should not work");
i.style.display = "none";
is(i.offsetWidth, 0, "Second input didn't hide?");
i.style.display = "";
isnot(i.offsetWidth, 0, "Second input didn't show?");
is(i.value, "2test2", "Hiding/showing second input should not affect value");
i.defaultValue = "2test4";
is(i.value, "2test2", "Setting defaultValue after hide/show should not work if we typed");
</script>
</pre>
</body>
</html>

0 comments on commit c00a3cd

Please sign in to comment.