REGRESSION (r230523): Caps lock indicator not shown in password field
authorpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2018 21:58:29 +0000 (21:58 +0000)
committerpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2018 21:58:29 +0000 (21:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190056

Reviewed by Ryosuke Niwa.

Source/WebCore:

When WindowServer access is blocked, GetCurrentModifiers() always returns 0. Instead of calling
GetCurrentModifiers(), store the current modifiers from the key event argument in the method
WebKit::WebPage::keyEvent, and use the stored value to detect if Caps lock is on. Additionally,
the modifiers needs to be updated when the window becomes active.

Test: fast/events/detect-caps-lock.html

* Sources.txt:
* platform/PlatformKeyboardEvent.h:
* platform/graphics/FontTaggedSettings.cpp:
* platform/mac/KeyEventMac.mm:
(WebCore::PlatformKeyboardEvent::currentCapsLockState):
(WebCore::PlatformKeyboardEvent::getCurrentModifierState):
* testing/Internals.cpp:
(WebCore::Internals::capsLockIsOn):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

Update cached modifier state in the WebProcess when WebKit::WebPage::keyEvent is called, and
when the window becomes active.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::dispatchActivityStateChange):
(WebKit::WebPageProxy::updateCurrentModifierState):
* UIProcess/WebPageProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::keyEvent):
(WebKit::WebPage::updateCurrentModifierState):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Tools:

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::toggleCapsLock):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::toggleCapsLock):

LayoutTests:

* TestExpectations:
* fast/events/detect-caps-lock-expected.txt: Added.
* fast/events/detect-caps-lock.html: Added.
* platform/mac/TestExpectations:

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

28 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/events/detect-caps-lock-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/detect-caps-lock.html [new file with mode: 0644]
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Sources.txt
Source/WebCore/platform/PlatformKeyboardEvent.cpp [new file with mode: 0644]
Source/WebCore/platform/PlatformKeyboardEvent.h
Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp
Source/WebCore/platform/mac/KeyEventMac.mm
Source/WebCore/platform/mediarecorder/MediaRecorderPrivate.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp
Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm

index d108477..7697618 100644 (file)
@@ -1,3 +1,15 @@
+2018-11-06  Per Arne Vollan  <pvollan@apple.com>
+
+        REGRESSION (r230523): Caps lock indicator not shown in password field
+        https://bugs.webkit.org/show_bug.cgi?id=190056
+
+        Reviewed by Ryosuke Niwa.
+
+        * TestExpectations:
+        * fast/events/detect-caps-lock-expected.txt: Added.
+        * fast/events/detect-caps-lock.html: Added.
+        * platform/mac/TestExpectations:
+
 2018-11-06  Ali Juma  <ajuma@chromium.org>
 
         IntersectionObserver doesn't keep target's JS wrapper alive
index 8dc9070..db9ab2f 100644 (file)
@@ -422,6 +422,8 @@ 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 ]
+
 # This test currently only works for mac-wk2
 fast/events/inactive-window-no-mouse-event.html [ Skip ]
 
diff --git a/LayoutTests/fast/events/detect-caps-lock-expected.txt b/LayoutTests/fast/events/detect-caps-lock-expected.txt
new file mode 100644 (file)
index 0000000..70ae6e2
--- /dev/null
@@ -0,0 +1,16 @@
+This test verifies that the function WebCore::currentCapsLockState() returns true when Caps Lock is on.
+
+
+1. Press Caps Lock key when view is active, make view inactive, make view active again, press Caps Lock key.
+CapsLock is on.
+CapsLock is not on.
+2. Press Caps Lock key in inactive view, make view active, press Caps Lock key.
+CapsLock is on.
+CapsLock is not on.
+3. Press Caps Lock key when view is active, press Caps Lock key when view is active.
+CapsLock is on.
+CapsLock is not on.
+4. Press Caps Lock key when view is inactive, press Caps Lock key when view inactive.
+CapsLock is on.
+CapsLock is not on.
+
diff --git a/LayoutTests/fast/events/detect-caps-lock.html b/LayoutTests/fast/events/detect-caps-lock.html
new file mode 100644 (file)
index 0000000..276b5f6
--- /dev/null
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html><head></head>
+    <body>
+        <p>This test verifies that the function WebCore::currentCapsLockState() returns true when Caps Lock is on.</p>
+        <input type="password"></input>
+        <div id="log"></div>
+        
+        <script>
+            function log(msg) {
+                document.getElementById("log").innerHTML+= msg + "<br>";
+            }
+        
+            function keyDown(e) {
+                if (e.key == "q")
+                    return;
+                if (window.internals) {
+                    log(messages[messageCount++]);
+                    if (window.internals.capsLockIsOn())
+                        log("CapsLock is on.");
+                    else
+                        log("CapsLock is not on.");
+                }
+            }
+
+            function keyUp(e) {
+                if (e.key == "q")
+                    testRunner.notifyDone();
+                if (window.internals) {
+                    if (window.internals.capsLockIsOn())
+                        log("CapsLock is on.");
+                    else
+                        log("CapsLock is not on.");
+                }
+            }
+
+            var messages = ["1. Press Caps Lock key when view is active, make view inactive, make view active again, press Caps Lock key.",
+                            "2. Press Caps Lock key in inactive view, make view active, press Caps Lock key.",
+                            "3. Press Caps Lock key when view is active, press Caps Lock key when view is active.",
+                            "4. Press Caps Lock key when view is inactive, press Caps Lock key when view inactive."];
+            var messageCount = 0;
+        
+            var input = document.getElementsByTagName("input")[0];
+            input.addEventListener('keydown', keyDown, false);
+            input.addEventListener('keyup', keyUp, false);
+            input.focus();
+            
+            if (window.testRunner) {
+                testRunner.dumpAsText();
+                testRunner.waitUntilDone();
+                
+                testRunner.toggleCapsLock();
+                testRunner.setWindowIsKey(false);
+                testRunner.setWindowIsKey(true);
+                testRunner.toggleCapsLock();
+                
+                testRunner.setWindowIsKey(false);
+                testRunner.toggleCapsLock();
+                testRunner.setWindowIsKey(true);
+                testRunner.toggleCapsLock();
+
+                testRunner.setWindowIsKey(true);
+                testRunner.toggleCapsLock();
+                testRunner.toggleCapsLock();
+
+                testRunner.setWindowIsKey(false);
+                testRunner.toggleCapsLock();
+                testRunner.toggleCapsLock();
+
+                eventSender.keyDown("q", []);
+            }
+        </script>
+    </body>
+</html>
index e793894..a338efb 100644 (file)
@@ -40,6 +40,8 @@ http/tests/gzip-content-encoding [ Pass ]
 fast/text/mac [ Pass ]
 webkit.org/b/181964 fast/text/mac/select-character-before-zero-width-joiner.html [ ImageOnlyFailure ]
 
+[ Mojave+ ] fast/events/detect-caps-lock.html [ Pass ]
+
 #//////////////////////////////////////////////////////////////////////////////////////////
 # End platform-specific directories.
 #//////////////////////////////////////////////////////////////////////////////////////////
index f84cf57..0890b3d 100644 (file)
@@ -1,3 +1,28 @@
+2018-11-06  Per Arne Vollan  <pvollan@apple.com>
+
+        REGRESSION (r230523): Caps lock indicator not shown in password field
+        https://bugs.webkit.org/show_bug.cgi?id=190056
+
+        Reviewed by Ryosuke Niwa.
+
+        When WindowServer access is blocked, GetCurrentModifiers() always returns 0. Instead of calling
+        GetCurrentModifiers(), store the current modifiers from the key event argument in the method
+        WebKit::WebPage::keyEvent, and use the stored value to detect if Caps lock is on. Additionally,
+        the modifiers needs to be updated when the window becomes active.
+
+        Test: fast/events/detect-caps-lock.html
+
+        * Sources.txt:
+        * platform/PlatformKeyboardEvent.h:
+        * platform/graphics/FontTaggedSettings.cpp:
+        * platform/mac/KeyEventMac.mm:
+        (WebCore::PlatformKeyboardEvent::currentCapsLockState):
+        (WebCore::PlatformKeyboardEvent::getCurrentModifierState):
+        * testing/Internals.cpp:
+        (WebCore::Internals::capsLockIsOn):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2018-11-06  Javier Fernandez  <jfernandez@igalia.com>
 
         CSS grid elements with justify-content: space-around have extra whitespace, sometimes a lot
index ca30de1..b8d32d9 100644 (file)
@@ -1542,6 +1542,7 @@ platform/MainThreadSharedTimer.cpp
 platform/NotImplemented.cpp
 platform/Pasteboard.cpp
 platform/PasteboardWriterData.cpp
+platform/PlatformKeyboardEvent.cpp
 platform/PlatformSpeechSynthesisUtterance.cpp
 platform/PlatformSpeechSynthesisVoice.cpp
 platform/PlatformSpeechSynthesizer.cpp
diff --git a/Source/WebCore/platform/PlatformKeyboardEvent.cpp b/Source/WebCore/platform/PlatformKeyboardEvent.cpp
new file mode 100644 (file)
index 0000000..c1799cc
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PlatformKeyboardEvent.h"
+
+#include <wtf/MainThread.h>
+
+namespace WebCore {
+
+std::optional<OptionSet<PlatformEvent::Modifier>> PlatformKeyboardEvent::s_currentModifiers;    
+
+void PlatformKeyboardEvent::setCurrentModifierState(OptionSet<Modifier> modifiers)
+{
+    ASSERT(isMainThread());
+    s_currentModifiers = modifiers;
+}
+
+}
index 61c4061..f7d4d8e 100644 (file)
@@ -135,8 +135,10 @@ namespace WebCore {
         bool isKeypad() const { return m_isKeypad; }
         bool isSystemKey() const { return m_isSystemKey; }
 
-        static bool currentCapsLockState();
-        static void getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey);
+        WEBCORE_EXPORT static bool currentCapsLockState();
+        WEBCORE_EXPORT static void getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey);
+        WEBCORE_EXPORT static void setCurrentModifierState(OptionSet<Modifier>);
+        WEBCORE_EXPORT static OptionSet<Modifier> currentStateOfModifierKeys();
 
 #if PLATFORM(COCOA)
 #if !PLATFORM(IOS_FAMILY)
@@ -206,6 +208,9 @@ namespace WebCore {
         GdkEventKey* m_gdkEventKey;
         CompositionResults m_compositionResults;
 #endif
+        
+        // The modifier state is optional, since it is not needed in the UI process or in legacy WebKit.
+        static std::optional<OptionSet<Modifier>> s_currentModifiers;
     };
     
 } // namespace WebCore
index 6c20067..c697d22 100644 (file)
 #if USE(CAIRO)
 
 #include "CairoOperations.h"
+#include "FloatRoundedRect.h"
 #include "Font.h"
 #include "GlyphBuffer.h"
 #include "GraphicsContextPlatformPrivateCairo.h"
+#include "ImageBuffer.h"
+#include "IntRect.h"
+
 
 namespace WebCore {
 
index 7405874..b08a53e 100644 (file)
@@ -32,6 +32,7 @@
 #import "Logging.h"
 #import "WindowsKeyboardCodes.h"
 #import <Carbon/Carbon.h>
+#import <wtf/MainThread.h>
 
 namespace WebCore {
 using namespace WTF;
@@ -259,16 +260,43 @@ void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCom
 
 bool PlatformKeyboardEvent::currentCapsLockState()
 {
-    return GetCurrentKeyModifiers() & alphaLock;
+    auto currentModifiers = currentStateOfModifierKeys();
+    return currentModifiers.contains(PlatformEvent::Modifier::CapsLockKey);
 }
 
 void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
 {
+    auto currentModifiers = currentStateOfModifierKeys();
+    shiftKey = currentModifiers.contains(PlatformEvent::Modifier::ShiftKey);
+    ctrlKey = currentModifiers.contains(PlatformEvent::Modifier::CtrlKey);
+    altKey = currentModifiers.contains(PlatformEvent::Modifier::AltKey);
+    metaKey = currentModifiers.contains(PlatformEvent::Modifier::MetaKey);
+}
+
+OptionSet<PlatformEvent::Modifier> PlatformKeyboardEvent::currentStateOfModifierKeys()
+{
+#if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+    // s_currentModifiers is only set in the WebContent process, not in the UI process.
+    if (s_currentModifiers) {
+        ASSERT(isMainThread());
+        return *s_currentModifiers;
+    }
+#endif
     UInt32 currentModifiers = GetCurrentKeyModifiers();
-    shiftKey = currentModifiers & ::shiftKey;
-    ctrlKey = currentModifiers & ::controlKey;
-    altKey = currentModifiers & ::optionKey;
-    metaKey = currentModifiers & ::cmdKey;
+
+    OptionSet<PlatformEvent::Modifier> modifiers;
+    if (currentModifiers & ::shiftKey)
+        modifiers.add(PlatformEvent::Modifier::ShiftKey);
+    if (currentModifiers & ::controlKey)
+        modifiers.add(PlatformEvent::Modifier::CtrlKey);
+    if (currentModifiers & ::optionKey)
+        modifiers.add(PlatformEvent::Modifier::AltKey);
+    if (currentModifiers & ::cmdKey)
+        modifiers.add(PlatformEvent::Modifier::MetaKey);
+    if (currentModifiers & ::alphaLock)
+        modifiers.add(PlatformEvent::Modifier::CapsLockKey);
+
+    return modifiers;
 }
 
 } // namespace WebCore
index 9bdabe5..e73e7a9 100644 (file)
 #include "PageCache.h"
 #include "PageOverlay.h"
 #include "PathUtilities.h"
+#include "PlatformKeyboardEvent.h"
 #include "PlatformMediaSessionManager.h"
 #include "PlatformScreen.h"
 #include "PlatformStrategies.h"
@@ -4736,6 +4737,11 @@ unsigned Internals::primaryScreenDisplayID()
 #endif
 }
 
+bool Internals::capsLockIsOn()
+{
+    return WebCore::PlatformKeyboardEvent::currentCapsLockState();
+}
+
 bool Internals::supportsVCPEncoder()
 {
 #if defined(ENABLE_VCP_ENCODER)
index 9e19583..0e3e9c3 100644 (file)
@@ -738,6 +738,8 @@ public:
 
     unsigned primaryScreenDisplayID();
 
+    bool capsLockIsOn();
+        
     bool supportsVCPEncoder();
         
     using HEVCParameterSet = WebCore::HEVCParameterSet;
index 745585c..f4cda15 100644 (file)
@@ -709,6 +709,8 @@ enum CompositingPolicy {
 
     unsigned long primaryScreenDisplayID();
 
+    boolean capsLockIsOn();
+
     boolean supportsVCPEncoder();
 
     HEVCParameterSet? parseHEVCCodecParameters(DOMString codecParameters);
index 2e12874..8d2f494 100644 (file)
@@ -1,3 +1,23 @@
+2018-11-06  Per Arne Vollan  <pvollan@apple.com>
+
+        REGRESSION (r230523): Caps lock indicator not shown in password field
+        https://bugs.webkit.org/show_bug.cgi?id=190056
+
+        Reviewed by Ryosuke Niwa.
+
+        Update cached modifier state in the WebProcess when WebKit::WebPage::keyEvent is called, and
+        when the window becomes active.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::dispatchActivityStateChange):
+        (WebKit::WebPageProxy::updateCurrentModifierState):
+        * UIProcess/WebPageProxy.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::keyEvent):
+        (WebKit::WebPage::updateCurrentModifierState):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2018-11-06  Alex Christensen  <achristensen@webkit.org>
 
         Add ObjC SPI equivalent of WKContextHandlesSafeBrowsing
index 69575a5..c8f86de 100644 (file)
 #include <WebCore/MIMETypeRegistry.h>
 #include <WebCore/MediaStreamRequest.h>
 #include <WebCore/PerformanceLoggingClient.h>
+#include <WebCore/PlatformEvent.h>
 #include <WebCore/PublicSuffix.h>
 #include <WebCore/RenderEmbeddedObject.h>
 #include <WebCore/ResourceLoadStatistics.h>
@@ -1561,6 +1562,9 @@ void WebPageProxy::dispatchActivityStateChange()
     if (changed)
         LOG_WITH_STREAM(ActivityState, stream << "WebPageProxy " << pageID() << " dispatchActivityStateChange: state changed from " << previousActivityState << " to " << m_activityState);
 
+    if ((changed & ActivityState::WindowIsActive) && isViewWindowActive())
+        updateCurrentModifierState();
+
     if ((m_potentiallyChangedActivityStateFlags & ActivityState::IsVisible) && isViewVisible())
         viewIsBecomingVisible();
 
@@ -8125,6 +8129,14 @@ void WebPageProxy::getIsViewVisible(bool& result)
     result = isViewVisible();
 }
 
+void WebPageProxy::updateCurrentModifierState()
+{
+#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+    auto modifiers = PlatformKeyboardEvent::currentStateOfModifierKeys();
+    m_process->send(Messages::WebPage::UpdateCurrentModifierState(modifiers), m_pageID);
+#endif
+}
+
 } // namespace WebKit
 
 #undef MERGE_WHEEL_EVENTS
index 25a1054..4682d74 100644 (file)
@@ -1851,6 +1851,8 @@ private:
     void stopDisplayLink(unsigned observerID);
 #endif
 
+    void updateCurrentModifierState();
+
     void reportPageLoadResult(const WebCore::ResourceError& = { });
 
     void continueNavigationInNewProcess(API::Navigation&, Ref<WebProcessProxy>&&);
index a42b874..80c5383 100644 (file)
@@ -2564,6 +2564,8 @@ void WebPage::keyEvent(const WebKeyboardEvent& keyboardEvent)
 
     m_userActivityHysteresis.impulse();
 
+    PlatformKeyboardEvent::setCurrentModifierState(platform(keyboardEvent).modifiers());
+
     CurrentEvent currentEvent(keyboardEvent);
 
     bool handled = handleKeyEvent(keyboardEvent, m_page.get());
@@ -6311,6 +6313,11 @@ void WebPage::didFinishLoadingApplicationManifest(uint64_t coreCallbackID, const
 }
 #endif // ENABLE(APPLICATION_MANIFEST)
 
+void WebPage::updateCurrentModifierState(OptionSet<PlatformEvent::Modifier> modifiers)
+{
+    PlatformKeyboardEvent::setCurrentModifierState(modifiers);
+}    
+
 } // namespace WebKit
 
 #undef RELEASE_LOG_IF_ALLOWED
index 492015e..4076ea7 100644 (file)
@@ -1091,6 +1091,8 @@ public:
     void didFinishLoadingApplicationManifest(uint64_t, const std::optional<WebCore::ApplicationManifest>&);
 #endif
 
+    void updateCurrentModifierState(OptionSet<WebCore::PlatformEvent::Modifier> modifiers);
+
     UserContentControllerIdentifier userContentControllerIdentifier() const { return m_userContentController->identifier(); }
 
     WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() const { return m_userInterfaceLayoutDirection; }
index 29f56af..fd430d6 100644 (file)
@@ -527,4 +527,6 @@ messages -> WebPage LegacyReceiver {
 #endif
 
     SetDefersLoading(bool defersLoading)
+
+    UpdateCurrentModifierState(OptionSet<WebCore::PlatformEvent::Modifier> modifiers)
 }
index d2500ff..8f13301 100644 (file)
@@ -1,3 +1,20 @@
+2018-11-06  Per Arne Vollan  <pvollan@apple.com>
+
+        REGRESSION (r230523): Caps lock indicator not shown in password field
+        https://bugs.webkit.org/show_bug.cgi?id=190056
+
+        Reviewed by Ryosuke Niwa.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::toggleCapsLock):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::toggleCapsLock):
+
 2018-11-06  Sihui Liu  <sihui_liu@apple.com>
 
         IndexedDB: WAL file keeps growing
index d8659f3..592afe9 100644 (file)
@@ -359,4 +359,6 @@ interface TestRunner {
     void addTestKeyToKeychain(DOMString privateKeyBase64, DOMString attrLabel, DOMString applicationTagBase64);
     void cleanUpKeychain(DOMString attrLabel);
     boolean keyExistsInKeychain(DOMString attrLabel, DOMString applicationTagBase64);
+
+    void toggleCapsLock();
 };
index c952a9f..a64d856 100644 (file)
@@ -2513,4 +2513,10 @@ bool TestRunner::keyExistsInKeychain(JSStringRef attrLabel, JSStringRef applicat
     return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
 }
 
+void TestRunner::toggleCapsLock()
+{
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("ToggleCapsLock"));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr);
+}
+
 } // namespace WTR
index 47e5972..2d992c1 100644 (file)
@@ -477,6 +477,8 @@ public:
     void cleanUpKeychain(JSStringRef attrLabel);
     bool keyExistsInKeychain(JSStringRef attrLabel, JSStringRef applicationTagBase64);
 
+    void toggleCapsLock();
+
 private:
     TestRunner();
 
index 93e8886..5fa632e 100644 (file)
@@ -260,6 +260,8 @@ public:
     void cleanUpKeychain(const String& attrLabel);
     bool keyExistsInKeychain(const String& attrLabel, const String& applicationTagBase64);
 
+    void toggleCapsLock();
+
 private:
     WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration(WKContextConfigurationRef);
     WKRetainPtr<WKContextConfigurationRef> generateContextConfiguration() const;
@@ -488,6 +490,8 @@ private:
 
     bool m_didReceiveServerRedirectForProvisionalNavigation { false };
 
+    bool m_capsLockOn { false };
+
     WKRetainPtr<WKArrayRef> m_openPanelFileURLs;
 
     std::unique_ptr<EventSenderProxy> m_eventSenderProxy;
index d2b8ca1..d81e58b 100644 (file)
@@ -1503,6 +1503,13 @@ WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedB
         return result;
     }
 
+#if PLATFORM(MAC)
+    if (WKStringIsEqualToUTF8CString(messageName, "ToggleCapsLock")) {
+        TestController::singleton().toggleCapsLock();
+        return nullptr;
+    }
+#endif
+
     ASSERT_NOT_REACHED();
     return nullptr;
 }
index 959c8f3..f1e3ed5 100644 (file)
@@ -351,4 +351,23 @@ bool TestController::keyExistsInKeychain(const String& attrLabel, const String&
     return false;
 }
 
+#if PLATFORM(MAC)
+void TestController::toggleCapsLock()
+{
+    m_capsLockOn = !m_capsLockOn;
+    NSEvent *fakeEvent = [NSEvent keyEventWithType:NSEventTypeFlagsChanged
+        location:NSZeroPoint
+        modifierFlags:m_capsLockOn ? NSEventModifierFlagCapsLock : 0
+        timestamp:0
+        windowNumber:[mainWebView()->platformWindow() windowNumber]
+        context:nullptr
+        characters:@""
+        charactersIgnoringModifiers:@""
+        isARepeat:NO
+        keyCode:57];
+    
+    [mainWebView()->platformWindow() sendEvent:fakeEvent];
+}
+#endif
+
 } // namespace WTR