- Revision
- 291426
- Author
- [email protected]
- Date
- 2022-03-17 12:02:47 -0700 (Thu, 17 Mar 2022)
Log Message
When a “autofilled and obscured” field becomes empty, turn “autofilled and obscured” off
https://bugs.webkit.org/show_bug.cgi?id=235256
Patch by Ellie Epskamp-Hunt <[email protected]> on 2022-03-17
Reviewed by Devin Rousso.
Source/WebCore:
Tests: fast/forms/input-autofilled-and-obscured-clear-field-programatically.html
fast/forms/input-autofilled-and-obscured-clear-form-programatically.html
fast/forms/input-autofilled-and-obscured.html
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::setValue):
Turn off the property if the page's _javascript_ deletes all the text in the field.
(WebCore::HTMLInputElement::setValueFromRenderer):
Turn off the property if the user deletes all the text in the field.
LayoutTests:
Add tests to verify that when a text field becomes empty, the autofilled-and-obscured
property is removed from that field.
* fast/forms/input-autofilled-and-obscured-clear-field-programatically-expected.txt: Added.
* fast/forms/input-autofilled-and-obscured-clear-field-programatically.html: Added.
Delete the text by setting the input's value to an empty string.
* fast/forms/input-autofilled-and-obscured-clear-form-programatically-expected.txt: Added.
* fast/forms/input-autofilled-and-obscured-clear-form-programatically.html: Added.
Delete the text by calling reset on the form.
* fast/forms/input-autofilled-and-obscured-expected.txt: Added.
* fast/forms/input-autofilled-and-obscured.html: Added.
Delete the text as a user would.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (291425 => 291426)
--- trunk/LayoutTests/ChangeLog 2022-03-17 18:55:43 UTC (rev 291425)
+++ trunk/LayoutTests/ChangeLog 2022-03-17 19:02:47 UTC (rev 291426)
@@ -1,3 +1,23 @@
+2022-03-17 Ellie Epskamp-Hunt <[email protected]>
+
+ When a “autofilled and obscured” field becomes empty, turn “autofilled and obscured” off
+ https://bugs.webkit.org/show_bug.cgi?id=235256
+
+ Reviewed by Devin Rousso.
+
+ Add tests to verify that when a text field becomes empty, the autofilled-and-obscured
+ property is removed from that field.
+
+ * fast/forms/input-autofilled-and-obscured-clear-field-programatically-expected.txt: Added.
+ * fast/forms/input-autofilled-and-obscured-clear-field-programatically.html: Added.
+ Delete the text by setting the input's value to an empty string.
+ * fast/forms/input-autofilled-and-obscured-clear-form-programatically-expected.txt: Added.
+ * fast/forms/input-autofilled-and-obscured-clear-form-programatically.html: Added.
+ Delete the text by calling reset on the form.
+ * fast/forms/input-autofilled-and-obscured-expected.txt: Added.
+ * fast/forms/input-autofilled-and-obscured.html: Added.
+ Delete the text as a user would.
+
2022-03-17 Ben Nham <[email protected]>
Only show notification permission prompt on user gesture
Added: trunk/LayoutTests/fast/forms/input-autofilled-and-obscured-clear-field-programatically-expected.txt (0 => 291426)
--- trunk/LayoutTests/fast/forms/input-autofilled-and-obscured-clear-field-programatically-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/input-autofilled-and-obscured-clear-field-programatically-expected.txt 2022-03-17 19:02:47 UTC (rev 291426)
@@ -0,0 +1,4 @@
+This tests that foreground and background colors properly change for autofilled-and-obscured inputs. It can only be run using DumpRenderTree.
+
+PASS
+
Added: trunk/LayoutTests/fast/forms/input-autofilled-and-obscured-clear-field-programatically.html (0 => 291426)
--- trunk/LayoutTests/fast/forms/input-autofilled-and-obscured-clear-field-programatically.html (rev 0)
+++ trunk/LayoutTests/fast/forms/input-autofilled-and-obscured-clear-field-programatically.html 2022-03-17 19:02:47 UTC (rev 291426)
@@ -0,0 +1,63 @@
+<html>
+<head>
+ <script src=""
+ <script>
+ function test() {
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ }
+
+ var tf = document.getElementById('tf');
+ var computedStyle = document.defaultView.getComputedStyle(tf);
+ var originalForeground = computedStyle.color;
+ var originalBackground = computedStyle.backgroundColor;
+
+ if (window.internals) {
+ window.internals.setAutoFilledAndObscured(tf, true);
+ }
+
+ // Both the foreground and background colors should change.
+ computedStyle = document.defaultView.getComputedStyle(tf);
+ var autofilledForeground = computedStyle.color;
+ var autofilledBackground = computedStyle.backgroundColor;
+ if (autofilledForeground == originalForeground) {
+ testFailed('Foreground color did not change when autofilled.');
+ return;
+ }
+ if (autofilledBackground == originalBackground) {
+ testFailed('Background color did not change when autofilled.');
+ return;
+ }
+
+ tf.value = "";
+
+ // Colors should be restored.
+ computedStyle = document.defaultView.getComputedStyle(tf);
+ if (computedStyle.color !== originalForeground) {
+ testFailed('Foreground color did not revert when field was emptied.');
+ return;
+ }
+ if (computedStyle.backgroundColor !== originalBackground) {
+ testFailed('Background color did not revert when field was emptied.');
+ return;
+ }
+
+ testPassed('');
+ }
+ </script>
+
+ <style>
+ #tf {
+ color: #FFFFFF;
+ background-color: #FFFFFF;
+ }
+ </style>
+</head>
+<body _onload_="test()">
+ This tests that foreground and background colors properly change for autofilled-and-obscured inputs. It can only be run using DumpRenderTree.<br>
+ <form name="fm">
+ <input type="text" id="tf" value="Field value" />
+ </form>
+ <div id="console"></div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/input-autofilled-and-obscured-clear-form-programatically-expected.txt (0 => 291426)
--- trunk/LayoutTests/fast/forms/input-autofilled-and-obscured-clear-form-programatically-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/input-autofilled-and-obscured-clear-form-programatically-expected.txt 2022-03-17 19:02:47 UTC (rev 291426)
@@ -0,0 +1,4 @@
+This tests that foreground and background colors properly change for autofilled-and-obscured inputs. It can only be run using DumpRenderTree.
+
+PASS
+
Added: trunk/LayoutTests/fast/forms/input-autofilled-and-obscured-clear-form-programatically.html (0 => 291426)
--- trunk/LayoutTests/fast/forms/input-autofilled-and-obscured-clear-form-programatically.html (rev 0)
+++ trunk/LayoutTests/fast/forms/input-autofilled-and-obscured-clear-form-programatically.html 2022-03-17 19:02:47 UTC (rev 291426)
@@ -0,0 +1,63 @@
+<html>
+<head>
+ <script src=""
+ <script>
+ function test() {
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ }
+
+ var tf = document.getElementById('tf');
+ var computedStyle = document.defaultView.getComputedStyle(tf);
+ var originalForeground = computedStyle.color;
+ var originalBackground = computedStyle.backgroundColor;
+
+ if (window.internals) {
+ window.internals.setAutoFilledAndObscured(tf, true);
+ }
+
+ // Both the foreground and background colors should change.
+ computedStyle = document.defaultView.getComputedStyle(tf);
+ var autofilledForeground = computedStyle.color;
+ var autofilledBackground = computedStyle.backgroundColor;
+ if (autofilledForeground == originalForeground) {
+ testFailed('Foreground color did not change when autofilled.');
+ return;
+ }
+ if (autofilledBackground == originalBackground) {
+ testFailed('Background color did not change when autofilled.');
+ return;
+ }
+
+ tf.form.reset();
+
+ // Colors should be restored.
+ computedStyle = document.defaultView.getComputedStyle(tf);
+ if (computedStyle.color !== originalForeground) {
+ testFailed('Foreground color did not revert when field was emptied.');
+ return;
+ }
+ if (computedStyle.backgroundColor !== originalBackground) {
+ testFailed('Background color did not revert when field was emptied.');
+ return;
+ }
+
+ testPassed('');
+ }
+ </script>
+
+ <style>
+ #tf {
+ color: #FFFFFF;
+ background-color: #FFFFFF;
+ }
+ </style>
+</head>
+<body _onload_="test()">
+ This tests that foreground and background colors properly change for autofilled-and-obscured inputs. It can only be run using DumpRenderTree.<br>
+ <form name="fm">
+ <input type="text" id="tf" value="Field value" />
+ </form>
+ <div id="console"></div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/input-autofilled-and-obscured-expected.txt (0 => 291426)
--- trunk/LayoutTests/fast/forms/input-autofilled-and-obscured-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/input-autofilled-and-obscured-expected.txt 2022-03-17 19:02:47 UTC (rev 291426)
@@ -0,0 +1,4 @@
+This tests that foreground and background colors properly change for autofilled-and-obscured inputs. It can only be run using DumpRenderTree.
+
+PASS
+
Added: trunk/LayoutTests/fast/forms/input-autofilled-and-obscured.html (0 => 291426)
--- trunk/LayoutTests/fast/forms/input-autofilled-and-obscured.html (rev 0)
+++ trunk/LayoutTests/fast/forms/input-autofilled-and-obscured.html 2022-03-17 19:02:47 UTC (rev 291426)
@@ -0,0 +1,65 @@
+<html>
+<head>
+ <script src=""
+ <script>
+ function test() {
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ }
+
+ var tf = document.getElementById('tf');
+ var computedStyle = document.defaultView.getComputedStyle(tf);
+ var originalForeground = computedStyle.color;
+ var originalBackground = computedStyle.backgroundColor;
+
+ if (window.internals) {
+ window.internals.setAutoFilledAndObscured(tf, true);
+ }
+
+ // Both the foreground and background colors should change.
+ computedStyle = document.defaultView.getComputedStyle(tf);
+ var autofilledForeground = computedStyle.color;
+ var autofilledBackground = computedStyle.backgroundColor;
+ if (autofilledForeground == originalForeground) {
+ testFailed('Foreground color did not change when autofilled.');
+ return;
+ }
+ if (autofilledBackground == originalBackground) {
+ testFailed('Background color did not change when autofilled.');
+ return;
+ }
+
+ tf.focus();
+ document.execCommand("SelectAll");
+ document.execCommand("Delete");
+
+ // Colors should be restored.
+ computedStyle = document.defaultView.getComputedStyle(tf);
+ if (computedStyle.color !== originalForeground) {
+ testFailed('Foreground color did not revert when field was emptied.');
+ return;
+ }
+ if (computedStyle.backgroundColor !== originalBackground) {
+ testFailed('Background color did not revert when field was emptied.');
+ return;
+ }
+
+ testPassed('');
+ }
+ </script>
+
+ <style>
+ #tf {
+ color: #FFFFFF;
+ background-color: #FFFFFF;
+ }
+ </style>
+</head>
+<body _onload_="test()">
+ This tests that foreground and background colors properly change for autofilled-and-obscured inputs. It can only be run using DumpRenderTree.<br>
+ <form name="fm">
+ <input type="text" id="tf" value="Field value" />
+ </form>
+ <div id="console"></div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (291425 => 291426)
--- trunk/Source/WebCore/ChangeLog 2022-03-17 18:55:43 UTC (rev 291425)
+++ trunk/Source/WebCore/ChangeLog 2022-03-17 19:02:47 UTC (rev 291426)
@@ -1,3 +1,20 @@
+2022-03-17 Ellie Epskamp-Hunt <[email protected]>
+
+ When a “autofilled and obscured” field becomes empty, turn “autofilled and obscured” off
+ https://bugs.webkit.org/show_bug.cgi?id=235256
+
+ Reviewed by Devin Rousso.
+
+ Tests: fast/forms/input-autofilled-and-obscured-clear-field-programatically.html
+ fast/forms/input-autofilled-and-obscured-clear-form-programatically.html
+ fast/forms/input-autofilled-and-obscured.html
+
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::setValue):
+ Turn off the property if the page's _javascript_ deletes all the text in the field.
+ (WebCore::HTMLInputElement::setValueFromRenderer):
+ Turn off the property if the user deletes all the text in the field.
+
2022-03-17 J Pascoe <[email protected]>
[WebAuthn] Support makeCredential for virtual HID authenticators
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (291425 => 291426)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2022-03-17 18:55:43 UTC (rev 291425)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2022-03-17 19:02:47 UTC (rev 291426)
@@ -1082,8 +1082,13 @@
m_inputType->setValue(sanitizedValue, valueChanged, eventBehavior, selection);
bool wasModifiedProgrammatically = eventBehavior == DispatchNoEvent;
- if (wasModifiedProgrammatically)
+ if (wasModifiedProgrammatically) {
resignStrongPasswordAppearance();
+
+ if (m_isAutoFilledAndObscured)
+ setAutoFilledAndObscured(false);
+ }
+
return { };
}
@@ -1144,8 +1149,15 @@
// We clear certain AutoFill flags here because this catches user edits.
setAutoFilled(false);
- if (m_isAutoFilledAndViewable && value.isEmpty())
+
+ if (!value.isEmpty())
+ return;
+
+ if (m_isAutoFilledAndViewable)
setAutoFilledAndViewable(false);
+
+ if (m_isAutoFilledAndObscured)
+ setAutoFilledAndObscured(false);
}
void HTMLInputElement::willDispatchEvent(Event& event, InputElementClickState& state)