Source/WebKit2:
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Dec 2016 19:49:37 +0000 (19:49 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Dec 2016 19:49:37 +0000 (19:49 +0000)
[Cocoa] SPI for setloadsImagesAutomatically
https://bugs.webkit.org/show_bug.cgi?id=166401

Patch by Zhuo Li <zachli@apple.com> on 2016-12-22
Reviewed by Darin Adler.

* UIProcess/API/Cocoa/WKPreferences.mm: Call the C API under the hood.
(-[WKPreferences _loadsImagesAutomatically]):
(-[WKPreferences _setLoadsImagesAutomatically:]):

* UIProcess/API/Cocoa/WKPreferencesPrivate.h:
Add `_loadsImagesAutomatically` property.

Tools:
[Cocoa] SPI for setloadsImagesAutomatically.
https://bugs.webkit.org/show_bug.cgi?id=166401.

Patch by Zhuo Li <zachli@apple.com> on 2016-12-22
Reviewed by Darin Adler.

* TestWebKitAPI/Tests/WebKit2Cocoa/Preferences.mm:
(TEST): Test the _setLoadsImagesAutomatically SPI. By default,
_loadsImagesAutomatically returns YES.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKPreferences.mm
Source/WebKit2/UIProcess/API/Cocoa/WKPreferencesPrivate.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Preferences.mm

index a1bf944..cec4d6b 100644 (file)
@@ -1,3 +1,17 @@
+2016-12-22  Zhuo Li  <zachli@apple.com>
+
+        [Cocoa] SPI for setloadsImagesAutomatically
+        https://bugs.webkit.org/show_bug.cgi?id=166401
+
+        Reviewed by Darin Adler.
+
+        * UIProcess/API/Cocoa/WKPreferences.mm: Call the C API under the hood.
+        (-[WKPreferences _loadsImagesAutomatically]):
+        (-[WKPreferences _setLoadsImagesAutomatically:]):
+
+        * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
+        Add `_loadsImagesAutomatically` property.
+
 2016-12-22  Eric Carlson  <eric.carlson@apple.com>
 
         AVPlayerLayer isn't available on every system
index 149f311..6d058e9 100644 (file)
@@ -517,6 +517,16 @@ static _WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPo
     _preferences->setShouldSuppressKeyboardInputDuringProvisionalNavigation(shouldSuppress);
 }
 
+- (BOOL)_loadsImagesAutomatically
+{
+    return _preferences->loadsImagesAutomatically();
+}
+
+- (void)_setLoadsImagesAutomatically:(BOOL)loadsImagesAutomatically
+{
+    _preferences->setLoadsImagesAutomatically(loadsImagesAutomatically);
+}
+
 @end
 
 #endif // WK_API_ENABLED
index 7cf1c6d..9741d9c 100644 (file)
@@ -94,6 +94,8 @@ typedef NS_OPTIONS(NSUInteger, _WKJavaScriptRuntimeFlags) {
 
 @property (nonatomic, setter=_setApplePayCapabilityDisclosureAllowed:) BOOL _applePayCapabilityDisclosureAllowed WK_API_AVAILABLE(macosx(10.12), ios(10.0));
 
+@property (nonatomic, setter=_setLoadsImagesAutomatically:) BOOL _loadsImagesAutomatically WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 + (NSArray<_WKExperimentalFeature *> *)_experimentalFeatures WK_API_AVAILABLE(macosx(10.12), ios(10.0));
 - (BOOL)_isEnabledForFeature:(_WKExperimentalFeature *)feature WK_API_AVAILABLE(macosx(10.12), ios(10.0));
 - (void)_setEnabled:(BOOL)value forFeature:(_WKExperimentalFeature *)feature WK_API_AVAILABLE(macosx(10.12), ios(10.0));
index a8eeee8..c2d1fe8 100644 (file)
@@ -1,3 +1,14 @@
+2016-12-22  Zhuo Li  <zachli@apple.com>
+
+        [Cocoa] SPI for setloadsImagesAutomatically.
+        https://bugs.webkit.org/show_bug.cgi?id=166401.
+
+        Reviewed by Darin Adler.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/Preferences.mm:
+        (TEST): Test the _setLoadsImagesAutomatically SPI. By default,
+        _loadsImagesAutomatically returns YES.
+
 2016-12-22  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         fast/events/ios/viewport-shrink-to-fit-allows-double-tap.html is flaky/order dependent
index 1af035d..2129047 100644 (file)
@@ -42,6 +42,17 @@ TEST(WebKit2, DefaultWKPreferences)
     EXPECT_TRUE([preferences _isStandalone]);
 }
 
+TEST(WebKit2, LoadsImagesAutomatically)
+{
+    RetainPtr<WKPreferences> preferences = adoptNS([[WKPreferences alloc] init]);
+
+    EXPECT_TRUE([preferences _loadsImagesAutomatically]);
+    [preferences _setLoadsImagesAutomatically:NO];
+    EXPECT_FALSE([preferences _loadsImagesAutomatically]);
+    [preferences _setLoadsImagesAutomatically:YES];
+    EXPECT_TRUE([preferences _loadsImagesAutomatically]);
+}
+
 TEST(WebKit2, ExperimentalFeatures)
 {
     NSArray *features = [WKPreferences _experimentalFeatures];