Title: [125124] trunk
Revision
125124
Author
[email protected]
Date
2012-08-08 17:34:11 -0700 (Wed, 08 Aug 2012)

Log Message

Google search query text reverts to original search query after multiple searches
<rdar://problem/10800686> and https://bugs.webkit.org/show_bug.cgi?id=93544

Reviewed by Darin Adler.

Source/WebCore:

For security sensitive fields we normally clear "autocomplete=off" form elements when
restoring a page from the page cache.

If the element is textual and has a defaultValue then "clearing" it actually restores
the default value.

There's no scenario we can imagine where that makes sense so we should not reset the
value in such fields.

Test: fast/forms/autocomplete-off-with-default-value-does-not-clear.html

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::parseAttribute): Update suspension callback registration as needed.
(WebCore::HTMLInputElement::needsSuspensionCallback): Don't reset text fields with a non-empty default value.

LayoutTests:

* fast/forms/autocomplete-off-with-default-value-does-not-clear-expected.txt: Added.
* fast/forms/autocomplete-off-with-default-value-does-not-clear.html: Added.
* fast/forms/resources/go-back.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125123 => 125124)


--- trunk/LayoutTests/ChangeLog	2012-08-09 00:19:23 UTC (rev 125123)
+++ trunk/LayoutTests/ChangeLog	2012-08-09 00:34:11 UTC (rev 125124)
@@ -1,3 +1,14 @@
+2012-08-08  Brady Eidson  <[email protected]>
+
+        Google search query text reverts to original search query after multiple searches
+        <rdar://problem/10800686> and https://bugs.webkit.org/show_bug.cgi?id=93544
+
+        Reviewed by Darin Adler.
+
+        * fast/forms/autocomplete-off-with-default-value-does-not-clear-expected.txt: Added.
+        * fast/forms/autocomplete-off-with-default-value-does-not-clear.html: Added.
+        * fast/forms/resources/go-back.html: Added.
+
 2012-08-08  Raymond Toy  <[email protected]>
 
         Creating "basic waveform" Oscillator nodes is not efficient

Added: trunk/LayoutTests/fast/forms/autocomplete-off-with-default-value-does-not-clear-expected.txt (0 => 125124)


--- trunk/LayoutTests/fast/forms/autocomplete-off-with-default-value-does-not-clear-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/autocomplete-off-with-default-value-does-not-clear-expected.txt	2012-08-09 00:34:11 UTC (rev 125124)
@@ -0,0 +1,3 @@
+This page has a text input element with a default value and autocomplete set to off. When restored from the page cache its value should *not* be cleared.
+
+SomeNonDefaultValue

Added: trunk/LayoutTests/fast/forms/autocomplete-off-with-default-value-does-not-clear.html (0 => 125124)


--- trunk/LayoutTests/fast/forms/autocomplete-off-with-default-value-does-not-clear.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/autocomplete-off-with-default-value-does-not-clear.html	2012-08-09 00:34:11 UTC (rev 125124)
@@ -0,0 +1,33 @@
+<script>
+
+if (window.testRunner) {
+	testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+	testRunner.dumpAsText();
+	testRunner.waitUntilDone();
+}
+
+function loaded()
+{
+	document.getElementById("testInput").value = "SomeNonDefaultValue";
+	setTimeout("location.href = ''", 0);
+}
+
+function pageShown(evt)
+{
+	if (evt.persisted)
+		setTimeout("finishUp()", 0);
+}
+
+function finishUp()
+{
+	document.getElementById("logger").innerText = document.getElementById("testInput").value;
+	if (window.testRunner)
+		testRunner.notifyDone();
+}
+
+</script>
+<body _onload_="loaded()" _onpageshow_="pageShown(event)">
+This page has a text input element with a default value and autocomplete set to off.  When restored from the page cache its value should *not* be cleared.<br>
+<input id="testInput" type="test" autocomplete="off" value="DefaultValue">
+<div id="logger"></div>
+</body>

Added: trunk/LayoutTests/fast/forms/resources/go-back.html (0 => 125124)


--- trunk/LayoutTests/fast/forms/resources/go-back.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/resources/go-back.html	2012-08-09 00:34:11 UTC (rev 125124)
@@ -0,0 +1,3 @@
+<body _onload_="setTimeout('history.back();', 0);">
+Going back...
+</body>

Modified: trunk/Source/WebCore/ChangeLog (125123 => 125124)


--- trunk/Source/WebCore/ChangeLog	2012-08-09 00:19:23 UTC (rev 125123)
+++ trunk/Source/WebCore/ChangeLog	2012-08-09 00:34:11 UTC (rev 125124)
@@ -1,3 +1,25 @@
+2012-08-08  Brady Eidson  <[email protected]>
+
+        Google search query text reverts to original search query after multiple searches
+        <rdar://problem/10800686> and https://bugs.webkit.org/show_bug.cgi?id=93544
+
+        Reviewed by Darin Adler.
+
+        For security sensitive fields we normally clear "autocomplete=off" form elements when
+        restoring a page from the page cache.
+        
+        If the element is textual and has a defaultValue then "clearing" it actually restores 
+        the default value.
+        
+        There's no scenario we can imagine where that makes sense so we should not reset the 
+        value in such fields.
+
+        Test: fast/forms/autocomplete-off-with-default-value-does-not-clear.html
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::parseAttribute): Update suspension callback registration as needed.
+        (WebCore::HTMLInputElement::needsSuspensionCallback): Don't reset text fields with a non-empty default value.
+
 2012-08-08  Raymond Toy  <[email protected]>
 
         Creating "basic waveform" Oscillator nodes is not efficient

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (125123 => 125124)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-08-09 00:19:23 UTC (rev 125123)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-08-09 00:34:11 UTC (rev 125124)
@@ -626,6 +626,12 @@
     } else if (attribute.name() == typeAttr) {
         updateType();
     } else if (attribute.name() == valueAttr) {
+        // Changes to the value attribute may change whether or not this element has a default value.
+        // If this field is autocomplete=off that might affect the return value of needsSuspensionCallback.
+        if (m_autocomplete == Off) {
+            unregisterForSuspensionCallbackIfNeeded();
+            registerForSuspensionCallbackIfNeeded();
+        }
         // We only need to setChanged if the form is looking at the default value right now.
         if (!hasDirtyValue()) {
             updatePlaceholderVisibility(false);
@@ -1379,7 +1385,17 @@
 
 bool HTMLInputElement::needsSuspensionCallback()
 {
-    return m_autocomplete == Off || m_inputType->shouldResetOnDocumentActivation();
+    if (m_inputType->shouldResetOnDocumentActivation())
+        return true;
+
+    // Sensitive input elements are marked with autocomplete=off, and we want to wipe them out
+    // when going back; returning true here arranges for us to call reset at the time
+    // the page is restored. Non-empty textual default values indicate that the field
+    // is not really sensitive -- there's no default value for an account number --
+    // and we would see unexpected results if we reset to something other than blank.
+    bool isSensitive = m_autocomplete == Off && !(m_inputType->isTextType() && !defaultValue().isEmpty());
+
+    return isSensitive;
 }
 
 void HTMLInputElement::registerForSuspensionCallbackIfNeeded()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to