Changeset 277209 in webkit
- Timestamp:
- May 7, 2021, 4:03:43 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/Platform/spi/Cocoa/AccessibilitySupportSPI.h (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKit/AccessibilityReduceMotion.mm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r277208 r277209 1 2021-05-07 Brent Fulgham <bfulgham@apple.com> 2 3 [iOS] Make AccessibilityReduceMotion test case work on iOS 4 https://bugs.webkit.org/show_bug.cgi?id=225244 5 <rdar://problem/77589455> 6 7 Reviewed by Per Arne Vollan. 8 9 New tests for Accessibility-related features were added in Bug 215664, but only for macOS. 10 We support these same features on iOS, and should have test coverage. 11 12 Tested by AccessibilityReduceMotion.mm. 13 14 * Platform/spi/Cocoa/AccessibilitySupportSPI.h: 15 1 16 2021-05-07 Brent Fulgham <bfulgham@apple.com> 2 17 -
trunk/Source/WebKit/Platform/spi/Cocoa/AccessibilitySupportSPI.h
r277206 r277209 41 41 #endif 42 42 43 #if PLATFORM(IOS_FAMILY) 44 extern CFStringRef kAXSReduceMotionPreference; 45 extern CFStringRef kAXSReduceMotionChangedNotification; 46 #endif 47 43 48 #if PLATFORM(IOS_FAMILY) && ENABLE(FULL_KEYBOARD_ACCESS) 44 49 extern CFStringRef kAXSFullKeyboardAccessEnabledNotification; -
trunk/Tools/ChangeLog
r277206 r277209 1 2021-05-07 Brent Fulgham <bfulgham@apple.com> 2 3 [iOS] Make AccessibilityReduceMotion test case work on iOS 4 https://bugs.webkit.org/show_bug.cgi?id=225244 5 <rdar://problem/77589455> 6 7 Reviewed by Per Arne Vollan. 8 9 New tests for Accessibility-related features were added in Bug 215664, but only for macOS. 10 We support these same features on iOS, and should have test coverage. 11 12 * TestWebKitAPI/Tests/WebKit/AccessibilityReduceMotion.mm: 13 (notificationCallback): 14 (TEST): 15 1 16 2021-05-07 Commit Queue <commit-queue@webkit.org> 2 17 -
trunk/Tools/TestWebKitAPI/Tests/WebKit/AccessibilityReduceMotion.mm
r277206 r277209 26 26 #import "config.h" 27 27 28 #if WK_HAVE_C_SPI &&ENABLE(CFPREFS_DIRECT_MODE)28 #if ENABLE(CFPREFS_DIRECT_MODE) 29 29 30 30 #import "PlatformUtilities.h" 31 31 #import "TestWKWebView.h" 32 #import "WKWebViewConfigurationExtras.h" 32 33 #import <WebKit/PreferenceObserver.h> 33 34 #import <WebKit/WKProcessPoolPrivate.h> 34 35 #import <WebKit/_WKProcessPoolConfiguration.h> 35 36 37 #if PLATFORM(MAC) 36 38 #import <pal/spi/mac/HIServicesSPI.h> 39 #endif 40 41 #if PLATFORM(IOS_FAMILY) 42 #include <pal/spi/cocoa/AccessibilitySupportSPI.h> 43 #include <wtf/SoftLinking.h> 44 45 SOFT_LINK_LIBRARY(libAccessibility) 46 SOFT_LINK_CONSTANT(libAccessibility, kAXSReduceMotionPreference, CFStringRef); 47 SOFT_LINK_CONSTANT(libAccessibility, kAXSReduceMotionChangedNotification, CFStringRef); 48 49 #define NOTIFICATION_CENTER CFNotificationCenterGetDarwinNotifyCenter() 50 #define REDUCED_MOTION_PREFERENCE getkAXSReduceMotionPreference() 51 #define REDUCED_MOTION_CHANGED_NOTIFICATION getkAXSReduceMotionChangedNotification() 52 #define ACCESSIBILITY_DOMAIN CFSTR("com.apple.Accessibility") 53 #else 54 #define NOTIFICATION_CENTER CFNotificationCenterGetDistributedCenter() 55 #define REDUCED_MOTION_PREFERENCE kAXInterfaceReduceMotionKey 56 #define REDUCED_MOTION_CHANGED_NOTIFICATION kAXInterfaceReduceMotionStatusDidChangeNotification 57 #define ACCESSIBILITY_DOMAIN CFSTR("com.apple.universalaccess") 58 #endif 37 59 38 60 static bool reduceMotionNotificationReceived = false; … … 51 73 @end 52 74 75 static void notificationCallback(CFNotificationCenterRef center, void *observer, CFNotificationName name, const void *object, CFDictionaryRef userInfo) 76 { 77 reduceMotionNotificationReceived = true; 78 } 79 53 80 TEST(WebKit, AccessibilityReduceMotion) 54 81 { 55 RetainPtr<NSObject> accessibilityObserver = [[NSDistributedNotificationCenter defaultCenter] addObserverForName:(__bridge id)kAXInterfaceReduceMotionStatusDidChangeNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *note) { 56 reduceMotionNotificationReceived = true; 57 }]; 82 CFNotificationCenterAddObserver(NOTIFICATION_CENTER, nullptr, ¬ificationCallback, REDUCED_MOTION_CHANGED_NOTIFICATION, nullptr, CFNotificationSuspensionBehaviorDeliverImmediately); 58 83 59 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 60 WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest")); 61 configuration.get().processPool = (WKProcessPool *)context.get(); 62 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]); 84 WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES]; 85 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration addToWindow:YES]); 63 86 64 CFPreferencesSetAppValue( kAXInterfaceReduceMotionKey, kCFBooleanFalse, CFSTR("com.apple.universalaccess"));87 CFPreferencesSetAppValue(REDUCED_MOTION_PREFERENCE, kCFBooleanFalse, ACCESSIBILITY_DOMAIN); 65 88 66 89 auto observer = adoptNS([[WKPreferenceObserverForTesting alloc] init]); … … 68 91 [webView synchronouslyLoadTestPageNamed:@"simple"]; 69 92 70 CFPreferencesSetAppValue(kAXInterfaceReduceMotionKey, kCFBooleanTrue, CFSTR("com.apple.universalaccess"));71 72 TestWebKitAPI::Util::run(&receivedPreferenceNotification);73 74 93 auto reduceMotion = [&] { 75 94 return [webView stringByEvaluatingJavaScript:@"window.internals.userPrefersReducedMotion()"].boolValue; 76 95 }; 77 96 97 ASSERT_FALSE(reduceMotion()); 98 99 reduceMotionNotificationReceived = false; 100 101 CFPreferencesSetAppValue(REDUCED_MOTION_PREFERENCE, kCFBooleanTrue, ACCESSIBILITY_DOMAIN); 102 103 TestWebKitAPI::Util::run(&receivedPreferenceNotification); 104 TestWebKitAPI::Util::run(&reduceMotionNotificationReceived); 105 78 106 [webView synchronouslyLoadTestPageNamed:@"simple"]; 79 80 TestWebKitAPI::Util::run(&reduceMotionNotificationReceived);81 107 82 108 ASSERT_TRUE(reduceMotion()); 83 109 84 CFPreferencesSetAppValue( kAXInterfaceReduceMotionKey, nullptr, CFSTR("com.apple.universalaccess"));110 CFPreferencesSetAppValue(REDUCED_MOTION_PREFERENCE, nullptr, ACCESSIBILITY_DOMAIN); 85 111 86 [[NSNotificationCenter defaultCenter] removeObserver:accessibilityObserver.get()];112 CFNotificationCenterRemoveObserver(NOTIFICATION_CENTER, nullptr, REDUCED_MOTION_CHANGED_NOTIFICATION, nullptr); 87 113 } 88 114
Note:
See TracChangeset
for help on using the changeset viewer.