Title: [231517] trunk
Revision
231517
Author
[email protected]
Date
2018-05-08 16:16:33 -0700 (Tue, 08 May 2018)

Log Message

Resign Strong Password appearance when text field value changes
https://bugs.webkit.org/show_bug.cgi?id=185433
<rdar://problem/39958508>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Remove the Strong Password decoration when the text field's value changes to avoid interfering
with web sites that allow a person to clear the password field.

Tests: fast/forms/auto-fill-button/auto-fill-strong-password-button-when-maxlength-changes.html
       fast/forms/auto-fill-button/auto-fill-strong-password-button-when-minlength-changes.html
       fast/forms/auto-fill-button/hide-auto-fill-strong-password-button-when-value-changes.html

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::resignStrongPasswordAppearance): Extracted from HTMLInputElement::updateType().
(WebCore::HTMLInputElement::updateType): Extract out logic to resign the Strong Password appearance
into a function that can be shared by this function and HTMLInputElement::setValue().
(WebCore::HTMLInputElement::setValue): Resign the Strong Password appearance if this field was
changed programmatically (i.e. no DOM change event was dispatched).
* html/HTMLInputElement.h:

Tools:

Add a unit test to ensure the injected bundle API and WebKit UI delegate SPI is invoked
when the field has the Strong Password button and its value changes.

* TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
(testDidResignInputElementStrongPasswordAppearanceAfterEvaluatingJavaScript):
(TEST):

LayoutTests:

Add a test to ensure we remove the Strong Password appearance when the value of the text field value changes.

* fast/forms/auto-fill-button/auto-fill-strong-password-button-when-maxlength-changes-expected.html: Added.
* fast/forms/auto-fill-button/auto-fill-strong-password-button-when-maxlength-changes.html: Added.
* fast/forms/auto-fill-button/auto-fill-strong-password-button-when-minlength-changes-expected.html: Added.
* fast/forms/auto-fill-button/auto-fill-strong-password-button-when-minlength-changes.html: Added.
* fast/forms/auto-fill-button/hide-auto-fill-strong-password-button-when-value-changes-expected.html: Added.
* fast/forms/auto-fill-button/hide-auto-fill-strong-password-button-when-value-changes.html: Added.
* fast/forms/auto-fill-button/resources/process-auto-fill-button-type-and-invoke-runTest.js: Add support for
setting the autofilled state of a field.
(window.onload):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (231516 => 231517)


--- trunk/LayoutTests/ChangeLog	2018-05-08 23:12:09 UTC (rev 231516)
+++ trunk/LayoutTests/ChangeLog	2018-05-08 23:16:33 UTC (rev 231517)
@@ -1,3 +1,23 @@
+2018-05-08  Daniel Bates  <[email protected]>
+
+        Resign Strong Password appearance when text field value changes
+        https://bugs.webkit.org/show_bug.cgi?id=185433
+        <rdar://problem/39958508>
+
+        Reviewed by Ryosuke Niwa.
+
+        Add a test to ensure we remove the Strong Password appearance when the value of the text field value changes.
+
+        * fast/forms/auto-fill-button/auto-fill-strong-password-button-when-maxlength-changes-expected.html: Added.
+        * fast/forms/auto-fill-button/auto-fill-strong-password-button-when-maxlength-changes.html: Added.
+        * fast/forms/auto-fill-button/auto-fill-strong-password-button-when-minlength-changes-expected.html: Added.
+        * fast/forms/auto-fill-button/auto-fill-strong-password-button-when-minlength-changes.html: Added.
+        * fast/forms/auto-fill-button/hide-auto-fill-strong-password-button-when-value-changes-expected.html: Added.
+        * fast/forms/auto-fill-button/hide-auto-fill-strong-password-button-when-value-changes.html: Added.
+        * fast/forms/auto-fill-button/resources/process-auto-fill-button-type-and-invoke-runTest.js: Add support for
+        setting the autofilled state of a field.
+        (window.onload):
+
 2018-05-08  Eric Carlson  <[email protected]>
 
         Consecutive messages logged as JSON are coalesced

Added: trunk/LayoutTests/fast/forms/auto-fill-button/auto-fill-strong-password-button-when-maxlength-changes-expected.html (0 => 231517)


--- trunk/LayoutTests/fast/forms/auto-fill-button/auto-fill-strong-password-button-when-maxlength-changes-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/auto-fill-button/auto-fill-strong-password-button-when-maxlength-changes-expected.html	2018-05-08 23:16:33 UTC (rev 231517)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+function runTest()
+{
+    if (window.internals)
+        internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks();
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+</script>
+</head>
+<body>
+<p>This tests that an autofilled Strong Password or Strong Confirmation Password decorated text field does not change appearance when its maxlength changes. It can only be tested in the test tool.</p>
+<input type="password" value="Cupertino" maxlength="100" data-auto-fill-button-type="StrongPassword" data-autofilled="true">
+<input type="password" value="Cupertino" maxlength="100" data-auto-fill-button-type="StrongConfirmationPassword" data-autofilled="true">
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/auto-fill-button/auto-fill-strong-password-button-when-maxlength-changes.html (0 => 231517)


--- trunk/LayoutTests/fast/forms/auto-fill-button/auto-fill-strong-password-button-when-maxlength-changes.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/auto-fill-button/auto-fill-strong-password-button-when-maxlength-changes.html	2018-05-08 23:16:33 UTC (rev 231517)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+function runTest()
+{
+    let inputElements = document.getElementsByTagName("input");
+    for (let inputElement of inputElements)
+        inputElement.maxlength = 5;
+    if (window.internals)
+        internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks();
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+</script>
+</head>
+<body>
+<p>This tests that an autofilled Strong Password or Strong Confirmation Password decorated text field does not change appearance when its maxlength changes. It can only be tested in the test tool.</p>
+<input type="password" value="Cupertino" maxlength="100" data-auto-fill-button-type="StrongPassword" data-autofilled="true">
+<input type="password" value="Cupertino" maxlength="100" data-auto-fill-button-type="StrongConfirmationPassword" data-autofilled="true">
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/auto-fill-button/auto-fill-strong-password-button-when-minlength-changes-expected.html (0 => 231517)


--- trunk/LayoutTests/fast/forms/auto-fill-button/auto-fill-strong-password-button-when-minlength-changes-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/auto-fill-button/auto-fill-strong-password-button-when-minlength-changes-expected.html	2018-05-08 23:16:33 UTC (rev 231517)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+function runTest()
+{
+    if (window.internals)
+        internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks();
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+</script>
+</head>
+<body>
+<p>This tests that an autofilled Strong Password or Strong Confirmation Password decorated text field does not change appearance when its minlength changes. It can only be tested in the test tool.</p>
+<input type="password" value="Cupertino" minlength="5" data-auto-fill-button-type="StrongPassword" data-autofilled="true">
+<input type="password" value="Cupertino" minlength="5" data-auto-fill-button-type="StrongConfirmationPassword" data-autofilled="true">
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/auto-fill-button/auto-fill-strong-password-button-when-minlength-changes.html (0 => 231517)


--- trunk/LayoutTests/fast/forms/auto-fill-button/auto-fill-strong-password-button-when-minlength-changes.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/auto-fill-button/auto-fill-strong-password-button-when-minlength-changes.html	2018-05-08 23:16:33 UTC (rev 231517)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+function runTest()
+{
+    let inputElements = document.getElementsByTagName("input");
+    for (let inputElement of inputElements)
+        inputElement.minlength = 100;
+    if (window.internals)
+        internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks();
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+</script>
+</head>
+<body>
+<p>This tests that an autofilled Strong Password or Strong Confirmation Password decorated text field does not change appearance when its minlength changes. It can only be tested in the test tool.</p>
+<input type="password" value="Cupertino" minlength="5" data-auto-fill-button-type="StrongPassword" data-autofilled="true">
+<input type="password" value="Cupertino" minlength="5" data-auto-fill-button-type="StrongConfirmationPassword" data-autofilled="true">
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-strong-password-button-when-value-changes-expected.html (0 => 231517)


--- trunk/LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-strong-password-button-when-value-changes-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-strong-password-button-when-value-changes-expected.html	2018-05-08 23:16:33 UTC (rev 231517)
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests that that an autofilled Strong Password or Strong Confirmation Password decorated text field reverts to its original appearance when its value changes. It can only be tested in the test tool.</p>
+<input type="password" value="">
+<input type="password" value="">
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-strong-password-button-when-value-changes.html (0 => 231517)


--- trunk/LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-strong-password-button-when-value-changes.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-strong-password-button-when-value-changes.html	2018-05-08 23:16:33 UTC (rev 231517)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+function runTest()
+{
+    let inputElements = document.getElementsByTagName("input");
+    for (let inputElement of inputElements)
+        inputElement.value = "";
+    if (window.internals)
+        internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks();
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+</script>
+</head>
+<body>
+<p>This tests that that an autofilled Strong Password or Strong Confirmation Password decorated text field reverts to its original appearance when its value changes. It can only be tested in the test tool.</p>
+<input type="password" value="Cupertino" data-auto-fill-button-type="StrongPassword" data-autofilled="true">
+<input type="password" value="Cupertino" data-auto-fill-button-type="StrongConfirmationPassword" data-autofilled="true">
+</body>
+</html>

Modified: trunk/LayoutTests/fast/forms/auto-fill-button/resources/process-auto-fill-button-type-and-invoke-runTest.js (231516 => 231517)


--- trunk/LayoutTests/fast/forms/auto-fill-button/resources/process-auto-fill-button-type-and-invoke-runTest.js	2018-05-08 23:12:09 UTC (rev 231516)
+++ trunk/LayoutTests/fast/forms/auto-fill-button/resources/process-auto-fill-button-type-and-invoke-runTest.js	2018-05-08 23:16:33 UTC (rev 231517)
@@ -5,8 +5,10 @@
         return;
     }
     let inputElements = document.getElementsByTagName("input");
-    for (let inputElement of inputElements)
+    for (let inputElement of inputElements) {
+        internals.setAutofilled(inputElement, inputElement.dataset.autofilled == "true");
         internals.setShowAutoFillButton(inputElement, inputElement.dataset.autoFillButtonType);
+    }
     if (window.runTest)
         window.runTest();
 }

Modified: trunk/Source/WebCore/ChangeLog (231516 => 231517)


--- trunk/Source/WebCore/ChangeLog	2018-05-08 23:12:09 UTC (rev 231516)
+++ trunk/Source/WebCore/ChangeLog	2018-05-08 23:16:33 UTC (rev 231517)
@@ -1,3 +1,26 @@
+2018-05-08  Daniel Bates  <[email protected]>
+
+        Resign Strong Password appearance when text field value changes
+        https://bugs.webkit.org/show_bug.cgi?id=185433
+        <rdar://problem/39958508>
+
+        Reviewed by Ryosuke Niwa.
+
+        Remove the Strong Password decoration when the text field's value changes to avoid interfering
+        with web sites that allow a person to clear the password field.
+
+        Tests: fast/forms/auto-fill-button/auto-fill-strong-password-button-when-maxlength-changes.html
+               fast/forms/auto-fill-button/auto-fill-strong-password-button-when-minlength-changes.html
+               fast/forms/auto-fill-button/hide-auto-fill-strong-password-button-when-value-changes.html
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::resignStrongPasswordAppearance): Extracted from HTMLInputElement::updateType().
+        (WebCore::HTMLInputElement::updateType): Extract out logic to resign the Strong Password appearance
+        into a function that can be shared by this function and HTMLInputElement::setValue().
+        (WebCore::HTMLInputElement::setValue): Resign the Strong Password appearance if this field was
+        changed programmatically (i.e. no DOM change event was dispatched).
+        * html/HTMLInputElement.h:
+
 2018-05-08  Jer Noble  <[email protected]>
 
         Unreviewed build fix; add missing function definition.

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (231516 => 231517)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2018-05-08 23:12:09 UTC (rev 231516)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2018-05-08 23:16:33 UTC (rev 231517)
@@ -488,6 +488,16 @@
     setAttributeWithoutSynchronization(typeAttr, type);
 }
 
+void HTMLInputElement::resignStrongPasswordAppearance()
+{
+    if (!hasAutoFillStrongPasswordButton())
+        return;
+    setAutoFilled(false);
+    setShowAutoFillButton(AutoFillButtonType::None);
+    if (auto* page = document().page())
+        page->chrome().client().inputElementDidResignStrongPasswordAppearance(*this);
+}
+
 void HTMLInputElement::updateType()
 {
     ASSERT(m_inputType);
@@ -497,14 +507,8 @@
         return;
 
     removeFromRadioButtonGroup();
+    resignStrongPasswordAppearance();
 
-    if (hasAutoFillStrongPasswordButton()) {
-        setAutoFilled(false);
-        setShowAutoFillButton(AutoFillButtonType::None);
-        if (auto* page = document().page())
-            page->chrome().client().inputElementDidResignStrongPasswordAppearance(*this);
-    }
-
     bool didStoreValue = m_inputType->storesValueSeparateFromAttribute();
     bool willStoreValue = newType->storesValueSeparateFromAttribute();
     bool neededSuspensionCallback = needsSuspensionCallback();
@@ -1064,6 +1068,10 @@
     setLastChangeWasNotUserEdit();
     setFormControlValueMatchesRenderer(false);
     m_inputType->setValue(sanitizedValue, valueChanged, eventBehavior);
+
+    bool wasModifiedProgrammatically = eventBehavior == DispatchNoEvent;
+    if (wasModifiedProgrammatically)
+        resignStrongPasswordAppearance();
     return { };
 }
 

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (231516 => 231517)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2018-05-08 23:12:09 UTC (rev 231516)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2018-05-08 23:16:33 UTC (rev 231517)
@@ -377,6 +377,8 @@
     FormControlState saveFormControlState() const final;
     void restoreFormControlState(const FormControlState&) final;
 
+    void resignStrongPasswordAppearance();
+
     bool canStartSelection() const final;
 
     void accessKeyAction(bool sendMouseEvents) final;

Modified: trunk/Tools/ChangeLog (231516 => 231517)


--- trunk/Tools/ChangeLog	2018-05-08 23:12:09 UTC (rev 231516)
+++ trunk/Tools/ChangeLog	2018-05-08 23:16:33 UTC (rev 231517)
@@ -1,3 +1,18 @@
+2018-05-08  Daniel Bates  <[email protected]>
+
+        Resign Strong Password appearance when text field value changes
+        https://bugs.webkit.org/show_bug.cgi?id=185433
+        <rdar://problem/39958508>
+
+        Reviewed by Ryosuke Niwa.
+
+        Add a unit test to ensure the injected bundle API and WebKit UI delegate SPI is invoked
+        when the field has the Strong Password button and its value changes.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
+        (testDidResignInputElementStrongPasswordAppearanceAfterEvaluatingJavaScript):
+        (TEST):
+
 2018-05-06  Filip Pizlo  <[email protected]>
 
         InPlaceAbstractState::beginBasicBlock shouldn't have to clear any abstract values

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm (231516 => 231517)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm	2018-05-08 23:12:09 UTC (rev 231516)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm	2018-05-08 23:16:33 UTC (rev 231517)
@@ -574,9 +574,10 @@
 
 @end
 
-TEST(WebKit, DidResignInputElementStrongPasswordAppearance)
+static void testDidResignInputElementStrongPasswordAppearanceAfterEvaluatingJavaScript(NSString *script)
 {
     done = false;
+    readytoResign = false;
     WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"DidResignInputElementStrongPasswordAppearance"];
 
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration]);
@@ -583,10 +584,20 @@
     auto delegate = adoptNS([[DidResignInputElementStrongPasswordAppearanceDelegate alloc] init]);
     [webView setUIDelegate:delegate.get()];
     TestWebKitAPI::Util::run(&readytoResign);
-    [webView evaluateJavaScript:@"document.querySelector('input').type = 'text'" completionHandler:nil];
+    [webView evaluateJavaScript:script completionHandler:nil];
     TestWebKitAPI::Util::run(&done);
 }
 
+TEST(WebKit, DidResignInputElementStrongPasswordAppearanceWhenTypeDidChange)
+{
+    testDidResignInputElementStrongPasswordAppearanceAfterEvaluatingJavaScript(@"document.querySelector('input').type = 'text'");
+}
+
+TEST(WebKit, DidResignInputElementStrongPasswordAppearanceWhenValueDidChange)
+{
+    testDidResignInputElementStrongPasswordAppearanceAfterEvaluatingJavaScript(@"document.querySelector('input').value = ''");
+}
+
 @interface AutoFillAvailableDelegate : NSObject <WKUIDelegatePrivate>
 @end
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to