Expose more WKPreferences SPI
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Oct 2019 17:49:54 +0000 (17:49 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Oct 2019 17:49:54 +0000 (17:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=203631
<rdar://problem/56717160>

Reviewed by Brady Eidson.

Source/WebKit:

I added a unit test for the one that can be easily tested.

* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _setWebAudioEnabled:]):
(-[WKPreferences _webAudioEnabled]):
(-[WKPreferences _setAcceleratedCompositingEnabled:]):
(-[WKPreferences _acceleratedCompositingEnabled]):
(-[WKPreferences _setRequestAnimationFrameEnabled:]):
(-[WKPreferences _requestAnimationFrameEnabled]):
* UIProcess/API/Cocoa/WKPreferencesPrivate.h:

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/Preferences.mm:
(TEST):

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/Preferences.mm

index 9c66d8b..177e9e2 100644 (file)
@@ -1,5 +1,24 @@
 2019-10-31  Alex Christensen  <achristensen@webkit.org>
 
+        Expose more WKPreferences SPI
+        https://bugs.webkit.org/show_bug.cgi?id=203631
+        <rdar://problem/56717160>
+
+        Reviewed by Brady Eidson.
+
+        I added a unit test for the one that can be easily tested.
+
+        * UIProcess/API/Cocoa/WKPreferences.mm:
+        (-[WKPreferences _setWebAudioEnabled:]):
+        (-[WKPreferences _webAudioEnabled]):
+        (-[WKPreferences _setAcceleratedCompositingEnabled:]):
+        (-[WKPreferences _acceleratedCompositingEnabled]):
+        (-[WKPreferences _setRequestAnimationFrameEnabled:]):
+        (-[WKPreferences _requestAnimationFrameEnabled]):
+        * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
+
+2019-10-31  Alex Christensen  <achristensen@webkit.org>
+
         CMake build should make WebKit framework able to be used by Safari
         https://bugs.webkit.org/show_bug.cgi?id=203685
 
index 80cea66..ab73c59 100644 (file)
@@ -862,6 +862,36 @@ static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehav
     _preferences->setSecureContextChecksEnabled(enabled);
 }
 
+- (void)_setWebAudioEnabled:(BOOL)enabled
+{
+    _preferences->setWebAudioEnabled(enabled);
+}
+
+- (BOOL)_webAudioEnabled
+{
+    return _preferences->webAudioEnabled();
+}
+
+- (void)_setAcceleratedCompositingEnabled:(BOOL)enabled
+{
+    _preferences->setAcceleratedCompositingEnabled(enabled);
+}
+
+- (BOOL)_acceleratedCompositingEnabled
+{
+    return _preferences->acceleratedCompositingEnabled();
+}
+
+- (void)_setRequestAnimationFrameEnabled:(BOOL)enabled
+{
+    _preferences->setRequestAnimationFrameEnabled(enabled);
+}
+
+- (BOOL)_requestAnimationFrameEnabled
+{
+    return _preferences->requestAnimationFrameEnabled();
+}
+
 - (BOOL)_remotePlaybackEnabled
 {
     return _preferences->remotePlaybackEnabled();
@@ -893,16 +923,6 @@ static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehav
     return _preferences->canvasUsesAcceleratedDrawing();
 }
 
-- (void)_setAcceleratedCompositingEnabled:(BOOL)enabled
-{
-    _preferences->setAcceleratedCompositingEnabled(enabled);
-}
-
-- (BOOL)_acceleratedCompositingEnabled
-{
-    return _preferences->acceleratedCompositingEnabled();
-}
-
 - (void)_setDefaultTextEncodingName:(NSString *)name
 {
     _preferences->setDefaultTextEncodingName(name);
@@ -1296,16 +1316,6 @@ static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehav
     return _preferences->wantsBalancedSetDefersLoadingBehavior();
 }
 
-- (void)_setWebAudioEnabled:(BOOL)enabled
-{
-    _preferences->setWebAudioEnabled(enabled);
-}
-
-- (BOOL)_webAudioEnabled
-{
-    return _preferences->webAudioEnabled();
-}
-
 - (void)_setAggressiveTileRetentionEnabled:(BOOL)enabled
 {
     _preferences->setAggressiveTileRetentionEnabled(enabled);
index dd3cf15..da74b75 100644 (file)
@@ -158,12 +158,14 @@ typedef NS_ENUM(NSInteger, _WKEditableLinkBehavior) {
 @property (nonatomic, setter=_setMediaSourceEnabled:) BOOL _mediaSourceEnabled WK_API_AVAILABLE(macos(10.13.4), ios(WK_IOS_TBA));
 @property (nonatomic, setter=_setSecureContextChecksEnabled:) BOOL _secureContextChecksEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 @property (nonatomic, setter=_setRemotePlaybackEnabled:) BOOL _remotePlaybackEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, setter=_setWebAudioEnabled:) BOOL _webAudioEnabled WK_API_AVAILABLE(macos(10.14), ios(WK_IOS_TBA));
+@property (nonatomic, setter=_setAcceleratedCompositingEnabled:) BOOL _acceleratedCompositingEnabled WK_API_AVAILABLE(macos(10.13.4), ios(WK_IOS_TBA));
+@property (nonatomic, setter=_setRequestAnimationFrameEnabled:) BOOL _requestAnimationFrameEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 #if !TARGET_OS_IPHONE
 @property (nonatomic, setter=_setWebGLEnabled:) BOOL _webGLEnabled WK_API_AVAILABLE(macos(10.13.4));
 @property (nonatomic, setter=_setJavaEnabledForLocalFiles:) BOOL _javaEnabledForLocalFiles WK_API_AVAILABLE(macos(10.13.4));
 @property (nonatomic, setter=_setCanvasUsesAcceleratedDrawing:) BOOL _canvasUsesAcceleratedDrawing WK_API_AVAILABLE(macos(10.13.4));
-@property (nonatomic, setter=_setAcceleratedCompositingEnabled:) BOOL _acceleratedCompositingEnabled WK_API_AVAILABLE(macos(10.13.4));
 @property (nonatomic, setter=_setDefaultTextEncodingName:) NSString *_defaultTextEncodingName WK_API_AVAILABLE(macos(10.13.4));
 @property (nonatomic, setter=_setAuthorAndUserStylesEnabled:) BOOL _authorAndUserStylesEnabled WK_API_AVAILABLE(macos(10.13.4));
 @property (nonatomic, setter=_setDOMTimersThrottlingEnabled:) BOOL _domTimersThrottlingEnabled WK_API_AVAILABLE(macos(10.13.4));
@@ -202,7 +204,6 @@ typedef NS_ENUM(NSInteger, _WKEditableLinkBehavior) {
 @property (nonatomic, setter=_setTextAreasAreResizable:) BOOL _textAreasAreResizable WK_API_AVAILABLE(macos(10.14));
 @property (nonatomic, setter=_setUseGiantTiles:) BOOL _useGiantTiles WK_API_AVAILABLE(macos(10.14));
 @property (nonatomic, setter=_setWantsBalancedSetDefersLoadingBehavior:) BOOL _wantsBalancedSetDefersLoadingBehavior WK_API_AVAILABLE(macos(10.14));
-@property (nonatomic, setter=_setWebAudioEnabled:) BOOL _webAudioEnabled WK_API_AVAILABLE(macos(10.14));
 @property (nonatomic, setter=_setAggressiveTileRetentionEnabled:) BOOL _aggressiveTileRetentionEnabled WK_API_AVAILABLE(macos(10.14));
 @property (nonatomic, setter=_setAppNapEnabled:) BOOL _appNapEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA));
 #endif
index 8028670..e7fc533 100644 (file)
@@ -1,3 +1,14 @@
+2019-10-31  Alex Christensen  <achristensen@webkit.org>
+
+        Expose more WKPreferences SPI
+        https://bugs.webkit.org/show_bug.cgi?id=203631
+        <rdar://problem/56717160>
+
+        Reviewed by Brady Eidson.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/Preferences.mm:
+        (TEST):
+
 2019-10-30  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [iOS] imported/mozilla/svg/text/textpath-selection.svg is still flaky
index 65f9ff5..3a4bcfb 100644 (file)
@@ -25,6 +25,7 @@
 
 #import "config.h"
 
+#import "PlatformUtilities.h"
 #import "Test.h"
 #import "Utilities.h"
 #import <WebKit/WKFoundation.h>
@@ -66,6 +67,25 @@ TEST(WebKit, ExperimentalFeatures)
     }
 }
 
+TEST(WebKit, WebAudioPreference)
+{
+    auto check = [](bool value) {
+        WKWebViewConfiguration *configuration = [[[WKWebViewConfiguration alloc] init] autorelease];
+        configuration.preferences._webAudioEnabled = value;
+        auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration]);
+        __block bool done = false;
+        __block RetainPtr<NSString> result;
+        [webView evaluateJavaScript:@"new Boolean(window.webkitAudioContext).toString()" completionHandler:^(id resultFromJS, NSError *error) {
+            result = resultFromJS;
+            done = true;
+        }];
+        TestWebKitAPI::Util::run(&done);
+        return result.autorelease();
+    };
+    EXPECT_WK_STREQ(check(true), "true");
+    EXPECT_WK_STREQ(check(false), "false");
+}
+
 #if PLATFORM(MAC)
 
 static bool receivedAlert;