Title: [240949] trunk
Revision
240949
Author
s...@apple.com
Date
2019-02-04 16:47:17 -0800 (Mon, 04 Feb 2019)

Log Message

[CG] Enable setAdditionalSupportedImageTypes for WK1
https://bugs.webkit.org/show_bug.cgi?id=194190

Reviewed by Tim Horton.

Source/WebCore:

Move the function webCoreStringVectorFromNSStringArray from WebKit to
WebCore so it can be used by both WebKit and WebKitLegacy.

* platform/mac/StringUtilities.h:
* platform/mac/StringUtilities.mm:
(WebCore::webCoreStringVectorFromNSStringArray):

Source/WebKit:

Move the function webCoreStringVectorFromNSStringArray from WebKit to
WebCore so it can be used by both WebKit and WebKitLegacy.

* Platform/mac/StringUtilities.h:
* Platform/mac/StringUtilities.mm:
(WebKit::webCoreStringVectorFromNSStringArray): Deleted.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):

Source/WebKitLegacy/mac:

1. Define the preferences key AdditionalSupportedImageTypes.
2. Add additionalSupportedImageTypes as a private preference property.
3. Define the setter and the getter of the property.
4. Add function to convert from an id to an array of strings.
5. Call WebCore::setAdditionalSupportedImageTypes when preferences change.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(-[WebPreferences _stringArrayValueForKey:]):
(-[WebPreferences _setStringArrayValueForKey:forKey:]):
(-[WebPreferences setAdditionalSupportedImageTypes:]):
(-[WebPreferences additionalSupportedImageTypes]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Tools:

Add a test similar to the one under WebKit Cocoa but make it create a
WebView instead of a WKWebView.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/100x100-red.tga: Added.
* TestWebKitAPI/Tests/mac/AdditionalSupportedImageTypes.html: Added.
* TestWebKitAPI/Tests/mac/AdditionalSupportedImageTypes.mm: Added.
(-[AdditionalSupportedImageTypesTest webView:didFinishLoadForFrame:]):
(TestWebKitAPI::runTest):
(TestWebKitAPI::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (240948 => 240949)


--- trunk/Source/WebCore/ChangeLog	2019-02-05 00:28:24 UTC (rev 240948)
+++ trunk/Source/WebCore/ChangeLog	2019-02-05 00:47:17 UTC (rev 240949)
@@ -1,3 +1,17 @@
+2019-02-04  Said Abou-Hallawa  <s...@apple.com>
+
+        [CG] Enable setAdditionalSupportedImageTypes for WK1
+        https://bugs.webkit.org/show_bug.cgi?id=194190
+
+        Reviewed by Tim Horton.
+
+        Move the function webCoreStringVectorFromNSStringArray from WebKit to
+        WebCore so it can be used by both WebKit and WebKitLegacy.
+
+        * platform/mac/StringUtilities.h:
+        * platform/mac/StringUtilities.mm:
+        (WebCore::webCoreStringVectorFromNSStringArray):
+
 2019-02-04  Justin Fan  <justin_...@apple.com>
 
         [Web GPU] Code clean-up for RenderPipeline backend

Modified: trunk/Source/WebCore/platform/mac/StringUtilities.h (240948 => 240949)


--- trunk/Source/WebCore/platform/mac/StringUtilities.h	2019-02-05 00:28:24 UTC (rev 240948)
+++ trunk/Source/WebCore/platform/mac/StringUtilities.h	2019-02-05 00:47:17 UTC (rev 240949)
@@ -29,5 +29,11 @@
 #import <wtf/Forward.h>
 
 namespace WebCore {
+
 WEBCORE_EXPORT bool stringMatchesWildcardString(const String& stringToBeMatched, const String& wildcardString);
+
+#ifdef __OBJC__
+WEBCORE_EXPORT Vector<String> webCoreStringVectorFromNSStringArray(NSArray<NSString *> *);
+#endif // defined(__OBJC__)
+
 }

Modified: trunk/Source/WebCore/platform/mac/StringUtilities.mm (240948 => 240949)


--- trunk/Source/WebCore/platform/mac/StringUtilities.mm	2019-02-05 00:28:24 UTC (rev 240948)
+++ trunk/Source/WebCore/platform/mac/StringUtilities.mm	2019-02-05 00:47:17 UTC (rev 240949)
@@ -59,4 +59,15 @@
     return JSC::Yarr::RegularExpression(wildcardRegexPatternString(wildcardString), JSC::Yarr::TextCaseInsensitive).match(string) != -1;
 }
 
+Vector<String> webCoreStringVectorFromNSStringArray(NSArray<NSString *> *nsStringArray)
+{
+    Vector<String> stringVector;
+    stringVector.reserveInitialCapacity([nsStringArray count]);
+
+    for (NSString *nsString in nsStringArray)
+        stringVector.uncheckedAppend(nsString);
+
+    return stringVector;
 }
+
+}

Modified: trunk/Source/WebKit/ChangeLog (240948 => 240949)


--- trunk/Source/WebKit/ChangeLog	2019-02-05 00:28:24 UTC (rev 240948)
+++ trunk/Source/WebKit/ChangeLog	2019-02-05 00:47:17 UTC (rev 240949)
@@ -1,3 +1,19 @@
+2019-02-04  Said Abou-Hallawa  <s...@apple.com>
+
+        [CG] Enable setAdditionalSupportedImageTypes for WK1
+        https://bugs.webkit.org/show_bug.cgi?id=194190
+
+        Reviewed by Tim Horton.
+
+        Move the function webCoreStringVectorFromNSStringArray from WebKit to
+        WebCore so it can be used by both WebKit and WebKitLegacy.
+
+        * Platform/mac/StringUtilities.h:
+        * Platform/mac/StringUtilities.mm:
+        (WebKit::webCoreStringVectorFromNSStringArray): Deleted.
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _initializeWithConfiguration:]):
+
 2019-02-04  Benjamin Poulain  <benja...@webkit.org>
 
         Use deferrable timer to restart the Responsiveness Timer on each wheel event

Modified: trunk/Source/WebKit/Platform/mac/StringUtilities.h (240948 => 240949)


--- trunk/Source/WebKit/Platform/mac/StringUtilities.h	2019-02-05 00:28:24 UTC (rev 240948)
+++ trunk/Source/WebKit/Platform/mac/StringUtilities.h	2019-02-05 00:47:17 UTC (rev 240949)
@@ -37,8 +37,6 @@
 NSString *nsStringFromWebCoreString(const String&);
 NSString *formattedPhoneNumberString(NSString *originalPhoneNumber);
 
-Vector<String> webCoreStringVectorFromNSStringArray(NSArray<NSString *> *);
-
 #endif // defined(__OBJC__)
 
 }

Modified: trunk/Source/WebKit/Platform/mac/StringUtilities.mm (240948 => 240949)


--- trunk/Source/WebKit/Platform/mac/StringUtilities.mm	2019-02-05 00:28:24 UTC (rev 240948)
+++ trunk/Source/WebKit/Platform/mac/StringUtilities.mm	2019-02-05 00:47:17 UTC (rev 240949)
@@ -82,15 +82,4 @@
 
 #endif // ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC)
 
-Vector<String> webCoreStringVectorFromNSStringArray(NSArray<NSString *> *nsStringArray)
-{
-    Vector<String> stringVector;
-    stringVector.reserveInitialCapacity([nsStringArray count]);
-
-    for (NSString *nsString in nsStringArray)
-        stringVector.uncheckedAppend(nsString);
-
-    return stringVector;
 }
-
-}

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (240948 => 240949)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-02-05 00:28:24 UTC (rev 240948)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-02-05 00:47:17 UTC (rev 240949)
@@ -51,7 +51,6 @@
 #import "RemoteObjectRegistry.h"
 #import "RemoteObjectRegistryMessages.h"
 #import "SafeBrowsingWarning.h"
-#import "StringUtilities.h"
 #import "UIDelegate.h"
 #import "UserMediaProcessManager.h"
 #import "VersionChecks.h"
@@ -112,6 +111,7 @@
 #import <WebCore/SchemeRegistry.h>
 #import <WebCore/Settings.h>
 #import <WebCore/SharedBuffer.h>
+#import <WebCore/StringUtilities.h>
 #import <WebCore/ValidationBubble.h>
 #import <WebCore/ViewportArguments.h>
 #import <WebCore/WritingMode.h>
@@ -583,7 +583,7 @@
             pageConfiguration->setPageGroup(WebKit::WebPageGroup::create(configuration._groupIdentifier).ptr());
     }
 
-    pageConfiguration->setAdditionalSupportedImageTypes(WebKit::webCoreStringVectorFromNSStringArray([_configuration _additionalSupportedImageTypes]));
+    pageConfiguration->setAdditionalSupportedImageTypes(WebCore::webCoreStringVectorFromNSStringArray([_configuration _additionalSupportedImageTypes]));
 
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::suppressesIncrementalRenderingKey(), WebKit::WebPreferencesStore::Value(!![_configuration suppressesIncrementalRendering]));
 

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (240948 => 240949)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2019-02-05 00:28:24 UTC (rev 240948)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2019-02-05 00:47:17 UTC (rev 240949)
@@ -1,3 +1,26 @@
+2019-02-04  Said Abou-Hallawa  <s...@apple.com>
+
+        [CG] Enable setAdditionalSupportedImageTypes for WK1
+        https://bugs.webkit.org/show_bug.cgi?id=194190
+
+        Reviewed by Tim Horton.
+
+        1. Define the preferences key AdditionalSupportedImageTypes.
+        2. Add additionalSupportedImageTypes as a private preference property.
+        3. Define the setter and the getter of the property.
+        4. Add function to convert from an id to an array of strings.
+        5. Call WebCore::setAdditionalSupportedImageTypes when preferences change.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (-[WebPreferences _stringArrayValueForKey:]):
+        (-[WebPreferences _setStringArrayValueForKey:forKey:]):
+        (-[WebPreferences setAdditionalSupportedImageTypes:]):
+        (-[WebPreferences additionalSupportedImageTypes]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2019-02-04  Timothy Hatcher  <timo...@apple.com>
 
         Add WebView SPI to temporarily force light or dark appearance on a page.

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h (240948 => 240949)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h	2019-02-05 00:28:24 UTC (rev 240948)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h	2019-02-05 00:47:17 UTC (rev 240949)
@@ -66,6 +66,7 @@
 #define WebKitAllowAnimatedImagesPreferenceKey @"WebKitAllowAnimatedImagesPreferenceKey"
 #define WebKitAllowAnimatedImageLoopingPreferenceKey @"WebKitAllowAnimatedImageLoopingPreferenceKey"
 #define WebKitDisplayImagesKey @"WebKitDisplayImagesKey"
+#define WebKitAdditionalSupportedImageTypesKey  @"WebKitAdditionalSupportedImageTypesKey"
 #define WebKitLoadSiteIconsKey @"WebKitLoadSiteIconsKey"
 #define WebKitBackForwardCacheExpirationIntervalKey @"WebKitBackForwardCacheExpirationIntervalKey"
 #if !TARGET_OS_IPHONE

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm (240948 => 240949)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm	2019-02-05 00:28:24 UTC (rev 240948)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm	2019-02-05 00:47:17 UTC (rev 240949)
@@ -757,6 +757,36 @@
     [self _postPreferencesChangedNotification];
 }
 
+- (NSArray<NSString *> *)_stringArrayValueForKey:(NSString *)key
+{
+    id value = [self _valueForKey:key];
+    if (![value isKindOfClass:[NSArray class]])
+        return nil;
+
+    NSArray *array = (NSArray *)value;
+    for (id object in array) {
+        if (![object isKindOfClass:[NSString class]])
+            return nil;
+    }
+
+    return (NSArray<NSString *> *)array;
+}
+
+- (void)_setStringArrayValueForKey:(NSArray<NSString *> *)value forKey:(NSString *)key
+{
+    NSString *_key = KEY(key);
+#if PLATFORM(IOS_FAMILY)
+    dispatch_barrier_sync(_private->readWriteQueue, ^{
+#endif
+        [_private->values.get() setObject:value forKey:_key];
+#if PLATFORM(IOS_FAMILY)
+    });
+#endif
+    if (_private->autosaves)
+        [[NSUserDefaults standardUserDefaults] setObject:value forKey:_key];
+    [self _postPreferencesChangedNotification];
+}
+
 - (int)_integerValueForKey:(NSString *)key
 {
     id o = [self _valueForKey:key];
@@ -1159,6 +1189,16 @@
     return [self _boolValueForKey: WebKitDisplayImagesKey];
 }
 
+- (void)setAdditionalSupportedImageTypes:(NSArray<NSString*> *)imageTypes
+{
+    [self _setStringArrayValueForKey:imageTypes forKey:WebKitAdditionalSupportedImageTypesKey];
+}
+
+- (NSArray<NSString *> *)additionalSupportedImageTypes
+{
+    return [self _stringArrayValueForKey:WebKitAdditionalSupportedImageTypesKey];
+}
+
 - (void)setAutosaves:(BOOL)flag
 {
     _private->autosaves = flag;

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h (240948 => 240949)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h	2019-02-05 00:28:24 UTC (rev 240948)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h	2019-02-05 00:47:17 UTC (rev 240949)
@@ -626,4 +626,7 @@
 
 @property (nonatomic) NSString *mediaContentTypesRequiringHardwareSupport;
 
+// additionalSupportedImageTypes is an array of image UTIs.
+@property (nonatomic, retain) NSArray<NSString *> *additionalSupportedImageTypes;
+
 @end

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (240948 => 240949)


--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2019-02-05 00:28:24 UTC (rev 240948)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2019-02-05 00:47:17 UTC (rev 240949)
@@ -204,9 +204,11 @@
 #import <WebCore/Settings.h>
 #import <WebCore/ShouldTreatAsContinuingLoad.h>
 #import <WebCore/SocketProvider.h>
+#import <WebCore/StringUtilities.h>
 #import <WebCore/StyleProperties.h>
 #import <WebCore/TextResourceDecoder.h>
 #import <WebCore/ThreadCheck.h>
+#import <WebCore/UTIRegistry.h>
 #import <WebCore/UserAgent.h>
 #import <WebCore/UserContentController.h>
 #import <WebCore/UserGestureIndicator.h>
@@ -2879,6 +2881,9 @@
     settings.setStandardFontFamily([preferences standardFontFamily]);
     settings.setLoadsImagesAutomatically([preferences loadsImagesAutomatically]);
     settings.setLoadsSiteIconsIgnoringImageLoadingSetting([preferences loadsSiteIconsIgnoringImageLoadingPreference]);
+
+    WebCore::setAdditionalSupportedImageTypes(WebCore::webCoreStringVectorFromNSStringArray([preferences additionalSupportedImageTypes]));
+
 #if PLATFORM(IOS_FAMILY)
     settings.setShouldPrintBackgrounds(true);
 #else

Modified: trunk/Tools/ChangeLog (240948 => 240949)


--- trunk/Tools/ChangeLog	2019-02-05 00:28:24 UTC (rev 240948)
+++ trunk/Tools/ChangeLog	2019-02-05 00:47:17 UTC (rev 240949)
@@ -1,3 +1,21 @@
+2019-02-04  Said Abou-Hallawa  <s...@apple.com>
+
+        [CG] Enable setAdditionalSupportedImageTypes for WK1
+        https://bugs.webkit.org/show_bug.cgi?id=194190
+
+        Reviewed by Tim Horton.
+
+        Add a test similar to the one under WebKit Cocoa but make it create a
+        WebView instead of a WKWebView.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/mac/100x100-red.tga: Added.
+        * TestWebKitAPI/Tests/mac/AdditionalSupportedImageTypes.html: Added.
+        * TestWebKitAPI/Tests/mac/AdditionalSupportedImageTypes.mm: Added.
+        (-[AdditionalSupportedImageTypesTest webView:didFinishLoadForFrame:]):
+        (TestWebKitAPI::runTest):
+        (TestWebKitAPI::TEST):
+
 2019-02-04  Zalan Bujtas  <za...@apple.com>
 
         [First paint] Adjust "finishedParsingMainDocument" flag by taking deferred and async scripts into account.

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (240948 => 240949)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-02-05 00:28:24 UTC (rev 240948)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-02-05 00:47:17 UTC (rev 240949)
@@ -266,6 +266,7 @@
 		55A817FC218100E00004A39A /* AdditionalSupportedImageTypes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 55A817FB218100E00004A39A /* AdditionalSupportedImageTypes.mm */; };
 		55A817FF2181021A0004A39A /* 100x100-red.tga in Copy Resources */ = {isa = PBXBuildFile; fileRef = 55A817FE218101DF0004A39A /* 100x100-red.tga */; };
 		55A81800218102210004A39A /* 400x400-green.png in Copy Resources */ = {isa = PBXBuildFile; fileRef = 55A817FD218101DF0004A39A /* 400x400-green.png */; };
+		55F9D2E52205031800A9AB38 /* AdditionalSupportedImageTypes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 55F9D2E42205031800A9AB38 /* AdditionalSupportedImageTypes.mm */; };
 		5714ECB91CA8B5B000051AC8 /* DownloadRequestOriginalURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECB81CA8B58800051AC8 /* DownloadRequestOriginalURL.html */; };
 		5714ECBB1CA8BFE400051AC8 /* DownloadRequestOriginalURLFrame.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECBA1CA8BFD100051AC8 /* DownloadRequestOriginalURLFrame.html */; };
 		5714ECBD1CA8C22A00051AC8 /* DownloadRequestOriginalURL2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECBC1CA8C21800051AC8 /* DownloadRequestOriginalURL2.html */; };
@@ -343,6 +344,8 @@
 		6B306106218A372900F5A802 /* ClosingWebView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6B306105218A372900F5A802 /* ClosingWebView.mm */; };
 		6B9ABE122086952F00D75DE6 /* HTTPParsers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B9ABE112086952F00D75DE6 /* HTTPParsers.cpp */; };
 		6BFD294C1D5E6C1D008EC968 /* HashCountedSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */; };
+		725C3EEF220570BE007C36FC /* 100x100-red.tga in Copy Resources */ = {isa = PBXBuildFile; fileRef = 725C3EEE22057005007C36FC /* 100x100-red.tga */; };
+		725C3EF322058A5B007C36FC /* AdditionalSupportedImageTypes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 725C3EF2220584BA007C36FC /* AdditionalSupportedImageTypes.html */; };
 		751B05D61F8EAC410028A09E /* DatabaseTrackerTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 751B05D51F8EAC1A0028A09E /* DatabaseTrackerTest.mm */; };
 		754CEC811F6722F200D0039A /* AutoFillAvailable.mm in Sources */ = {isa = PBXBuildFile; fileRef = 754CEC801F6722DC00D0039A /* AutoFillAvailable.mm */; };
 		7673499D1930C5BB00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7673499A1930182E00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp */; };
@@ -996,10 +999,12 @@
 			dstPath = TestWebKitAPI.resources;
 			dstSubfolderSpec = 7;
 			files = (
+				725C3EEF220570BE007C36FC /* 100x100-red.tga in Copy Resources */,
 				55A817FF2181021A0004A39A /* 100x100-red.tga in Copy Resources */,
 				1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */,
 				55A81800218102210004A39A /* 400x400-green.png in Copy Resources */,
 				379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */,
+				725C3EF322058A5B007C36FC /* AdditionalSupportedImageTypes.html in Copy Resources */,
 				1C2B81871C8925A000A5529F /* Ahem.ttf in Copy Resources */,
 				1A63479F183D72A4005B1707 /* all-content-in-one-iframe.html in Copy Resources */,
 				C25CCA0D1E5141840026CB8A /* AllAhem.svg in Copy Resources */,
@@ -1644,6 +1649,7 @@
 		55A817FB218100E00004A39A /* AdditionalSupportedImageTypes.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AdditionalSupportedImageTypes.mm; sourceTree = "<group>"; };
 		55A817FD218101DF0004A39A /* 400x400-green.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "400x400-green.png"; sourceTree = "<group>"; };
 		55A817FE218101DF0004A39A /* 100x100-red.tga */ = {isa = PBXFileReference; lastKnownFileType = file; path = "100x100-red.tga"; sourceTree = "<group>"; };
+		55F9D2E42205031800A9AB38 /* AdditionalSupportedImageTypes.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = AdditionalSupportedImageTypes.mm; sourceTree = "<group>"; };
 		5714ECB81CA8B58800051AC8 /* DownloadRequestOriginalURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURL.html; sourceTree = "<group>"; };
 		5714ECBA1CA8BFD100051AC8 /* DownloadRequestOriginalURLFrame.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURLFrame.html; sourceTree = "<group>"; };
 		5714ECBC1CA8C21800051AC8 /* DownloadRequestOriginalURL2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURL2.html; sourceTree = "<group>"; };
@@ -1721,6 +1727,8 @@
 		6B0A07F621FA9C2B00D57391 /* AdClickAttribution.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AdClickAttribution.cpp; sourceTree = "<group>"; };
 		6B306105218A372900F5A802 /* ClosingWebView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ClosingWebView.mm; sourceTree = "<group>"; };
 		6B9ABE112086952F00D75DE6 /* HTTPParsers.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPParsers.cpp; sourceTree = "<group>"; };
+		725C3EEE22057005007C36FC /* 100x100-red.tga */ = {isa = PBXFileReference; lastKnownFileType = file; path = "100x100-red.tga"; sourceTree = "<group>"; };
+		725C3EF2220584BA007C36FC /* AdditionalSupportedImageTypes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = AdditionalSupportedImageTypes.html; sourceTree = "<group>"; };
 		751B05D51F8EAC1A0028A09E /* DatabaseTrackerTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DatabaseTrackerTest.mm; sourceTree = "<group>"; };
 		754CEC801F6722DC00D0039A /* AutoFillAvailable.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AutoFillAvailable.mm; sourceTree = "<group>"; };
 		7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCacheAddImageToCacheIOS.mm; sourceTree = "<group>"; };
@@ -3421,6 +3429,7 @@
 			children = (
 				C07E6CB013FD737C0038B22B /* Resources */,
 				379028B514FABD92007E6B43 /* AcceptsFirstMouse.mm */,
+				55F9D2E42205031800A9AB38 /* AdditionalSupportedImageTypes.mm */,
 				B55F119F1516834F00915916 /* AttributedString.mm */,
 				00CD9F6215BE312C002DA2CE /* BackForwardList.mm */,
 				1C7FEB1F207C0F2D00D23278 /* BackgroundColor.mm */,
@@ -3495,7 +3504,9 @@
 		C07E6CB013FD737C0038B22B /* Resources */ = {
 			isa = PBXGroup;
 			children = (
+				725C3EEE22057005007C36FC /* 100x100-red.tga */,
 				379028B814FABE49007E6B43 /* acceptsFirstMouse.html */,
+				725C3EF2220584BA007C36FC /* AdditionalSupportedImageTypes.html */,
 				B55F11B01517A2C400915916 /* attributedStringCustomFont.html */,
 				7C9ED98A17A19D0600E4DC33 /* attributedStringStrikethrough.html */,
 				26DF5A6115A2A22B003689C2 /* CancelLoadFromResourceLoadDelegate.html */,
@@ -3915,6 +3926,7 @@
 				6B0A07F721FA9C2B00D57391 /* AdClickAttribution.cpp in Sources */,
 				37E7DD641EA06FF2009B396D /* AdditionalReadAccessAllowedURLs.mm in Sources */,
 				55A817FC218100E00004A39A /* AdditionalSupportedImageTypes.mm in Sources */,
+				55F9D2E52205031800A9AB38 /* AdditionalSupportedImageTypes.mm in Sources */,
 				7A909A7D1D877480007E10F8 /* AffineTransform.cpp in Sources */,
 				A1DF74321C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm in Sources */,
 				2DE71AFE1D49C0BD00904094 /* AnimatedResize.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/mac/100x100-red.tga (0 => 240949)


--- trunk/Tools/TestWebKitAPI/Tests/mac/100x100-red.tga	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/100x100-red.tga	2019-02-05 00:47:17 UTC (rev 240949)
@@ -0,0 +1,2 @@
+
+dd (\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xF
 F\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\x
 E3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF\xE3\xFF\xFF
\ No newline at end of file

Added: trunk/Tools/TestWebKitAPI/Tests/mac/AdditionalSupportedImageTypes.html (0 => 240949)


--- trunk/Tools/TestWebKitAPI/Tests/mac/AdditionalSupportedImageTypes.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/AdditionalSupportedImageTypes.html	2019-02-05 00:47:17 UTC (rev 240949)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <img src="" _onerror_="imgError(this);">
+    <script>
+        function imgError(image) {
+            image.parentNode. removeChild(image);
+            return true;
+        }
+    </script>
+</body>
+</html>

Added: trunk/Tools/TestWebKitAPI/Tests/mac/AdditionalSupportedImageTypes.mm (0 => 240949)


--- trunk/Tools/TestWebKitAPI/Tests/mac/AdditionalSupportedImageTypes.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/AdditionalSupportedImageTypes.mm	2019-02-05 00:47:17 UTC (rev 240949)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#import "PlatformUtilities.h"
+#import "PlatformWebView.h"
+
+#import <WebKit/DOM.h>
+#import <WebKit/WebPreferencesPrivate.h>
+#import <WebKit/WebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+@interface AdditionalSupportedImageTypesTest : NSObject <WebFrameLoadDelegate> {
+}
+@end
+
+static bool didFinishLoad;
+
+@implementation AdditionalSupportedImageTypesTest
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+    didFinishLoad = true;
+}
+@end
+
+namespace TestWebKitAPI {
+
+static void runTest(NSArray *additionalSupportedImageTypes, Boolean expectedToLoad)
+{
+    RetainPtr<WebPreferences> preferences = adoptNS([[WebPreferences alloc] initWithIdentifier:nil]);
+    [preferences setAdditionalSupportedImageTypes:additionalSupportedImageTypes];
+
+    RetainPtr<WebView> webView = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+    [webView setPreferences:preferences.get()];
+
+    RetainPtr<AdditionalSupportedImageTypesTest> testController = adoptNS([AdditionalSupportedImageTypesTest new]);
+    webView.get().frameLoadDelegate = testController.get();
+
+    RetainPtr<NSURL> testURL = [[NSBundle mainBundle] URLForResource:@"AdditionalSupportedImageTypes" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+    [[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
+
+    Util::run(&didFinishLoad);
+    didFinishLoad = false;
+
+    DOMDocument *document = webView.get().mainFrameDocument;
+    DOMElement *documentElement = [document documentElement];
+
+    DOMHTMLImageElement *image = (DOMHTMLImageElement *)[documentElement querySelector:@"img"];
+    EXPECT_EQ(image != nullptr, expectedToLoad);
+    if (image)
+        EXPECT_EQ([image width], 100);
+}
+
+TEST(WebKitLegacy, AdditionalSupportedStringImageType)
+{
+    runTest(@[@"com.truevision.tga-image"], true);
+}
+
+TEST(WebKitLegacy, AdditionalBogusStringImageType)
+{
+    runTest(@[@"public.bogus"], false);
+}
+
+TEST(WebKitLegacy, AdditionalEmptyArrayImageType)
+{
+    runTest(@[], false);
+}
+
+TEST(WebKitLegacy, AdditionalArryOfNullImageType)
+{
+    runTest(@[[NSNull null]], false);
+}
+
+TEST(WebKitLegacy, AdditionalArrayOfArrayImageType)
+{
+    runTest(@[@[@"com.truevision.tga-image"]], false);
+}
+
+} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to