Title: [106388] trunk
Revision
106388
Author
[email protected]
Date
2012-01-31 13:43:56 -0800 (Tue, 31 Jan 2012)

Log Message

Hidden form elements do not save their state prior to form submission
https://bugs.webkit.org/show_bug.cgi?id=77391
<rdar://problem/10563108>

Reviewed by Brady Eidson.

Source/WebCore:

Test: fast/forms/state-restore-hidden.html

* html/HiddenInputType.cpp: Teach hidden inputs to save and restore their state.
(WebCore::HiddenInputType::saveFormControlState):
(WebCore::HiddenInputType::restoreFormControlState):
* html/HiddenInputType.h:
(HiddenInputType):

LayoutTests:

The test changes the value of the hidden input element via _javascript_ prior to
submitting the form. The form action goes back one page, and we check to see
that the hidden input value is what it was set to by _javascript_, rather than what
it was originally assigned.

* fast/forms/state-restore-hidden-expected.txt: Added.
* fast/forms/state-restore-hidden.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (106387 => 106388)


--- trunk/LayoutTests/ChangeLog	2012-01-31 21:39:33 UTC (rev 106387)
+++ trunk/LayoutTests/ChangeLog	2012-01-31 21:43:56 UTC (rev 106388)
@@ -1,3 +1,19 @@
+2012-01-31  Jon Lee  <[email protected]>
+
+        Hidden form elements do not save their state prior to form submission
+        https://bugs.webkit.org/show_bug.cgi?id=77391
+        <rdar://problem/10563108>
+
+        Reviewed by Brady Eidson.
+
+        The test changes the value of the hidden input element via _javascript_ prior to
+        submitting the form. The form action goes back one page, and we check to see
+        that the hidden input value is what it was set to by _javascript_, rather than what
+        it was originally assigned.
+
+        * fast/forms/state-restore-hidden-expected.txt: Added.
+        * fast/forms/state-restore-hidden.html: Added.
+
 2012-01-31  Joshua Bell  <[email protected]>
 
         IndexedDB: IDBCursor.update() should raise exception if key changed

Added: trunk/LayoutTests/fast/forms/state-restore-hidden-expected.txt (0 => 106388)


--- trunk/LayoutTests/fast/forms/state-restore-hidden-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/state-restore-hidden-expected.txt	2012-01-31 21:43:56 UTC (rev 106388)
@@ -0,0 +1,11 @@
+Bug 77391 - Hidden form elements do not save their state prior to form submission
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.f.hidden.value is "after"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+

Added: trunk/LayoutTests/fast/forms/state-restore-hidden.html (0 => 106388)


--- trunk/LayoutTests/fast/forms/state-restore-hidden.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/state-restore-hidden.html	2012-01-31 21:43:56 UTC (rev 106388)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body _onload_="runTest()">
+
+<div id="console"></div>
+
+<input id="emptyOnFirstVisit" />
+<form action="" name=f>
+    <input type="hidden" name="hidden" value="before" />
+</form>
+
+<script>
+description("Bug 77391 - Hidden form elements do not save their state prior to form submission");
+
+function runTest() {
+    var state = document.getElementById("emptyOnFirstVisit");
+    if (!state.value) {
+        // First visit.
+        if (window.layoutTestController)
+            layoutTestController.waitUntilDone();
+        state.value = "visited";
+
+        document.f.hidden.value = "after";
+        // Submit form in a timeout to make sure that we create a new back/forward list item.
+        setTimeout(function() {document.f.submit();}, 0);
+    } else {
+        // Second visit.
+        shouldBeEqualToString("document.f.hidden.value", "after");
+        successfullyParsed = true;
+        
+        var script = document.createElement('script');
+        script.src = ""
+        script.type = "text/_javascript_";
+        script._onload_ = function() {
+            if (window.layoutTestController)
+                layoutTestController.notifyDone();
+        };
+        document.body.appendChild(script);
+    }
+}
+</script>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (106387 => 106388)


--- trunk/Source/WebCore/ChangeLog	2012-01-31 21:39:33 UTC (rev 106387)
+++ trunk/Source/WebCore/ChangeLog	2012-01-31 21:43:56 UTC (rev 106388)
@@ -1,3 +1,19 @@
+2012-01-31  Jon Lee  <[email protected]>
+
+        Hidden form elements do not save their state prior to form submission
+        https://bugs.webkit.org/show_bug.cgi?id=77391
+        <rdar://problem/10563108>
+
+        Reviewed by Brady Eidson.
+
+        Test: fast/forms/state-restore-hidden.html
+
+        * html/HiddenInputType.cpp: Teach hidden inputs to save and restore their state.
+        (WebCore::HiddenInputType::saveFormControlState):
+        (WebCore::HiddenInputType::restoreFormControlState):
+        * html/HiddenInputType.h:
+        (HiddenInputType):
+
 2012-01-31  Joshua Bell  <[email protected]>
 
         IndexedDB: IDBCursor.update() should raise exception if key changed

Modified: trunk/Source/WebCore/html/HiddenInputType.cpp (106387 => 106388)


--- trunk/Source/WebCore/html/HiddenInputType.cpp	2012-01-31 21:39:33 UTC (rev 106387)
+++ trunk/Source/WebCore/html/HiddenInputType.cpp	2012-01-31 21:43:56 UTC (rev 106388)
@@ -46,10 +46,22 @@
     return adoptPtr(new HiddenInputType(element));
 }
 
-const AtomicString& HiddenInputType::formControlType() const {
+const AtomicString& HiddenInputType::formControlType() const
+{
     return InputTypeNames::hidden();
 }
 
+bool HiddenInputType::saveFormControlState(String& result) const
+{
+    result = element()->value();
+    return true;
+}
+
+void HiddenInputType::restoreFormControlState(const String& string) const
+{
+    element()->setAttribute(valueAttr, string);
+}
+
 bool HiddenInputType::supportsValidation() const
 {
     return false;

Modified: trunk/Source/WebCore/html/HiddenInputType.h (106387 => 106388)


--- trunk/Source/WebCore/html/HiddenInputType.h	2012-01-31 21:39:33 UTC (rev 106387)
+++ trunk/Source/WebCore/html/HiddenInputType.h	2012-01-31 21:43:56 UTC (rev 106388)
@@ -42,6 +42,8 @@
 private:
     HiddenInputType(HTMLInputElement* element) : InputType(element) { }
     virtual const AtomicString& formControlType() const OVERRIDE;
+    virtual bool saveFormControlState(String&) const OVERRIDE;
+    virtual void restoreFormControlState(const String&) const OVERRIDE;
     virtual bool supportsValidation() const OVERRIDE;
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const OVERRIDE;
     virtual void accessKeyAction(bool sendMouseEvents) OVERRIDE;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to