Changeset 238512 in webkit
- Timestamp:
- Nov 26, 2018 12:41:19 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r238496 r238512 1 2018-11-26 Daniel Bates <dabates@apple.com> 2 3 Move testRunner.toggleCapsLock() to uiController 4 https://bugs.webkit.org/show_bug.cgi?id=191972 5 6 Reviewed by Tim Horton. 7 8 Updated existing test to use UIHelper.toggleCapsLock(), which calls uiController.toggleCapsLock(), 9 now that testRunner.toggleCapsLock() was removed. 10 11 * fast/events/detect-caps-lock.html: 12 * resources/ui-helper.js: 13 (window.UIHelper.toggleCapsLock): Added. Convenience function to call uiController.toggleCapsLock() 14 and return a Promise that is resolved once the UIProcess has dispatched the NSEvent to simulate 15 pressing the caps lock key. 16 1 17 2018-11-26 Zalan Bujtas <zalan@apple.com> 2 18 -
trunk/LayoutTests/fast/events/detect-caps-lock.html
r237886 r238512 1 1 <!DOCTYPE html> 2 <html><head></head> 2 <html> 3 <head> 4 <script src="../../resources/ui-helper.js"></script> 5 </head> 3 6 <body> 4 7 <p>This test verifies that the function WebCore::currentCapsLockState() returns true when Caps Lock is on.</p> … … 44 47 input.addEventListener('keyup', keyUp, false); 45 48 input.focus(); 46 49 50 async function runTest() 51 { 52 await UIHelper.toggleCapsLock(); 53 testRunner.setWindowIsKey(false); 54 testRunner.setWindowIsKey(true); 55 await UIHelper.toggleCapsLock(); 56 57 testRunner.setWindowIsKey(false); 58 await UIHelper.toggleCapsLock(); 59 testRunner.setWindowIsKey(true); 60 await UIHelper.toggleCapsLock(); 61 62 testRunner.setWindowIsKey(true); 63 await UIHelper.toggleCapsLock(); 64 await UIHelper.toggleCapsLock(); 65 66 testRunner.setWindowIsKey(false); 67 await UIHelper.toggleCapsLock(); 68 await UIHelper.toggleCapsLock(); 69 70 eventSender.keyDown("q", []); 71 } 72 47 73 if (window.testRunner) { 48 74 testRunner.dumpAsText(); 49 75 testRunner.waitUntilDone(); 50 51 testRunner.toggleCapsLock();52 testRunner.setWindowIsKey(false);53 testRunner.setWindowIsKey(true);54 testRunner.toggleCapsLock();55 56 testRunner.setWindowIsKey(false);57 testRunner.toggleCapsLock();58 testRunner.setWindowIsKey(true);59 testRunner.toggleCapsLock();60 76 61 testRunner.setWindowIsKey(true); 62 testRunner.toggleCapsLock(); 63 testRunner.toggleCapsLock(); 64 65 testRunner.setWindowIsKey(false); 66 testRunner.toggleCapsLock(); 67 testRunner.toggleCapsLock(); 68 69 eventSender.keyDown("q", []); 77 runTest(); 70 78 } 71 79 </script> -
trunk/LayoutTests/resources/ui-helper.js
r238235 r238512 64 64 return new Promise((resolve) => { 65 65 testRunner.runUIScript(`uiController.keyDown("${key}", ${JSON.stringify(modifiers)});`, resolve); 66 }); 67 } 68 69 static toggleCapsLock() 70 { 71 return new Promise((resolve) => { 72 testRunner.runUIScript(`uiController.toggleCapsLock(() => uiController.uiScriptComplete('Done'));`, resolve); 66 73 }); 67 74 } -
trunk/Tools/ChangeLog
r238501 r238512 1 2018-11-26 Daniel Bates <dabates@apple.com> 2 3 Move testRunner.toggleCapsLock() to uiController 4 https://bugs.webkit.org/show_bug.cgi?id=191972 5 6 Reviewed by Tim Horton. 7 8 Move testRunner.toggleCapsLock() to uiController as uiController is the preferred JavaScript 9 object for UI test functions. Having this functionality be on uiController makes it an 10 asynchronous function naturally and complements use of onkeydown, onkeyup listeners to know 11 when the Caps Lock key event is dispatched. It also facilitates its use directly as part of 12 scripts with other uiController functions invocations that are passed in a single invocation 13 of testRunner.runUIScript(). 14 15 * DumpRenderTree/ios/UIScriptControllerIOS.mm: 16 (WTR::UIScriptController::toggleCapsLock): 17 * DumpRenderTree/mac/UIScriptControllerMac.mm: 18 (WTR::UIScriptController::toggleCapsLock): 19 Added stub functions that invoke the callback. We do not support toggling caps lock in Legacy 20 WebKit at the moment. Legacy WebKit reads the caps lock key state directly from the OS. Modern 21 WebKit caches the caps lock state in the WebProcess as a natural side effect of the fact that 22 the UIProcess is the only process capable of querying the caps lock key state from the OS and 23 hence the UIProcess must send over this state to the WebProcess. 24 25 * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: Add IDL for new function. 26 * TestRunnerShared/UIScriptContext/UIScriptController.cpp: 27 (WTR::UIScriptController::toggleCapsLock): Added empty implementation for ports non-Cocoa ports. 28 * TestRunnerShared/UIScriptContext/UIScriptController.h: 29 30 * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: 31 * WebKitTestRunner/InjectedBundle/TestRunner.cpp: 32 (WTR::TestRunner::toggleCapsLock): Deleted. 33 * WebKitTestRunner/InjectedBundle/TestRunner.h: 34 * WebKitTestRunner/TestController.h: 35 * WebKitTestRunner/TestInvocation.cpp: 36 (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): 37 * WebKitTestRunner/cocoa/TestControllerCocoa.mm: 38 (WTR::TestController::toggleCapsLock): Deleted; moved to UIScriptController::toggleCapsLock(). 39 Removed logic to handle testRunner.toggleCapsLock(). 40 41 * WebKitTestRunner/ios/UIScriptControllerIOS.mm: 42 (WTR::UIScriptController::toggleCapsLock): Add stub function that invokes the callback 43 and a FIXME comment that explains that we will implement this function in <https://bugs.webkit.org/show_bug.cgi?id=191815>. 44 * WebKitTestRunner/mac/UIScriptControllerMac.mm: 45 (WTR::UIScriptController::toggleCapsLock): Moved the implementation from TestController::toggleCapsLock(). 46 1 47 2018-11-26 Brent Fulgham <bfulgham@apple.com> 2 48 -
trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm
r238235 r238512 423 423 } 424 424 425 void UIScriptController::toggleCapsLock(JSValueRef callback) 426 { 427 doAsyncTask(callback); 428 } 429 425 430 } 426 431 -
trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm
r237924 r238512 206 206 { 207 207 } 208 208 209 void UIScriptController::toggleCapsLock(JSValueRef callback) 210 { 211 doAsyncTask(callback); 212 } 213 209 214 } 210 215 -
trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
r238235 r238512 71 71 72 72 void keyDown(DOMString character, object modifierArray); 73 void toggleCapsLock(object callback); 73 74 74 75 // eventsJSON describes a series of user events in JSON form. For the keys, see HIDEventGenerator.mm. -
trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
r238235 r238512 207 207 208 208 #if !PLATFORM(COCOA) 209 209 210 void UIScriptController::zoomToScale(double, JSValueRef) 210 211 { … … 236 237 return nullptr; 237 238 } 238 239 #endif 239 240 void UIScriptController::toggleCapsLock(JSValueRef) 241 { 242 } 243 244 #endif // !PLATFORM(COCOA) 240 245 241 246 void UIScriptController::playBackEventStream(JSStringRef stream, JSValueRef callback) -
trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
r238235 r238512 92 92 93 93 void keyDown(JSStringRef character, JSValueRef modifierArray); 94 void toggleCapsLock(JSValueRef callback); 94 95 95 96 void keyboardAccessoryBarNext(); … … 222 223 223 224 UIScriptContext* m_context; 225 226 #if PLATFORM(MAC) 227 bool m_capsLockOn { false }; 228 #endif 224 229 }; 225 230 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r238438 r238512 362 362 void cleanUpKeychain(DOMString attrLabel); 363 363 boolean keyExistsInKeychain(DOMString attrLabel, DOMString applicationTagBase64); 364 365 void toggleCapsLock();366 364 }; -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
r238438 r238512 2635 2635 } 2636 2636 2637 void TestRunner::toggleCapsLock()2638 {2639 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("ToggleCapsLock"));2640 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr);2641 }2642 2643 2637 } // namespace WTR -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r238438 r238512 480 480 bool keyExistsInKeychain(JSStringRef attrLabel, JSStringRef applicationTagBase64); 481 481 482 void toggleCapsLock();483 484 482 private: 485 483 TestRunner(); -
trunk/Tools/WebKitTestRunner/TestController.h
r237924 r238512 282 282 bool keyExistsInKeychain(const String& attrLabel, const String& applicationTagBase64); 283 283 284 void toggleCapsLock();285 286 284 #if PLATFORM(COCOA) 287 285 RetainPtr<NSString> getOverriddenCalendarIdentifier() const; … … 519 517 bool m_didReceiveServerRedirectForProvisionalNavigation { false }; 520 518 521 bool m_capsLockOn { false };522 523 519 WKRetainPtr<WKArrayRef> m_openPanelFileURLs; 524 520 -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r238098 r238512 1510 1510 } 1511 1511 1512 #if PLATFORM(MAC)1513 if (WKStringIsEqualToUTF8CString(messageName, "ToggleCapsLock")) {1514 TestController::singleton().toggleCapsLock();1515 return nullptr;1516 }1517 #endif1518 1519 1512 ASSERT_NOT_REACHED(); 1520 1513 return nullptr; -
trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
r238125 r238512 390 390 } 391 391 392 #if PLATFORM(MAC)393 void TestController::toggleCapsLock()394 {395 m_capsLockOn = !m_capsLockOn;396 NSEvent *fakeEvent = [NSEvent keyEventWithType:NSEventTypeFlagsChanged397 location:NSZeroPoint398 modifierFlags:m_capsLockOn ? NSEventModifierFlagCapsLock : 0399 timestamp:0400 windowNumber:[mainWebView()->platformWindow() windowNumber]401 context:nullptr402 characters:@""403 charactersIgnoringModifiers:@""404 isARepeat:NO405 keyCode:57];406 407 [mainWebView()->platformWindow() sendEvent:fakeEvent];408 }409 #endif410 411 392 } // namespace WTR -
trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm
r238475 r238512 911 911 } 912 912 913 void UIScriptController::toggleCapsLock(JSValueRef callback) 914 { 915 // FIXME: Implement for iOS. See <https://bugs.webkit.org/show_bug.cgi?id=191815>. 916 doAsyncTask(callback); 917 } 918 913 919 } 914 920 -
trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm
r237786 r238512 192 192 } 193 193 194 void UIScriptController::toggleCapsLock(JSValueRef callback) 195 { 196 m_capsLockOn = !m_capsLockOn; 197 NSWindow *window = [TestController::singleton().mainWebView()->platformView() window]; 198 NSEvent *fakeEvent = [NSEvent keyEventWithType:NSEventTypeFlagsChanged 199 location:NSZeroPoint 200 modifierFlags:m_capsLockOn ? NSEventModifierFlagCapsLock : 0 201 timestamp:0 202 windowNumber:window.windowNumber 203 context:nullptr 204 characters:@"" 205 charactersIgnoringModifiers:@"" 206 isARepeat:NO 207 keyCode:57]; 208 [window sendEvent:fakeEvent]; 209 doAsyncTask(callback); 210 } 211 194 212 } // namespace WTR
Note: See TracChangeset
for help on using the changeset viewer.