REGRESSION (r238078): Do not draw caps lock indicator when Strong Password button...
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Nov 2018 04:17:11 +0000 (04:17 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Nov 2018 04:17:11 +0000 (04:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191969
<rdar://problem/46247569>

Reviewed by Dean Jackson.

Source/WebCore:

Following r238078 we now support drawing the caps lock indicator in password fields on iOS.
However it is not meaningful to show the caps lock indicator when the Strong Password button
is visible because the password field is not editable. We should not paint the caps lock
indicator when the Strong Password button is visible.

Tests: fast/forms/auto-fill-button/caps-lock-indicator-should-be-visible-after-hiding-auto-fill-strong-password-button.html
       fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible.html

* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::shouldDrawCapsLockIndicator const): Do not draw the caps
lock indicator when the password field has the Strong Password button.
(WebCore::TextFieldInputType::updateAutoFillButton): Call capsLockStateMayHaveChanged() to
update the visibility of the caps lock indicator when the auto fill button has changed.

LayoutTests:

Add tests to ensure that we show or hide the caps lock indicator depending on whether the
Strong Password button is visible.

* TestExpectations: Skip the tests below on all platforms. We will selectively enable them on Mac.
* fast/forms/auto-fill-button/caps-lock-indicator-should-be-visible-after-hiding-auto-fill-strong-password-button-expected.html: Added.
* fast/forms/auto-fill-button/caps-lock-indicator-should-be-visible-after-hiding-auto-fill-strong-password-button.html: Added.
* fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible-expected.html: Added.
* fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible.html: Added.
* platform/mac-wk2/TestExpectations: Mark the tests above as PASS so that we run them.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238545 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/forms/auto-fill-button/caps-lock-indicator-should-be-visible-after-hiding-auto-fill-strong-password-button-expected.html [new file with mode: 0644]
LayoutTests/fast/forms/auto-fill-button/caps-lock-indicator-should-be-visible-after-hiding-auto-fill-strong-password-button.html [new file with mode: 0644]
LayoutTests/fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible-expected.html [new file with mode: 0644]
LayoutTests/fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible.html [new file with mode: 0644]
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/html/TextFieldInputType.cpp

index 4c6164e..6efcf87 100644 (file)
@@ -1,3 +1,21 @@
+2018-11-26  Daniel Bates  <dabates@apple.com>
+
+        REGRESSION (r238078): Do not draw caps lock indicator when Strong Password button is shown
+        https://bugs.webkit.org/show_bug.cgi?id=191969
+        <rdar://problem/46247569>
+
+        Reviewed by Dean Jackson.
+
+        Add tests to ensure that we show or hide the caps lock indicator depending on whether the
+        Strong Password button is visible.
+
+        * TestExpectations: Skip the tests below on all platforms. We will selectively enable them on Mac.
+        * fast/forms/auto-fill-button/caps-lock-indicator-should-be-visible-after-hiding-auto-fill-strong-password-button-expected.html: Added.
+        * fast/forms/auto-fill-button/caps-lock-indicator-should-be-visible-after-hiding-auto-fill-strong-password-button.html: Added.
+        * fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible-expected.html: Added.
+        * fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible.html: Added.
+        * platform/mac-wk2/TestExpectations: Mark the tests above as PASS so that we run them.
+
 2018-11-26  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r238357.
index daa868a..53b7883 100644 (file)
@@ -399,8 +399,10 @@ fast/canvas/webgl/context-update-on-display-configuration.html [ Skip ]
 fast/misc/valid-primary-screen-displayID.html [ Skip ]
 
 fast/events/detect-caps-lock.html [ Skip ]
-fast/repaint/placeholder-after-caps-lock-hidden.html [ Skip ]
+fast/forms/auto-fill-button/caps-lock-indicator-should-be-visible-after-hiding-auto-fill-strong-password-button.html [ Skip ]
+fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible.html [ Skip ]
 fast/forms/password-scrolled-after-caps-lock-toggled.html [ Skip ]
+fast/repaint/placeholder-after-caps-lock-hidden.html [ Skip ]
 
 # This test currently only works for mac-wk2
 fast/events/inactive-window-no-mouse-event.html [ Skip ]
diff --git a/LayoutTests/fast/forms/auto-fill-button/caps-lock-indicator-should-be-visible-after-hiding-auto-fill-strong-password-button-expected.html b/LayoutTests/fast/forms/auto-fill-button/caps-lock-indicator-should-be-visible-after-hiding-auto-fill-strong-password-button-expected.html
new file mode 100644 (file)
index 0000000..6d7cf4f
--- /dev/null
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/ui-helper.js"></script>
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+</script>
+</head>
+<body>
+<p>This tests that the caps lock indicator is visible after hiding the Strong Password AutoFill button. It can only be tested in the test tool.</p>
+<input type="password" value="A quick brown fox jumped over the lazy dog.">
+<script>
+function done()
+{
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+function handleCapsLockEnabled(event)
+{
+    console.assert(event.key === "CapsLock");
+    // Move the caret to the beginning of the field to ensure consistent test results.
+    input.setSelectionRange(0, 0);
+    // FIXME: For some reason it takes up to 100ms for the caps lock indicator to be painted (why?).
+    window.setTimeout(done, 100);
+}
+
+async function runTest()
+{
+    if (!window.testRunner)
+        return;
+
+    let input = document.querySelector("input");
+
+    function handleFocus(event) {
+        console.assert(event.target === input);
+        input.addEventListener("keydown", handleCapsLockEnabled, { once: true });
+        UIHelper.toggleCapsLock();
+    }
+    input.addEventListener("focus", handleFocus, { once: true });
+    UIHelper.activateElement(input); // Puts caret in the center of the field; we will fix this up.
+}
+
+runTest();
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/auto-fill-button/caps-lock-indicator-should-be-visible-after-hiding-auto-fill-strong-password-button.html b/LayoutTests/fast/forms/auto-fill-button/caps-lock-indicator-should-be-visible-after-hiding-auto-fill-strong-password-button.html
new file mode 100644 (file)
index 0000000..d730948
--- /dev/null
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/ui-helper.js"></script>
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+</script>
+</head>
+<body>
+<p>This tests that the caps lock indicator is visible after hiding the Strong Password AutoFill button. It can only be tested in the test tool.</p>
+<input type="password" value="A quick brown fox jumped over the lazy dog.">
+<script>
+function done()
+{
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+function handleCapsLockEnabled(event)
+{
+    console.assert(event.key === "CapsLock");
+    let input = document.querySelector("input");
+    internals.setAutofilled(input, false);
+    internals.setShowAutoFillButton(input, "None");
+
+    // Move the caret to the beginning of the field to ensure consistent test results.
+    input.setSelectionRange(0, 0);
+
+    // FIXME: For some reason it takes up to 100ms for the caps lock indicator to be painted (why?).
+    window.setTimeout(done, 100);
+}
+
+async function runTest()
+{
+    if (!window.internals)
+        return;
+
+    let input = document.querySelector("input");
+    internals.setAutofilled(input, true);
+    internals.setShowAutoFillButton(input, "StrongPassword");
+
+    function handleFocus(event) {
+        console.assert(event.target === input);
+        input.addEventListener("keydown", handleCapsLockEnabled, { once: true });
+        UIHelper.toggleCapsLock();
+    }
+    input.addEventListener("focus", handleFocus, { once: true });
+    UIHelper.activateElement(input);
+}
+
+runTest();
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible-expected.html b/LayoutTests/fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible-expected.html
new file mode 100644 (file)
index 0000000..e434ff2
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/ui-helper.js"></script>
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+</script>
+</head>
+<body>
+<p>This tests that the caps lock indicator is not visible when the Strong Password AutoFill button is shown. It can only be tested in the test tool.</p>
+<input type="password" value="A quick brown fox jumped over the lazy dog.">
+<script>
+async function runTest()
+{
+    if (!window.internals)
+        return;
+
+    let input = document.querySelector("input");
+    internals.setAutofilled(input, true);
+    internals.setShowAutoFillButton(input, "StrongPassword");
+
+    input.addEventListener("focus", () => testRunner.notifyDone(), { once: true });
+    await UIHelper.activateElement(input);
+}
+
+runTest();
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible.html b/LayoutTests/fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible.html
new file mode 100644 (file)
index 0000000..8fa970e
--- /dev/null
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/ui-helper.js"></script>
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+</script>
+</head>
+<body>
+<p>This tests that the caps lock indicator is not visible when the Strong Password AutoFill button is shown. It can only be tested in the test tool.</p>
+<input type="password" value="A quick brown fox jumped over the lazy dog.">
+<script>
+function done()
+{
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+function handleCapsLockEnabled(event)
+{
+    console.assert(event.key === "CapsLock");
+    // FIXME: For some reason it takes up to 100ms for the caps lock indicator to be painted (why?).
+    window.setTimeout(done, 100);
+}
+
+async function runTest()
+{
+    if (!window.internals)
+        return;
+
+    let input = document.querySelector("input");
+    internals.setAutofilled(input, true);
+    internals.setShowAutoFillButton(input, "StrongPassword");
+
+    function handleFocus(event) {
+        console.assert(event.target === input);
+        input.addEventListener("keydown", handleCapsLockEnabled, { once: true });
+        UIHelper.toggleCapsLock();
+    }
+    input.addEventListener("focus", handleFocus, { once: true });
+    UIHelper.activateElement(input);
+}
+
+runTest();
+</script>
+</body>
+</html>
index 76fddc2..4e588ff 100644 (file)
@@ -68,8 +68,10 @@ webkit.org/b/187773 http/tests/webAPIStatistics [ Pass ]
 webkit.org/b/184569 storage/indexeddb/modern/transactions-stop-on-navigation.html [ Pass Failure ]
 
 [ Mojave+ ] fast/events/detect-caps-lock.html [ Pass ]
-[ Mojave+ ] fast/repaint/placeholder-after-caps-lock-hidden.html [ Pass ]
+[ Mojave+ ] fast/forms/auto-fill-button/caps-lock-indicator-should-be-visible-after-hiding-auto-fill-strong-password-button.html [ Pass ]
+[ Mojave+ ] fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible.html [ Pass ]
 [ Mojave+ ] fast/forms/password-scrolled-after-caps-lock-toggled.html [ Pass ]
+[ Mojave+ ] fast/repaint/placeholder-after-caps-lock-hidden.html [ Pass ]
 
 fast/events/inactive-window-no-mouse-event.html [ Pass ]
 
index a9534fe..61b2ade 100644 (file)
@@ -1,3 +1,25 @@
+2018-11-26  Daniel Bates  <dabates@apple.com>
+
+        REGRESSION (r238078): Do not draw caps lock indicator when Strong Password button is shown
+        https://bugs.webkit.org/show_bug.cgi?id=191969
+        <rdar://problem/46247569>
+
+        Reviewed by Dean Jackson.
+
+        Following r238078 we now support drawing the caps lock indicator in password fields on iOS.
+        However it is not meaningful to show the caps lock indicator when the Strong Password button
+        is visible because the password field is not editable. We should not paint the caps lock
+        indicator when the Strong Password button is visible.
+
+        Tests: fast/forms/auto-fill-button/caps-lock-indicator-should-be-visible-after-hiding-auto-fill-strong-password-button.html
+               fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible.html
+
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::shouldDrawCapsLockIndicator const): Do not draw the caps
+        lock indicator when the password field has the Strong Password button.
+        (WebCore::TextFieldInputType::updateAutoFillButton): Call capsLockStateMayHaveChanged() to
+        update the visibility of the caps lock indicator when the auto fill button has changed.
+
 2018-11-26  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r238357.
index ff770a6..471b77a 100644 (file)
@@ -724,6 +724,9 @@ bool TextFieldInputType::shouldDrawCapsLockIndicator() const
     if (element()->isDisabledOrReadOnly())
         return false;
 
+    if (element()->hasAutoFillStrongPasswordButton())
+        return false;
+
     RefPtr<Frame> frame = element()->document().frame();
     if (!frame)
         return false;
@@ -792,6 +795,8 @@ void TextFieldInputType::createAutoFillButton(AutoFillButtonType autoFillButtonT
 
 void TextFieldInputType::updateAutoFillButton()
 {
+    capsLockStateMayHaveChanged();
+
     if (shouldDrawAutoFillButton()) {
         if (!m_container)
             createContainer();