Landing fix for bug 441930. Page refresh of textarea disabled through JS fails to display content. Patch by bnewman@mozilla.com, r+sr=bzbarsky@mit.edu, a=dveditz@cruzio.com

git-svn-id: svn://10.0.0.236/trunk@255768 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jst%mozilla.org
2009-01-08 07:47:04 +00:00
parent 070e8296b2
commit e3f2bb3ea4
4 changed files with 62 additions and 2 deletions

View File

@@ -948,8 +948,9 @@ nsHTMLTextAreaElement::RestoreState(nsPresState* aState)
nsAutoString value;
nsresult rv =
aState->GetStateProperty(NS_LITERAL_STRING("value"), value);
NS_ASSERTION(NS_SUCCEEDED(rv), "value restore failed!");
SetValue(value);
if (rv == NS_STATE_PROPERTY_EXISTS) {
SetValue(value);
}
nsAutoString disabled;
rv = aState->GetStateProperty(NS_LITERAL_STRING("disabled"), disabled);

View File

@@ -115,6 +115,8 @@ _TEST_FILES = test_bug589.html \
test_bug421640.html \
test_bug430351.html \
test_bug430392.html \
bug441930_iframe.html \
test_bug441930.html \
$(NULL)
libs:: $(_TEST_FILES)

View File

@@ -0,0 +1,27 @@
<html>
<body>
The content of this <code>textarea</code> should not disappear on page reload:<br />
<textarea>This text should not disappear on page reload!</textarea>
<script>
var ta = document.getElementsByTagName("textarea").item(0);
if (!parent.reloaded) {
parent.reloaded = true;
ta.disabled = true;
location.reload();
} else {
// Primary regression test:
parent.isnot(ta.value, "",
"Content of dynamically disabled textarea disappeared on page reload.");
// Bonus regression test: changing the textarea's defaultValue after
// reloading should also update the textarea's value.
var newDefaultValue = "new default value";
ta.defaultValue = newDefaultValue;
parent.is(ta.value, newDefaultValue,
"Changing the defaultValue attribute of a textarea fails to update its value attribute.");
parent.SimpleTest.finish();
}
</script>
</body>
</html>

View File

@@ -0,0 +1,30 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=441930
-->
<head>
<title>Test for Bug 441930</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.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=441930">Mozilla Bug 441930</a>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 441930: see bug441930_iframe.html **/
SimpleTest.waitForExplicitFinish();
</script>
</pre>
<p id="display">
<iframe src="bug441930_iframe.html"></iframe>
</p>
<div id="content" style="display: none">
</div>
</body>
</html>