Diff
Modified: trunk/LayoutTests/ChangeLog (238511 => 238512)
--- trunk/LayoutTests/ChangeLog 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/LayoutTests/ChangeLog 2018-11-26 20:41:19 UTC (rev 238512)
@@ -1,3 +1,19 @@
+2018-11-26 Daniel Bates <[email protected]>
+
+ Move testRunner.toggleCapsLock() to uiController
+ https://bugs.webkit.org/show_bug.cgi?id=191972
+
+ Reviewed by Tim Horton.
+
+ Updated existing test to use UIHelper.toggleCapsLock(), which calls uiController.toggleCapsLock(),
+ now that testRunner.toggleCapsLock() was removed.
+
+ * fast/events/detect-caps-lock.html:
+ * resources/ui-helper.js:
+ (window.UIHelper.toggleCapsLock): Added. Convenience function to call uiController.toggleCapsLock()
+ and return a Promise that is resolved once the UIProcess has dispatched the NSEvent to simulate
+ pressing the caps lock key.
+
2018-11-26 Zalan Bujtas <[email protected]>
Unreviewed rebaseline after r238493.
Modified: trunk/LayoutTests/fast/events/detect-caps-lock.html (238511 => 238512)
--- trunk/LayoutTests/fast/events/detect-caps-lock.html 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/LayoutTests/fast/events/detect-caps-lock.html 2018-11-26 20:41:19 UTC (rev 238512)
@@ -1,5 +1,8 @@
<!DOCTYPE html>
-<html><head></head>
+<html>
+<head>
+<script src=""
+</head>
<body>
<p>This test verifies that the function WebCore::currentCapsLockState() returns true when Caps Lock is on.</p>
<input type="password"></input>
@@ -43,31 +46,36 @@
input.addEventListener('keydown', keyDown, false);
input.addEventListener('keyup', keyUp, false);
input.focus();
-
- if (window.testRunner) {
- testRunner.dumpAsText();
- testRunner.waitUntilDone();
-
- testRunner.toggleCapsLock();
+
+ async function runTest()
+ {
+ await UIHelper.toggleCapsLock();
testRunner.setWindowIsKey(false);
testRunner.setWindowIsKey(true);
- testRunner.toggleCapsLock();
+ await UIHelper.toggleCapsLock();
testRunner.setWindowIsKey(false);
- testRunner.toggleCapsLock();
+ await UIHelper.toggleCapsLock();
testRunner.setWindowIsKey(true);
- testRunner.toggleCapsLock();
+ await UIHelper.toggleCapsLock();
testRunner.setWindowIsKey(true);
- testRunner.toggleCapsLock();
- testRunner.toggleCapsLock();
+ await UIHelper.toggleCapsLock();
+ await UIHelper.toggleCapsLock();
testRunner.setWindowIsKey(false);
- testRunner.toggleCapsLock();
- testRunner.toggleCapsLock();
+ await UIHelper.toggleCapsLock();
+ await UIHelper.toggleCapsLock();
eventSender.keyDown("q", []);
}
+
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+
+ runTest();
+ }
</script>
</body>
</html>
Modified: trunk/LayoutTests/resources/ui-helper.js (238511 => 238512)
--- trunk/LayoutTests/resources/ui-helper.js 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/LayoutTests/resources/ui-helper.js 2018-11-26 20:41:19 UTC (rev 238512)
@@ -66,6 +66,13 @@
});
}
+ static toggleCapsLock()
+ {
+ return new Promise((resolve) => {
+ testRunner.runUIScript(`uiController.toggleCapsLock(() => uiController.uiScriptComplete('Done'));`, resolve);
+ });
+ }
+
static ensurePresentationUpdate()
{
if (!this.isWebKit2()) {
Modified: trunk/Tools/ChangeLog (238511 => 238512)
--- trunk/Tools/ChangeLog 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/Tools/ChangeLog 2018-11-26 20:41:19 UTC (rev 238512)
@@ -1,3 +1,49 @@
+2018-11-26 Daniel Bates <[email protected]>
+
+ Move testRunner.toggleCapsLock() to uiController
+ https://bugs.webkit.org/show_bug.cgi?id=191972
+
+ Reviewed by Tim Horton.
+
+ Move testRunner.toggleCapsLock() to uiController as uiController is the preferred _javascript_
+ object for UI test functions. Having this functionality be on uiController makes it an
+ asynchronous function naturally and complements use of onkeydown, onkeyup listeners to know
+ when the Caps Lock key event is dispatched. It also facilitates its use directly as part of
+ scripts with other uiController functions invocations that are passed in a single invocation
+ of testRunner.runUIScript().
+
+ * DumpRenderTree/ios/UIScriptControllerIOS.mm:
+ (WTR::UIScriptController::toggleCapsLock):
+ * DumpRenderTree/mac/UIScriptControllerMac.mm:
+ (WTR::UIScriptController::toggleCapsLock):
+ Added stub functions that invoke the callback. We do not support toggling caps lock in Legacy
+ WebKit at the moment. Legacy WebKit reads the caps lock key state directly from the OS. Modern
+ WebKit caches the caps lock state in the WebProcess as a natural side effect of the fact that
+ the UIProcess is the only process capable of querying the caps lock key state from the OS and
+ hence the UIProcess must send over this state to the WebProcess.
+
+ * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: Add IDL for new function.
+ * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
+ (WTR::UIScriptController::toggleCapsLock): Added empty implementation for ports non-Cocoa ports.
+ * TestRunnerShared/UIScriptContext/UIScriptController.h:
+
+ * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+ * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+ (WTR::TestRunner::toggleCapsLock): Deleted.
+ * WebKitTestRunner/InjectedBundle/TestRunner.h:
+ * WebKitTestRunner/TestController.h:
+ * WebKitTestRunner/TestInvocation.cpp:
+ (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+ * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+ (WTR::TestController::toggleCapsLock): Deleted; moved to UIScriptController::toggleCapsLock().
+ Removed logic to handle testRunner.toggleCapsLock().
+
+ * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+ (WTR::UIScriptController::toggleCapsLock): Add stub function that invokes the callback
+ and a FIXME comment that explains that we will implement this function in <https://bugs.webkit.org/show_bug.cgi?id=191815>.
+ * WebKitTestRunner/mac/UIScriptControllerMac.mm:
+ (WTR::UIScriptController::toggleCapsLock): Moved the implementation from TestController::toggleCapsLock().
+
2018-11-26 Brent Fulgham <[email protected]>
[Win] Reduce the use of WKSI library calls: CoreAnimation
Modified: trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm (238511 => 238512)
--- trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm 2018-11-26 20:41:19 UTC (rev 238512)
@@ -422,6 +422,11 @@
return 0;
}
+void UIScriptController::toggleCapsLock(JSValueRef callback)
+{
+ doAsyncTask(callback);
}
+}
+
#endif // PLATFORM(IOS_FAMILY)
Modified: trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm (238511 => 238512)
--- trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm 2018-11-26 20:41:19 UTC (rev 238512)
@@ -205,7 +205,12 @@
void UIScriptController::setDefaultCalendarType(JSStringRef calendarIdentifier)
{
}
-
+
+void UIScriptController::toggleCapsLock(JSValueRef callback)
+{
+ doAsyncTask(callback);
}
+}
+
#endif // PLATFORM(MAC)
Modified: trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (238511 => 238512)
--- trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl 2018-11-26 20:41:19 UTC (rev 238512)
@@ -70,6 +70,7 @@
void typeCharacterUsingHardwareKeyboard(DOMString character, object callback);
void keyDown(DOMString character, object modifierArray);
+ void toggleCapsLock(object callback);
// eventsJSON describes a series of user events in JSON form. For the keys, see HIDEventGenerator.mm.
// For example, this JSON describes a touch down followed by a touch up (i.e. a single tap).
Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp (238511 => 238512)
--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp 2018-11-26 20:41:19 UTC (rev 238512)
@@ -206,6 +206,7 @@
}
#if !PLATFORM(COCOA)
+
void UIScriptController::zoomToScale(double, JSValueRef)
{
}
@@ -235,9 +236,13 @@
{
return nullptr;
}
-
-#endif
+void UIScriptController::toggleCapsLock(JSValueRef)
+{
+}
+
+#endif // !PLATFORM(COCOA)
+
void UIScriptController::playBackEventStream(JSStringRef stream, JSValueRef callback)
{
platformPlayBackEventStream(stream, callback);
Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (238511 => 238512)
--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h 2018-11-26 20:41:19 UTC (rev 238512)
@@ -91,6 +91,7 @@
void typeCharacterUsingHardwareKeyboard(JSStringRef character, JSValueRef callback);
void keyDown(JSStringRef character, JSValueRef modifierArray);
+ void toggleCapsLock(JSValueRef callback);
void keyboardAccessoryBarNext();
void keyboardAccessoryBarPrevious();
@@ -221,6 +222,10 @@
JSObjectRef objectFromRect(const WebCore::FloatRect&) const;
UIScriptContext* m_context;
+
+#if PLATFORM(MAC)
+ bool m_capsLockOn { false };
+#endif
};
}
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (238511 => 238512)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2018-11-26 20:41:19 UTC (rev 238512)
@@ -361,6 +361,4 @@
void addTestKeyToKeychain(DOMString privateKeyBase64, DOMString attrLabel, DOMString applicationTagBase64);
void cleanUpKeychain(DOMString attrLabel);
boolean keyExistsInKeychain(DOMString attrLabel, DOMString applicationTagBase64);
-
- void toggleCapsLock();
};
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (238511 => 238512)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2018-11-26 20:41:19 UTC (rev 238512)
@@ -2634,10 +2634,4 @@
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
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (238511 => 238512)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2018-11-26 20:41:19 UTC (rev 238512)
@@ -479,8 +479,6 @@
void cleanUpKeychain(JSStringRef attrLabel);
bool keyExistsInKeychain(JSStringRef attrLabel, JSStringRef applicationTagBase64);
- void toggleCapsLock();
-
private:
TestRunner();
Modified: trunk/Tools/WebKitTestRunner/TestController.h (238511 => 238512)
--- trunk/Tools/WebKitTestRunner/TestController.h 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/Tools/WebKitTestRunner/TestController.h 2018-11-26 20:41:19 UTC (rev 238512)
@@ -281,8 +281,6 @@
void cleanUpKeychain(const String& attrLabel);
bool keyExistsInKeychain(const String& attrLabel, const String& applicationTagBase64);
- void toggleCapsLock();
-
#if PLATFORM(COCOA)
RetainPtr<NSString> getOverriddenCalendarIdentifier() const;
void setDefaultCalendarType(NSString *identifier);
@@ -518,8 +516,6 @@
bool m_didReceiveServerRedirectForProvisionalNavigation { false };
- bool m_capsLockOn { false };
-
WKRetainPtr<WKArrayRef> m_openPanelFileURLs;
std::unique_ptr<EventSenderProxy> m_eventSenderProxy;
Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (238511 => 238512)
--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2018-11-26 20:41:19 UTC (rev 238512)
@@ -1509,13 +1509,6 @@
return result;
}
-#if PLATFORM(MAC)
- if (WKStringIsEqualToUTF8CString(messageName, "ToggleCapsLock")) {
- TestController::singleton().toggleCapsLock();
- return nullptr;
- }
-#endif
-
ASSERT_NOT_REACHED();
return nullptr;
}
Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (238511 => 238512)
--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm 2018-11-26 20:41:19 UTC (rev 238512)
@@ -389,23 +389,4 @@
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
Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (238511 => 238512)
--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm 2018-11-26 20:41:19 UTC (rev 238512)
@@ -910,6 +910,12 @@
#endif
}
+void UIScriptController::toggleCapsLock(JSValueRef callback)
+{
+ // FIXME: Implement for iOS. See <https://bugs.webkit.org/show_bug.cgi?id=191815>.
+ doAsyncTask(callback);
}
+}
+
#endif // PLATFORM(IOS_FAMILY)
Modified: trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm (238511 => 238512)
--- trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm 2018-11-26 20:29:33 UTC (rev 238511)
+++ trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm 2018-11-26 20:41:19 UTC (rev 238512)
@@ -191,4 +191,22 @@
return [window firstResponder] == [window contentView];
}
+void UIScriptController::toggleCapsLock(JSValueRef callback)
+{
+ m_capsLockOn = !m_capsLockOn;
+ NSWindow *window = [TestController::singleton().mainWebView()->platformView() window];
+ NSEvent *fakeEvent = [NSEvent keyEventWithType:NSEventTypeFlagsChanged
+ location:NSZeroPoint
+ modifierFlags:m_capsLockOn ? NSEventModifierFlagCapsLock : 0
+ timestamp:0
+ windowNumber:window.windowNumber
+ context:nullptr
+ characters:@""
+ charactersIgnoringModifiers:@""
+ isARepeat:NO
+ keyCode:57];
+ [window sendEvent:fakeEvent];
+ doAsyncTask(callback);
+}
+
} // namespace WTR