RESOLVED FIXED 31539
Form Reset : Press Back Button and Reset , TextareaElemnt is not set to Default Value
https://bugs.webkit.org/show_bug.cgi?id=31539
Summary Form Reset : Press Back Button and Reset , TextareaElemnt is not set to Defau...
Amol
Reported 2009-11-16 02:45:29 PST
I visited the formreset link(http://spe.mobilephone.net/wit/xhtmlv2/formreset.xhtml ). All Radio button , checkbox , TextArea has some defalut value . After modifying it and pressing Submit , the data gets submitted , If we press back and Press a Reset Button . The textarea feild is not getting reset to default valu e, I observer the same behavior in other Browser(Mozilla) , its resets the same . Regards , Amol
Attachments
Test part 1 (2.57 KB, text/html)
2009-12-01 08:40 PST, Ben Murdoch
no flags
Test part 2 - place in resources directory under part 1 (409 bytes, text/html)
2009-12-01 08:41 PST, Ben Murdoch
no flags
Proposed patch (1.35 KB, patch)
2009-12-07 11:22 PST, Ben Murdoch
no flags
Fix with manual test (3.82 KB, patch)
2010-01-11 09:58 PST, Ben Murdoch
no flags
Alexey Proskuryakov
Comment 1 2009-11-16 17:38:27 PST
I cannot reproduce this with Safari 4.0.3 on Mac OS X. What browser are you seeing this with?
Amol
Comment 2 2009-11-16 21:22:33 PST
Hi Alexey, Thanks for the reply . I can see this issue in Google Chrome(3.0.195.33) which i have installed . I have ported the Webkit Browser code and the same issue i can see in Google android phone . Thanks and Regards , Amol
Ben Murdoch
Comment 3 2009-11-27 06:45:16 PST
I had a look at this on Android, and the problem seems to be when TextAreaElement::restoreFormControlElementState is called when we navigate back to the page. This resets the *default* value of the element to the state of the form before the submit (using TextAreaElement::setDefaultValue), so when we click reset, the default value to reset to matches the current state rather than the default value stipulated by the HTML. Setting breakpoints in Safari, it seems restoreFormControlElementState isn't getting called because it's being pulled out of the cache and short circuiting some code, whereas on Android we are triggering a new load. If after submitting the form you clear Safari's cache and then go back, the bug surfaces and you cannot reset the text area to it's default value of 123. I think the fix therefore is to call setValue rather than setDefaultValue in restoreFormControlElementState. I can send a patch for this. Thanks, Ben
Ben Murdoch
Comment 4 2009-11-30 03:04:57 PST
I have a patch ready to fix this bug, but before I upload it I've been trying to write a layout test for it. It's tricky because to expose the bug on Safari, you need to clear the cache between submitting the form and hitting back. Is there a way to turn off or clear the cache through the layout test controller? Thanks, Ben
Alexey Proskuryakov
Comment 5 2009-11-30 08:35:28 PST
Maybe setCacheModel(0) will work?
Ben Murdoch
Comment 6 2009-12-01 08:29:17 PST
I have written a reduced test case that exposes the bug on Safari which is perfect for the layout test. However, I'm having trouble getting the test to execute automatically. If you open the test page and manually click the 'submit' button on the form in the iframe, then the test will expose the bug. When I try to automate this by programattically clicking the button, the test does not run correctly. I think I've tracked the problem down to the fact that it seems that for events from script that trigger navigation, no history items are created and so the call to history.back() in the form handler fails. I will attach the test as I have it right now; does any one have any advice as to how I could fully automate it? I've tried using the eventSender object in DRT, calling the submit button's click() method, instantiating an Event object and dispatching it to the submit button, altering location.hash to try and create history entries, calling the submit() function on the form itself, but nothing seems to work... The fix for the bug is a very simple one line change in HTMLTextAreaElement.cpp. Thanks, Ben
Ben Murdoch
Comment 7 2009-12-01 08:40:39 PST
Created attachment 44083 [details] Test part 1 First part of the test
Ben Murdoch
Comment 8 2009-12-01 08:41:56 PST
Created attachment 44084 [details] Test part 2 - place in resources directory under part 1
Ben Murdoch
Comment 9 2009-12-07 11:22:12 PST
I haven't had any luck getting the test to automate - I wonder if we could consider adding the fix without a test? I have attached a patch...
Ben Murdoch
Comment 10 2009-12-07 11:22:57 PST
Created attachment 44422 [details] Proposed patch
Darin Adler
Comment 11 2009-12-08 11:46:45 PST
Comment on attachment 44422 [details] Proposed patch > void HTMLTextAreaElement::restoreFormControlState(const String& state) > { > - setDefaultValue(state); > + setValue(state); > } Sure, we want to set the value. But don't we want to set the default value too?
WebKit Review Bot
Comment 12 2009-12-08 11:47:35 PST
style-queue ran check-webkit-style on attachment 44422 [details] without any errors.
Ben Murdoch
Comment 13 2009-12-08 11:54:14 PST
(In reply to comment #11) > > Sure, we want to set the value. But don't we want to set the default value too? I don't think so -- not to the value that was stored as the state of the text area, anyway?
Maciej Stachowiak
Comment 14 2009-12-29 05:45:50 PST
(In reply to comment #11) > (From update of attachment 44422 [details]) > > void HTMLTextAreaElement::restoreFormControlState(const String& state) > > { > > - setDefaultValue(state); > > + setValue(state); > > } > > Sure, we want to set the value. But don't we want to set the default value too? I don't think that's right - when saving form control state, what we saved originally was the value, not the default value. We could save the default value as well (in case it was changed e.g. by altering the <textarea>'s DOM children) but in general our form control state saving code doesn't try to do that type of thing.
Adele Peterson
Comment 15 2010-01-08 23:48:04 PST
How about adding the test as a manual test?
Ben Murdoch
Comment 16 2010-01-11 04:50:57 PST
(In reply to comment #15) > How about adding the test as a manual test? That would do it I should think, thanks for the tip! I've never written or used manual tests in WebKit -- is it as one would expect, a layout test that is designed to be run by hand? A quick look at current tests inside WebCore/manual-tests would suggest so and that the body of the test page should include instructions for running the test and the expected results. Are there any other guidelines or tips for writing a manual test? Are these tests run with any regularity? Thanks, Ben
Ben Murdoch
Comment 17 2010-01-11 09:58:22 PST
Created attachment 46286 [details] Fix with manual test Here's the same patch with a manual test.
Ben Murdoch
Comment 18 2010-01-12 02:29:15 PST
Comment on attachment 46286 [details] Fix with manual test cq+ for landing.
WebKit Commit Bot
Comment 19 2010-01-12 03:48:12 PST
Comment on attachment 46286 [details] Fix with manual test Clearing flags on attachment: 46286 Committed r53132: <http://trac.webkit.org/changeset/53132>
WebKit Commit Bot
Comment 20 2010-01-12 03:48:20 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.