Title: [258120] trunk
Revision
258120
Author
pvol...@apple.com
Date
2020-03-08 16:52:40 -0700 (Sun, 08 Mar 2020)

Log Message

[iOS] Mapping to UTI from tag and tag class should be performed in the UI process
https://bugs.webkit.org/show_bug.cgi?id=208783

Reviewed by Brent Fulgham.

Source/WebCore:

This mapping should be done in the UI process, since it is using a system service that will no longer be available
in the WebContent process. To achieve this, the method +[UTTypeRecord typeRecordWithTagOverride] is swizzled in
the WebContent process, and is using the cached mapping sent from the UI process.

API test: WebKit.UTIFromTag

* WebCore.xcodeproj/project.pbxproj:
* platform/cocoa/UTTypeRecordSwizzler.h: Added.
(WebCore::UTTypeItem::encode const):
(WebCore::UTTypeItem::decode):
* platform/cocoa/UTTypeRecordSwizzler.mm: Added.
(-[WebUTTypeRecord setIdentifier:]):
(WebCore::vectorOfUTTypeRecords):
(WebCore::typeRecordWithTagOverride):
(WebCore::createVectorOfUTTypeItem):
(WebCore::setVectorOfUTTypeItem):
(WebCore::swizzleUTTypeRecord):
* platform/network/mac/UTIUtilities.h:
* platform/network/mac/UTIUtilities.mm:
(WebCore::UTIFromTag):
* testing/Internals.cpp:
(WebCore::Internals::getUTIFromTag):
* testing/Internals.h:
* testing/Internals.idl:
* testing/Internals.mm:
(WebCore::Internals::getUTIFromTag):

Source/WebCore/PAL:

* PAL.xcodeproj/project.pbxproj:
* pal/spi/cocoa/NSUTTypeRecordSPI.h: Added.

Source/WebKit:

Send mapping from tag/tag class to UTI from the UI process to the WebContent process as part of the WebProcess
creation parameters. Also, issue some mach-lookup extensions to the WebContent process if Accessibility is
enabled.

* Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode const):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):

Source/WTF:

* wtf/PlatformUse.h:

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (258119 => 258120)


--- trunk/Source/WTF/ChangeLog	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WTF/ChangeLog	2020-03-08 23:52:40 UTC (rev 258120)
@@ -1,3 +1,12 @@
+2020-03-08  Per Arne Vollan  <pvol...@apple.com>
+
+        [iOS] Mapping to UTI from tag and tag class should be performed in the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=208783
+
+        Reviewed by Brent Fulgham.
+
+        * wtf/PlatformUse.h:
+
 2020-03-08  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Lazily generate CGPaths for some simple types of paths, such as arcs and lines

Modified: trunk/Source/WTF/wtf/PlatformUse.h (258119 => 258120)


--- trunk/Source/WTF/wtf/PlatformUse.h	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WTF/wtf/PlatformUse.h	2020-03-08 23:52:40 UTC (rev 258120)
@@ -320,3 +320,7 @@
 #if PLATFORM(COCOA) && !(PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101600)
 #define USE_CTFONTTRANSFORMGLYPHSWITHLANGUAGE 1
 #endif
+
+#if PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000
+#define USE_UTTYPE_SWIZZLER 1
+#endif

Modified: trunk/Source/WebCore/ChangeLog (258119 => 258120)


--- trunk/Source/WebCore/ChangeLog	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebCore/ChangeLog	2020-03-08 23:52:40 UTC (rev 258120)
@@ -1,3 +1,37 @@
+2020-03-08  Per Arne Vollan  <pvol...@apple.com>
+
+        [iOS] Mapping to UTI from tag and tag class should be performed in the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=208783
+
+        Reviewed by Brent Fulgham.
+
+        This mapping should be done in the UI process, since it is using a system service that will no longer be available
+        in the WebContent process. To achieve this, the method +[UTTypeRecord typeRecordWithTagOverride] is swizzled in
+        the WebContent process, and is using the cached mapping sent from the UI process.
+
+        API test: WebKit.UTIFromTag
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/cocoa/UTTypeRecordSwizzler.h: Added.
+        (WebCore::UTTypeItem::encode const):
+        (WebCore::UTTypeItem::decode):
+        * platform/cocoa/UTTypeRecordSwizzler.mm: Added.
+        (-[WebUTTypeRecord setIdentifier:]):
+        (WebCore::vectorOfUTTypeRecords):
+        (WebCore::typeRecordWithTagOverride):
+        (WebCore::createVectorOfUTTypeItem):
+        (WebCore::setVectorOfUTTypeItem):
+        (WebCore::swizzleUTTypeRecord):
+        * platform/network/mac/UTIUtilities.h:
+        * platform/network/mac/UTIUtilities.mm:
+        (WebCore::UTIFromTag):
+        * testing/Internals.cpp:
+        (WebCore::Internals::getUTIFromTag):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+        * testing/Internals.mm:
+        (WebCore::Internals::getUTIFromTag):
+
 2020-03-08  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Lazily generate CGPaths for some simple types of paths, such as arcs and lines

Modified: trunk/Source/WebCore/PAL/ChangeLog (258119 => 258120)


--- trunk/Source/WebCore/PAL/ChangeLog	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebCore/PAL/ChangeLog	2020-03-08 23:52:40 UTC (rev 258120)
@@ -1,3 +1,13 @@
+2020-03-08  Per Arne Vollan  <pvol...@apple.com>
+
+        [iOS] Mapping to UTI from tag and tag class should be performed in the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=208783
+
+        Reviewed by Brent Fulgham.
+
+        * PAL.xcodeproj/project.pbxproj:
+        * pal/spi/cocoa/NSUTTypeRecordSPI.h: Added.
+
 2020-03-08  Konstantin Tokarev  <annu...@yandex.ru>
 
         [CMake] Some fixes for building Mac port

Modified: trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (258119 => 258120)


--- trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj	2020-03-08 23:52:40 UTC (rev 258120)
@@ -351,6 +351,7 @@
 		CDACB35F23873E480018D7CE /* MediaToolboxSoftLink.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaToolboxSoftLink.h; sourceTree = "<group>"; };
 		CDF91112220E4EEC001EA39E /* CelestialSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CelestialSPI.h; sourceTree = "<group>"; };
 		CE5673862151A7B9002F92D7 /* IOKitSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IOKitSPI.h; sourceTree = "<group>"; };
+		E3037F4F2415ADF40031CA0F /* NSUTTypeRecordSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSUTTypeRecordSPI.h; sourceTree = "<group>"; };
 		E5D45D112106A07400D2B738 /* NSColorWellSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSColorWellSPI.h; sourceTree = "<group>"; };
 		E5D45D132106A18700D2B738 /* NSPopoverColorWellSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSPopoverColorWellSPI.h; sourceTree = "<group>"; };
 		F442915D1FA52473002CC93E /* NSFileSizeFormatterSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSFileSizeFormatterSPI.h; sourceTree = "<group>"; };
@@ -453,6 +454,7 @@
 				0C2DA1371F3BEB4900DBC317 /* NSURLDownloadSPI.h */,
 				0C2DA1381F3BEB4900DBC317 /* NSURLFileTypeMappingsSPI.h */,
 				C15CBB3223F34A1200300CC7 /* NSUserDefaultsSPI.h */,
+				E3037F4F2415ADF40031CA0F /* NSUTTypeRecordSPI.h */,
 				570AB8F820AF6E3D00B8BE87 /* NSXPCConnectionSPI.h */,
 				0C2DA1391F3BEB4900DBC317 /* PassKitSPI.h */,
 				0C2DA13A1F3BEB4900DBC317 /* pthreadSPI.h */,

Added: trunk/Source/WebCore/PAL/pal/spi/cocoa/NSUTTypeRecordSPI.h (0 => 258120)


--- trunk/Source/WebCore/PAL/pal/spi/cocoa/NSUTTypeRecordSPI.h	                        (rev 0)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/NSUTTypeRecordSPI.h	2020-03-08 23:52:40 UTC (rev 258120)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2020 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. ``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
+ * 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.
+ */
+
+#pragma once
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <CoreServices/LSPropertyListPriv.h>
+#import <CoreServices/UTTypeRecordPriv.h>
+
+#else
+
+__attribute__((visibility("default")))
+@interface LSRecord : NSObject <NSCopying, NSDiscardableContent>
+@end
+
+__attribute__((visibility("default")))
+@interface UTTypeRecord : LSRecord
++ (nullable instancetype)typeRecordWithTag:(NSString *)tag ofClass:(NSString *)tagClass conformingToIdentifier:(NSString *)conformsTo;
+@property (readonly) NSString *identifier;
+@end
+
+#endif

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (258119 => 258120)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-03-08 23:52:40 UTC (rev 258120)
@@ -4842,6 +4842,8 @@
 		E3BBC24723835526006EC39F /* CSSValueKey.h in Headers */ = {isa = PBXBuildFile; fileRef = E3BBC2452383551A006EC39F /* CSSValueKey.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E3C99A091DC3D41C00794AD3 /* DOMJITCheckDOM.h in Headers */ = {isa = PBXBuildFile; fileRef = E3C99A081DC3D41700794AD3 /* DOMJITCheckDOM.h */; };
 		E3C9AECB2113149900419B92 /* JSMicrotaskCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = E3C9AEC92113147400419B92 /* JSMicrotaskCallback.h */; };
+		E3CAAA6124155F8700CED2E2 /* UTTypeRecordSwizzler.h in Headers */ = {isa = PBXBuildFile; fileRef = E3CAAA5E24155EF200CED2E2 /* UTTypeRecordSwizzler.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		E3CAAA622415613200CED2E2 /* UTTypeRecordSwizzler.mm in Sources */ = {isa = PBXBuildFile; fileRef = E3CAAA6024155EF300CED2E2 /* UTTypeRecordSwizzler.mm */; };
 		E3E4E2A81E3B17100023BB8A /* ScriptElementCachedScriptFetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = E3E4E2A61E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E3FA38641D71812D00AA5950 /* PendingScriptClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E3FA38611D716E7600AA5950 /* PendingScriptClient.h */; };
 		E401C27517CE53EC00C41A35 /* ElementIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -15209,6 +15211,8 @@
 		E3BF19E722AF309F009C9926 /* SecurityPolicyViolationEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SecurityPolicyViolationEvent.cpp; sourceTree = "<group>"; };
 		E3C99A081DC3D41700794AD3 /* DOMJITCheckDOM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITCheckDOM.h; sourceTree = "<group>"; };
 		E3C9AEC92113147400419B92 /* JSMicrotaskCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMicrotaskCallback.h; sourceTree = "<group>"; };
+		E3CAAA5E24155EF200CED2E2 /* UTTypeRecordSwizzler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UTTypeRecordSwizzler.h; sourceTree = "<group>"; };
+		E3CAAA6024155EF300CED2E2 /* UTTypeRecordSwizzler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UTTypeRecordSwizzler.mm; sourceTree = "<group>"; };
 		E3D049931DADC04500718F3C /* NodeConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeConstants.h; sourceTree = "<group>"; };
 		E3E4E2A51E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptElementCachedScriptFetcher.cpp; sourceTree = "<group>"; };
 		E3E4E2A61E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptElementCachedScriptFetcher.h; sourceTree = "<group>"; };
@@ -23132,6 +23136,8 @@
 				310D71941B335C9D009C7B73 /* ThemeCocoa.h */,
 				310D71931B335C9D009C7B73 /* ThemeCocoa.mm */,
 				A3AF9D81203252EE006CAD06 /* UserAgentCocoa.mm */,
+				E3CAAA5E24155EF200CED2E2 /* UTTypeRecordSwizzler.h */,
+				E3CAAA6024155EF300CED2E2 /* UTTypeRecordSwizzler.mm */,
 				52B0D4BF1C57FD660077CE53 /* VideoFullscreenChangeObserver.h */,
 				52D5A1A41C57488900DE34A3 /* VideoFullscreenModel.h */,
 				52D5A1A51C57488900DE34A3 /* VideoFullscreenModelVideoElement.h */,
@@ -32949,6 +32955,7 @@
 				572B40362176A922000AD43E /* UserVerificationRequirement.h in Headers */,
 				55AF14E61EAAC59B0026EEAA /* UTIRegistry.h in Headers */,
 				1FAFBF1915A5FA7400083A20 /* UTIUtilities.h in Headers */,
+				E3CAAA6124155F8700CED2E2 /* UTTypeRecordSwizzler.h in Headers */,
 				83C45B8E1DC2B68A008871BA /* ValidationBubble.h in Headers */,
 				F5A154281279534D00D0B0C0 /* ValidationMessage.h in Headers */,
 				F513A3EA15FF4841001526DB /* ValidationMessageClient.h in Headers */,
@@ -34390,6 +34397,7 @@
 				7C3B79711908757B00B47A2D /* UserMessageHandler.cpp in Sources */,
 				7CE68344192143A800F4D928 /* UserMessageHandlerDescriptor.cpp in Sources */,
 				7C73FB07191EF417007DE061 /* UserMessageHandlersNamespace.cpp in Sources */,
+				E3CAAA622415613200CED2E2 /* UTTypeRecordSwizzler.mm in Sources */,
 				3FBC4AF3189881560046EE38 /* VideoFullscreenInterfaceAVKit.mm in Sources */,
 				52D5A18F1C54592300DE34A3 /* VideoLayerManagerObjC.mm in Sources */,
 				BE88E0DE1715D2A200658D98 /* VideoTrack.cpp in Sources */,

Added: trunk/Source/WebCore/platform/cocoa/UTTypeRecordSwizzler.h (0 => 258120)


--- trunk/Source/WebCore/platform/cocoa/UTTypeRecordSwizzler.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/UTTypeRecordSwizzler.h	2020-03-08 23:52:40 UTC (rev 258120)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#pragma once
+
+#if USE(UTTYPE_SWIZZLER)
+
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+struct UTTypeItem {
+    String tag;
+    String tagClass;
+    String identifier;
+    String uti;
+
+    template<class Encoder> void encode(Encoder&) const;
+    template<class Decoder> static Optional<UTTypeItem> decode(Decoder&);
+};
+
+WEBCORE_EXPORT void swizzleUTTypeRecord();
+
+WEBCORE_EXPORT const Vector<UTTypeItem>& createVectorOfUTTypeItem();
+WEBCORE_EXPORT void setVectorOfUTTypeItem(Vector<UTTypeItem>&&);
+
+template<class Encoder>
+void UTTypeItem::encode(Encoder& encoder) const
+{
+    encoder << tag;
+    encoder << tagClass;
+    encoder << identifier;
+    encoder << uti;
+}
+
+template<class Decoder>
+Optional<UTTypeItem> UTTypeItem::decode(Decoder& decoder)
+{
+    Optional<String> tag;
+    decoder >> tag;
+    if (!tag)
+        return WTF::nullopt;
+
+    Optional<String> tagClass;
+    decoder >> tagClass;
+    if (!tagClass)
+        return WTF::nullopt;
+
+    Optional<String> identifier;
+    decoder >> identifier;
+    if (!identifier)
+        return WTF::nullopt;
+
+    Optional<String> uti;
+    decoder >> uti;
+    if (!uti)
+        return WTF::nullopt;
+
+    return UTTypeItem { *tag, *tagClass, *identifier, *uti };
+}
+};
+
+#endif

Added: trunk/Source/WebCore/platform/cocoa/UTTypeRecordSwizzler.mm (0 => 258120)


--- trunk/Source/WebCore/platform/cocoa/UTTypeRecordSwizzler.mm	                        (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/UTTypeRecordSwizzler.mm	2020-03-08 23:52:40 UTC (rev 258120)
@@ -0,0 +1,116 @@
+/*
+* Copyright (C) 2020 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.
+*/
+
+#import "config.h"
+#import "UTTypeRecordSwizzler.h"
+
+#if USE(UTTYPE_SWIZZLER)
+
+#import <MobileCoreServices/MobileCoreServices.h>
+
+#import <WebCore/UTIUtilities.h>
+#import <pal/spi/cocoa/NSUTTypeRecordSPI.h>
+#import <wtf/NeverDestroyed.h>
+#import <wtf/ObjCRuntimeExtras.h>
+#import <wtf/SoftLinking.h>
+#import <wtf/Vector.h>
+#import <wtf/text/WTFString.h>
+
+__attribute__((visibility("default")))
+@interface WebUTTypeRecord : UTTypeRecord
+- (void)setIdentifier:(NSString *)i;
+@end
+
+@implementation WebUTTypeRecord {
+@package
+    NSString *_identifier;
+}
+@synthesize identifier=_identifier;
+- (void)setIdentifier:(NSString *)i
+{
+    _identifier = i;
+}
+@end
+
+namespace WebCore {
+
+static Vector<UTTypeItem>& vectorOfUTTypeRecords()
+{
+    static NeverDestroyed<Vector<UTTypeItem>> vector;
+    return vector;
+}
+
+static IMP typeRecordWithTagOriginal = nil;
+
+static UTTypeRecord *typeRecordWithTagOverride(id self, SEL selector, NSString *tag, NSString *tagClass, NSString *identifier)
+{
+    for (auto& r : vectorOfUTTypeRecords()) {
+        if (r.tag == String(tag) && r.tagClass == String(tagClass) && r.identifier == String(identifier)) {
+            WebUTTypeRecord *record = [WebUTTypeRecord alloc];
+            [record setIdentifier:r.uti];
+            return [record autorelease];
+        }
+    }
+    WTFLogAlways("UTI not found for tag: %s %s %s\n", String(tag).utf8().data(), String(tagClass).utf8().data(), String(identifier).utf8().data());
+    return wtfCallIMP<UTTypeRecord *>(typeRecordWithTagOriginal, self, selector, tag, tagClass, identifier);
+}
+
+const Vector<UTTypeItem>& createVectorOfUTTypeItem()
+{
+    static NeverDestroyed<Vector<UTTypeItem>> vector = [] {
+        Vector<UTTypeItem> v = std::initializer_list<UTTypeItem> {
+            { "dat"_s, "public.filename-extension"_s, static_cast<char*>(nullptr), static_cast<char*>(nullptr) },
+            { "mp4"_s, "public.filename-extension"_s, static_cast<char*>(nullptr), static_cast<char*>(nullptr) },
+            { "otf"_s, "public.filename-extension"_s, static_cast<char*>(nullptr), static_cast<char*>(nullptr) },
+        };
+        for (auto& r : v) {
+            auto uti = adoptCF(UTTypeCreatePreferredIdentifierForTag(r.tagClass.createCFString().get(), r.tag.createCFString().get(), r.identifier.isNull() ? nullptr : r.identifier.createCFString().get()));
+            r.uti = uti.get();
+        }
+        for (auto& it : createUTIFromMIMETypeMap()) {
+            UTTypeItem i = { it.key, "public.mime-type"_s, static_cast<char*>(nullptr), static_cast<char*>(nullptr) };
+            auto uti = adoptCF(UTTypeCreatePreferredIdentifierForTag(i.tagClass.createCFString().get(), i.tag.createCFString().get(), i.identifier.isNull() ? nullptr : i.identifier.createCFString().get()));
+            i.uti = uti.get();
+            v.append(WTFMove(i));
+        }
+        return v;
+    }();
+    return vector;
+}
+
+void setVectorOfUTTypeItem(Vector<UTTypeItem>&& vector)
+{
+    vectorOfUTTypeRecords() = WTFMove(vector);
+}
+
+void swizzleUTTypeRecord()
+{
+    Method typeRecordWithTagMethod = class_getClassMethod(objc_getClass("UTTypeRecord"), @selector(typeRecordWithTag: ofClass: conformingToIdentifier:));
+    typeRecordWithTagOriginal = method_setImplementation(typeRecordWithTagMethod, (IMP)typeRecordWithTagOverride);
+}
+
+};
+
+#endif

Modified: trunk/Source/WebCore/platform/network/mac/UTIUtilities.h (258119 => 258120)


--- trunk/Source/WebCore/platform/network/mac/UTIUtilities.h	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebCore/platform/network/mac/UTIUtilities.h	2020-03-08 23:52:40 UTC (rev 258120)
@@ -33,6 +33,7 @@
 String MIMETypeFromUTITree(const String&);
 WEBCORE_EXPORT String UTIFromMIMEType(const String&);
 bool isDeclaredUTI(const String&);
+WEBCORE_EXPORT String UTIFromTag(const String& tagClass, const String& tag, const String& conformingToUTI);
 
 WEBCORE_EXPORT void setUTIFromMIMETypeMap(HashMap<String, String>&&);
 WEBCORE_EXPORT const HashMap<String, String>& createUTIFromMIMETypeMap();

Modified: trunk/Source/WebCore/platform/network/mac/UTIUtilities.mm (258119 => 258120)


--- trunk/Source/WebCore/platform/network/mac/UTIUtilities.mm	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebCore/platform/network/mac/UTIUtilities.mm	2020-03-08 23:52:40 UTC (rev 258120)
@@ -161,6 +161,12 @@
     return UTTypeIsDeclared(UTI.createCFString().get());
 }
 
+String UTIFromTag(const String& tagClass, const String& tag, const String& conformingToUTI)
+{
+    auto u = adoptCF(UTTypeCreatePreferredIdentifierForTag(tagClass.createCFString().get(), tag.createCFString().get(), conformingToUTI.createCFString().get()));
+    return String(u.get());
+}
+
 static const Vector<String>& additionalMIMETypes()
 {
     static NeverDestroyed<Vector<String>> mimeTypes = std::initializer_list<String> {

Modified: trunk/Source/WebCore/testing/Internals.cpp (258119 => 258120)


--- trunk/Source/WebCore/testing/Internals.cpp	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebCore/testing/Internals.cpp	2020-03-08 23:52:40 UTC (rev 258120)
@@ -5501,6 +5501,11 @@
 {
     return emptyString();
 }
+
+String Internals::getUTIFromTag(const String& tagClass, const String& tag, const String& conformingToUTI)
+{
+    return emptyString();
+}
 #endif
 
 String Internals::mediaMIMETypeForExtension(const String& extension)

Modified: trunk/Source/WebCore/testing/Internals.h (258119 => 258120)


--- trunk/Source/WebCore/testing/Internals.h	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebCore/testing/Internals.h	2020-03-08 23:52:40 UTC (rev 258120)
@@ -943,6 +943,7 @@
     String mediaMIMETypeForExtension(const String& extension);
 
     String getUTIFromMIMEType(const String& mimeType);
+    String getUTIFromTag(const String& tagClass, const String& tag, const String& conformingToUTI);
 
     bool supportsPictureInPicture();
 

Modified: trunk/Source/WebCore/testing/Internals.idl (258119 => 258120)


--- trunk/Source/WebCore/testing/Internals.idl	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebCore/testing/Internals.idl	2020-03-08 23:52:40 UTC (rev 258120)
@@ -853,6 +853,7 @@
     DOMString mediaMIMETypeForExtension(DOMString extension);
 
     DOMString getUTIFromMIMEType(DOMString mimeType);
+    DOMString getUTIFromTag(DOMString tagClass, DOMString tag, DOMString conformingToUTI);
 
     boolean supportsPictureInPicture();
 };

Modified: trunk/Source/WebCore/testing/Internals.mm (258119 => 258120)


--- trunk/Source/WebCore/testing/Internals.mm	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebCore/testing/Internals.mm	2020-03-08 23:52:40 UTC (rev 258120)
@@ -106,4 +106,9 @@
     return UTIFromMIMEType(mimeType);
 }
 
+String Internals::getUTIFromTag(const String& tagClass, const String& tag, const String& conformingToUTI)
+{
+    return UTIFromTag(tagClass, tag, conformingToUTI);
 }
+
+}

Modified: trunk/Source/WebKit/ChangeLog (258119 => 258120)


--- trunk/Source/WebKit/ChangeLog	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebKit/ChangeLog	2020-03-08 23:52:40 UTC (rev 258120)
@@ -1,5 +1,26 @@
 2020-03-08  Per Arne Vollan  <pvol...@apple.com>
 
+        [iOS] Mapping to UTI from tag and tag class should be performed in the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=208783
+
+        Reviewed by Brent Fulgham.
+
+        Send mapping from tag/tag class to UTI from the UI process to the WebContent process as part of the WebProcess
+        creation parameters. Also, issue some mach-lookup extensions to the WebContent process if Accessibility is
+        enabled.
+
+        * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode const):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeWebProcess):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+
+2020-03-08  Per Arne Vollan  <pvol...@apple.com>
+
         REGRESSION (r258064): API tests intermittently crashing under WebKit::registerDefaultsOverride
         https://bugs.webkit.org/show_bug.cgi?id=208784
         <rdar://problem/60201631>

Modified: trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb (258119 => 258120)


--- trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb	2020-03-08 23:52:40 UTC (rev 258120)
@@ -848,7 +848,7 @@
 (allow mach-lookup
     (require-all
         (extension "com.apple.webkit.extension.mach")
-        (global-name "com.apple.iphone.axserver-systemwide" "com.apple.tccd" "com.apple.nehelper" "com.apple.nesessionmanager.content-filter" "com.apple.uikit.viewservice.com.apple.WebContentFilter.remoteUI" "com.apple.diagnosticd" "com.apple.lsd.open" "com.apple.mobileassetd" "com.apple.mobileassetd.v2" "com.apple.frontboard.systemappservices" "com.apple.iconservices" "com.apple.webinspector" "com.apple.PowerManagement.control" "com.apple.cfprefsd.daemon"
+        (global-name "com.apple.iphone.axserver-systemwide" "com.apple.tccd" "com.apple.nehelper" "com.apple.nesessionmanager.content-filter" "com.apple.uikit.viewservice.com.apple.WebContentFilter.remoteUI" "com.apple.diagnosticd" "com.apple.lsd.open" "com.apple.mobileassetd" "com.apple.mobileassetd.v2" "com.apple.frontboard.systemappservices" "com.apple.iconservices" "com.apple.webinspector" "com.apple.PowerManagement.control" "com.apple.cfprefsd.daemon" "com.apple.lsd.mapdb"
 
             ;;; FIXME(207716): The following should be removed when the GPU process is complete
             "com.apple.airplay.apsynccontroller.xpc" "com.apple.audio.AURemoteIOServer" "com.apple.audio.AudioComponentRegistrar"

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (258119 => 258120)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2020-03-08 23:52:40 UTC (rev 258120)
@@ -180,7 +180,10 @@
     encoder << cssValueToSystemColorMap;
     encoder << focusRingColor;
     encoder << localizedDeviceModel;
+#if USE(UTTYPE_SWIZZLER)
+    encoder << vectorOfUTTypeItem;
 #endif
+#endif
 
 #if PLATFORM(COCOA)
     // FIXME(207716): The following should be removed when the GPU process is complete.
@@ -493,7 +496,15 @@
     
     if (!decoder.decode(parameters.localizedDeviceModel))
         return false;
+    
+#if USE(UTTYPE_SWIZZLER)
+    Optional<Vector<UTTypeItem>> vectorOfUTTypeItem;
+    decoder >> vectorOfUTTypeItem;
+    if (!vectorOfUTTypeItem)
+        return false;
+    parameters.vectorOfUTTypeItem = WTFMove(*vectorOfUTTypeItem);
 #endif
+#endif
 
 #if PLATFORM(COCOA)
     // FIXME(207716): The following should be removed when the GPU process is complete.

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (258119 => 258120)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2020-03-08 23:52:40 UTC (rev 258120)
@@ -53,6 +53,7 @@
 
 #if PLATFORM(IOS_FAMILY)
 #include <WebCore/RenderThemeIOS.h>
+#include <WebCore/UTTypeRecordSwizzler.h>
 #endif
 
 namespace API {
@@ -223,7 +224,10 @@
     WebCore::RenderThemeIOS::CSSValueToSystemColorMap cssValueToSystemColorMap;
     WebCore::Color focusRingColor;
     String localizedDeviceModel;
+#if USE(UTTYPE_SWIZZLER)
+    Vector<WebCore::UTTypeItem> vectorOfUTTypeItem;
 #endif
+#endif
 
 #if PLATFORM(COCOA)
     SandboxExtension::HandleArray mediaExtensionHandles; // FIXME(207716): Remove when GPU process is complete.

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (258119 => 258120)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2020-03-08 23:52:40 UTC (rev 258120)
@@ -377,9 +377,10 @@
 #endif
 
 #if PLATFORM(IOS_FAMILY)
-    if (!WebCore::IOSApplication::isMobileSafari()) {
+    if (!WebCore::IOSApplication::isMobileSafari() || _AXSApplicationAccessibilityEnabled()) {
         static const char* services[] = {
             "com.apple.lsd.open",
+            "com.apple.lsd.mapdb",
             "com.apple.mobileassetd",
             "com.apple.iconservices",
             "com.apple.PowerManagement.control",
@@ -430,8 +431,10 @@
     parameters.cssValueToSystemColorMap = RenderThemeIOS::cssValueToSystemColorMap();
     parameters.focusRingColor = RenderTheme::singleton().focusRingColor(OptionSet<StyleColor::Options>());
     parameters.localizedDeviceModel = localizedDeviceModel();
+#if USE(UTTYPE_SWIZZLER)
+    parameters.vectorOfUTTypeItem = createVectorOfUTTypeItem();
 #endif
-
+#endif
     
     // Allow microphone access if either preference is set because WebRTC requires microphone access.
     bool needWebProcessExtensions = !m_defaultPageGroup->preferences().useGPUProcessForMedia()

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (258119 => 258120)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-03-08 23:52:40 UTC (rev 258120)
@@ -103,6 +103,7 @@
 #import "UserInterfaceIdiom.h"
 #import "WKAccessibilityWebPageObjectIOS.h"
 #import <UIKit/UIAccessibility.h>
+#import <WebCore/UTTypeRecordSwizzler.h>
 #import <pal/spi/ios/GraphicsServicesSPI.h>
 #endif
 
@@ -296,6 +297,11 @@
         _CFPrefsSetDirectModeEnabled(false);
     }
 #endif
+        
+#if USE(UTTYPE_SWIZZLER)
+    swizzleUTTypeRecord();
+    setVectorOfUTTypeItem(WTFMove(parameters.vectorOfUTTypeItem));
+#endif
 }
 
 void WebProcess::platformSetWebsiteDataStoreParameters(WebProcessDataStoreParameters&& parameters)

Modified: trunk/Tools/ChangeLog (258119 => 258120)


--- trunk/Tools/ChangeLog	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Tools/ChangeLog	2020-03-08 23:52:40 UTC (rev 258120)
@@ -1,3 +1,12 @@
+2020-03-08  Per Arne Vollan  <pvol...@apple.com>
+
+        [iOS] Mapping to UTI from tag and tag class should be performed in the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=208783
+
+        Reviewed by Brent Fulgham.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+
 2020-03-07  Ross Kirsling  <ross.kirsl...@sony.com>
 
         Replace the use of term "rollout" to "revert" in various tools

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (258119 => 258120)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2020-03-08 23:23:03 UTC (rev 258119)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2020-03-08 23:52:40 UTC (rev 258120)
@@ -1016,6 +1016,7 @@
 		E3A1E78221B25B7A008C6007 /* URL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3A1E78021B25B79008C6007 /* URL.cpp */; };
 		E3A1E78521B25B91008C6007 /* URLParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3A1E78421B25B91008C6007 /* URLParser.cpp */; };
 		E3C21A7C21B25CA2003B31A3 /* URLExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = E3C21A7B21B25CA2003B31A3 /* URLExtras.mm */; };
+		E3CAAA4C2415505100CED2E2 /* UTIFromTag.mm in Sources */ = {isa = PBXBuildFile; fileRef = E3CAAA4B2415505100CED2E2 /* UTIFromTag.mm */; };
 		E3DEA8111F0A589000CBC2E8 /* ThreadGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3DEA8101F0A588000CBC2E8 /* ThreadGroup.cpp */; };
 		E5036F78211BC25400BFDBE2 /* color-drop.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E5036F77211BC22800BFDBE2 /* color-drop.html */; };
 		ECA680CE1E68CC0900731D20 /* StringUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = ECA680CD1E68CC0900731D20 /* StringUtilities.mm */; };
@@ -2616,6 +2617,7 @@
 		E3A1E78021B25B79008C6007 /* URL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URL.cpp; sourceTree = "<group>"; };
 		E3A1E78421B25B91008C6007 /* URLParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLParser.cpp; sourceTree = "<group>"; };
 		E3C21A7B21B25CA2003B31A3 /* URLExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = URLExtras.mm; sourceTree = "<group>"; };
+		E3CAAA4B2415505100CED2E2 /* UTIFromTag.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = UTIFromTag.mm; sourceTree = "<group>"; };
 		E3DEA8101F0A588000CBC2E8 /* ThreadGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadGroup.cpp; sourceTree = "<group>"; };
 		E40019301ACE9B5C001B0A2A /* BloomFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BloomFilter.cpp; sourceTree = "<group>"; };
 		E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TypingStyleCrash.mm; sourceTree = "<group>"; };
@@ -2916,6 +2918,7 @@
 				E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */,
 				C15CBB3E23FB177A00300CC7 /* PreferenceChanges.mm */,
 				C194E31C2409DF43002939ED /* UTIFromMIMEType.mm */,
+				E3CAAA4B2415505100CED2E2 /* UTIFromTag.mm */,
 				0F139E751A423A5300F590F5 /* WeakObjCPtr.mm */,
 			);
 			name = cocoa;
@@ -5119,6 +5122,7 @@
 				7CCE7F181A411AE600447C4C /* UserMessage.cpp in Sources */,
 				2EB242B821D4140B0055C1C0 /* UseSelectionAsFindString.mm in Sources */,
 				C194E31D2409DF43002939ED /* UTIFromMIMEType.mm in Sources */,
+				E3CAAA4C2415505100CED2E2 /* UTIFromTag.mm in Sources */,
 				7C83E03A1D0A602700FEBCF3 /* UtilitiesCocoa.mm in Sources */,
 				7C83E0C61D0A654E00FEBCF3 /* VideoControlsManager.mm in Sources */,
 				CD3065E02165682E00E895DF /* VideoQualityDisplayCompositing.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit/UTIFromTag.mm (0 => 258120)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/UTIFromTag.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/UTIFromTag.mm	2020-03-08 23:52:40 UTC (rev 258120)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2020 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"
+
+#if WK_HAVE_C_SPI
+
+#if USE(UTTYPE_SWIZZLER)
+
+#import "PlatformUtilities.h"
+#import "TestWKWebView.h"
+#import <WebCore/UTIUtilities.h>
+#import <WebCore/UTTypeRecordSwizzler.h>
+
+TEST(WebKit, UTIFromTag)
+{
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
+    configuration.get().processPool = (WKProcessPool *)context.get();
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
+
+    for (auto& item : WebCore::createVectorOfUTTypeItem()) {
+        auto js = [NSString stringWithFormat:@"window.internals.getUTIFromTag(\"%s\", \"%s\", \"%s\")", item.tag.utf8().data(), item.tagClass.utf8().data(), , item.identifier.utf8().data()];
+
+        auto uti = [webView stringByEvaluatingJavaScript:js];
+
+        ASSERT_TRUE(WebCore::UTIFromTag(item.tagClass, item.tag, item.identifier) == String(uti));
+    }
+}
+#endif
+
+#endif // WK_HAVE_C_SPI
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to