Title: [256839] trunk
Revision
256839
Author
pvol...@apple.com
Date
2020-02-18 10:27:01 -0800 (Tue, 18 Feb 2020)

Log Message

Move [UIDevice currentDevice] calls to UI process
https://bugs.webkit.org/show_bug.cgi?id=204320

Reviewed by Darin Adler.

Source/WebCore:

Calling [UIDevice currentDevice] will cause the runningboard daemon to be accessed. Since this service will be removed from
the WebContent sandbox, these calls should be moved to the UI process. The function exernalDeviceDisplayNameForPlayer in
MediaPlayerPrivateAVFoundationObjC.mm is calling [[PAL::getUIDeviceClass() currentDevice] localizedModel], which should be
moved to the UI process.

API test: WebKit.LocalizedDeviceName

* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::exernalDeviceDisplayNameForPlayer):
* platform/ios/LocalizedDeviceModel.h: Added.
* platform/ios/LocalizedDeviceModel.mm: Added.
(WebCore::cachedLocalizedDeviceModel):
(WebCore::localizedDeviceModel):
(WebCore::setLocalizedDeviceModel):

Source/WebKit:

Get the localized device name in the UI process, and send it to the WebContent process as part of the
process creation parameters.

* 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):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit/LocalizedDeviceModel.mm: Added.
(TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (256838 => 256839)


--- trunk/Source/WebCore/ChangeLog	2020-02-18 18:19:13 UTC (rev 256838)
+++ trunk/Source/WebCore/ChangeLog	2020-02-18 18:27:01 UTC (rev 256839)
@@ -1,3 +1,27 @@
+2020-02-18  Per Arne Vollan  <pvol...@apple.com>
+
+        Move [UIDevice currentDevice] calls to UI process
+        https://bugs.webkit.org/show_bug.cgi?id=204320
+
+        Reviewed by Darin Adler.
+
+        Calling [UIDevice currentDevice] will cause the runningboard daemon to be accessed. Since this service will be removed from
+        the WebContent sandbox, these calls should be moved to the UI process. The function exernalDeviceDisplayNameForPlayer in
+        MediaPlayerPrivateAVFoundationObjC.mm is calling [[PAL::getUIDeviceClass() currentDevice] localizedModel], which should be
+        moved to the UI process.
+
+        API test: WebKit.LocalizedDeviceName
+
+        * SourcesCocoa.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::exernalDeviceDisplayNameForPlayer):
+        * platform/ios/LocalizedDeviceModel.h: Added.
+        * platform/ios/LocalizedDeviceModel.mm: Added.
+        (WebCore::cachedLocalizedDeviceModel):
+        (WebCore::localizedDeviceModel):
+        (WebCore::setLocalizedDeviceModel):
+
 2020-02-18  Youenn Fablet  <you...@apple.com>
 
         Use more ObjectIdentifier in WebRTC MDNS register

Modified: trunk/Source/WebCore/SourcesCocoa.txt (256838 => 256839)


--- trunk/Source/WebCore/SourcesCocoa.txt	2020-02-18 18:19:13 UTC (rev 256838)
+++ trunk/Source/WebCore/SourcesCocoa.txt	2020-02-18 18:27:01 UTC (rev 256839)
@@ -399,6 +399,7 @@
 platform/ios/LegacyTileLayer.mm
 platform/ios/LegacyTileLayerPool.mm
 platform/ios/LocalCurrentTraitCollection.mm
+platform/ios/LocalizedDeviceModel.mm
 platform/ios/LowPowerModeNotifierIOS.mm
 platform/ios/PasteboardIOS.mm
 platform/ios/PlatformEventFactoryIOS.mm @no-unify

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (256838 => 256839)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-02-18 18:19:13 UTC (rev 256838)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-02-18 18:27:01 UTC (rev 256839)
@@ -4796,6 +4796,7 @@
 		E323CFFA1E5AF6AF00F0B4A0 /* JSDOMConvertPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = E323CFF91E5AF6A500F0B4A0 /* JSDOMConvertPromise.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E3565B7B1DC2D6C900217DBD /* JSEventCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = E34EE49F1DC2D57500EAA9D3 /* JSEventCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E35802B61DC8435D00A9773C /* DOMJITIDLTypeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = E35802B51DC8435800A9773C /* DOMJITIDLTypeFilter.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		E35B907F23F60A50000011FF /* LocalizedDeviceModel.h in Headers */ = {isa = PBXBuildFile; fileRef = E35B907C23F60677000011FF /* LocalizedDeviceModel.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E377FE4D1DADE16500CDD025 /* NodeConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = E3D049931DADC04500718F3C /* NodeConstants.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E37C86501EB63E3F0087C6CA /* JSDOMPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = E37C864F1EB63E2D0087C6CA /* JSDOMPromise.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E39628BF2395728F00658ECD /* DeviceOrientationUpdateProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = E39628BD2395728E00658ECD /* DeviceOrientationUpdateProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -15115,6 +15116,8 @@
 		E334825E1DC93AA0009C9544 /* DOMJITAbstractHeapRepository.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DOMJITAbstractHeapRepository.h; path = DerivedSources/WebCore/DOMJITAbstractHeapRepository.h; sourceTree = BUILT_PRODUCTS_DIR; };
 		E34EE49F1DC2D57500EAA9D3 /* JSEventCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEventCustom.h; sourceTree = "<group>"; };
 		E35802B51DC8435800A9773C /* DOMJITIDLTypeFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITIDLTypeFilter.h; sourceTree = "<group>"; };
+		E35B907C23F60677000011FF /* LocalizedDeviceModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalizedDeviceModel.h; sourceTree = "<group>"; };
+		E35B907E23F60677000011FF /* LocalizedDeviceModel.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalizedDeviceModel.mm; sourceTree = "<group>"; };
 		E37C864F1EB63E2D0087C6CA /* JSDOMPromise.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMPromise.h; sourceTree = "<group>"; };
 		E38838941BAD145F00D62EE3 /* ScriptModuleLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptModuleLoader.cpp; sourceTree = "<group>"; };
 		E38838951BAD145F00D62EE3 /* ScriptModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptModuleLoader.h; sourceTree = "<group>"; };
@@ -22871,6 +22874,8 @@
 				E4E39AFC1330EFC5003AB274 /* LegacyTileLayerPool.mm */,
 				1C43DE6822AB4B8A001527D9 /* LocalCurrentTraitCollection.h */,
 				1C43DE6A22AB4B8A001527D9 /* LocalCurrentTraitCollection.mm */,
+				E35B907C23F60677000011FF /* LocalizedDeviceModel.h */,
+				E35B907E23F60677000011FF /* LocalizedDeviceModel.mm */,
 				46EFAF0D1E5FB9C200E7F34B /* LowPowerModeNotifierIOS.mm */,
 				E39628C02395743000658ECD /* MotionManagerClient.h */,
 				E45390190EAFCACA003695C8 /* PasteboardIOS.mm */,
@@ -31351,6 +31356,7 @@
 				F5973DE015CFB2030027F804 /* LocaleCocoa.h in Headers */,
 				7633A72613D8B33A008501B6 /* LocaleToScriptMapping.h in Headers */,
 				A516E8B7136E04DB0076C3C0 /* LocalizedDateCache.h in Headers */,
+				E35B907F23F60A50000011FF /* LocalizedDeviceModel.h in Headers */,
 				935207BE09BD410A00F2038D /* LocalizedStrings.h in Headers */,
 				41FCD6BB23CE027700C62567 /* LocalSampleBufferDisplayLayer.h in Headers */,
 				BCE1C41B0D982980003B02F2 /* Location.h in Headers */,

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (256838 => 256839)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2020-02-18 18:19:13 UTC (rev 256838)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2020-02-18 18:27:01 UTC (rev 256839)
@@ -47,6 +47,7 @@
 #import "InbandMetadataTextTrackPrivateAVF.h"
 #import "InbandTextTrackPrivateAVFObjC.h"
 #import "InbandTextTrackPrivateLegacyAVFObjC.h"
+#import "LocalizedDeviceModel.h"
 #import "Logging.h"
 #import "MediaPlaybackTargetCocoa.h"
 #import "MediaPlaybackTargetMock.h"
@@ -2718,7 +2719,7 @@
             break;
 
         // The route is a speaker or HDMI out, override the name to be the localized device model.
-        NSString *localizedDeviceModel = [[PAL::getUIDeviceClass() currentDevice] localizedModel];
+        NSString *localizedDeviceModelName = localizedDeviceModel();
 
         // In cases where a route with that name already exists, prefix the name with the model.
         BOOL includeLocalizedDeviceModelName = NO;
@@ -2733,9 +2734,9 @@
         }
 
         if (includeLocalizedDeviceModelName)
-            displayName =  [NSString stringWithFormat:@"%@ %@", localizedDeviceModel, displayName];
+            displayName = [NSString stringWithFormat:@"%@ %@", localizedDeviceModelName, displayName];
         else
-            displayName = localizedDeviceModel;
+            displayName = localizedDeviceModelName;
 
         break;
     }

Added: trunk/Source/WebCore/platform/ios/LocalizedDeviceModel.h (0 => 256839)


--- trunk/Source/WebCore/platform/ios/LocalizedDeviceModel.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/ios/LocalizedDeviceModel.h	2020-02-18 18:27:01 UTC (rev 256839)
@@ -0,0 +1,39 @@
+/*
+* 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 PLATFORM(IOS_FAMILY)
+
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+WEBCORE_EXPORT String localizedDeviceModel();
+WEBCORE_EXPORT void setLocalizedDeviceModel(const String&);
+
+}
+
+#endif

Added: trunk/Source/WebCore/platform/ios/LocalizedDeviceModel.mm (0 => 256839)


--- trunk/Source/WebCore/platform/ios/LocalizedDeviceModel.mm	                        (rev 0)
+++ trunk/Source/WebCore/platform/ios/LocalizedDeviceModel.mm	2020-02-18 18:27:01 UTC (rev 256839)
@@ -0,0 +1,57 @@
+/*
+* 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"
+#include "LocalizedDeviceModel.h"
+
+#if PLATFORM(IOS_FAMILY)
+
+#import <pal/ios/UIKitSoftLink.h>
+#import <wtf/Optional.h>
+
+namespace WebCore {
+
+static Optional<String>& cachedLocalizedDeviceModel()
+{
+    static NeverDestroyed<Optional<String>> deviceModel;
+    return deviceModel;
+}
+
+String localizedDeviceModel()
+{
+    auto& deviceModel = cachedLocalizedDeviceModel();
+    if (!deviceModel)
+        deviceModel = String([[PAL::getUIDeviceClass() currentDevice] localizedModel]);
+    return *deviceModel;
+}
+
+void setLocalizedDeviceModel(const String& deviceModel)
+{
+    cachedLocalizedDeviceModel() = deviceModel;
+}
+
+}
+
+#endif

Modified: trunk/Source/WebKit/ChangeLog (256838 => 256839)


--- trunk/Source/WebKit/ChangeLog	2020-02-18 18:19:13 UTC (rev 256838)
+++ trunk/Source/WebKit/ChangeLog	2020-02-18 18:27:01 UTC (rev 256839)
@@ -1,3 +1,22 @@
+2020-02-18  Per Arne Vollan  <pvol...@apple.com>
+
+        Move [UIDevice currentDevice] calls to UI process
+        https://bugs.webkit.org/show_bug.cgi?id=204320
+
+        Reviewed by Darin Adler.
+
+        Get the localized device name in the UI process, and send it to the WebContent process as part of the
+        process creation parameters.
+
+        * 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-02-18  Youenn Fablet  <you...@apple.com>
 
         Use more ObjectIdentifier in WebRTC MDNS register

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (256838 => 256839)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2020-02-18 18:19:13 UTC (rev 256838)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2020-02-18 18:27:01 UTC (rev 256839)
@@ -175,6 +175,7 @@
     encoder << supportsPictureInPicture;
     encoder << cssValueToSystemColorMap;
     encoder << focusRingColor;
+    encoder << localizedDeviceModel;
 #endif
 
 #if PLATFORM(COCOA)
@@ -474,6 +475,9 @@
     if (!focusRingColor)
         return false;
     parameters.focusRingColor = WTFMove(*focusRingColor);
+    
+    if (!decoder.decode(parameters.localizedDeviceModel))
+        return false;
 #endif
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (256838 => 256839)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2020-02-18 18:19:13 UTC (rev 256838)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2020-02-18 18:27:01 UTC (rev 256839)
@@ -217,6 +217,7 @@
     bool supportsPictureInPicture { false };
     WebCore::RenderThemeIOS::CSSValueToSystemColorMap cssValueToSystemColorMap;
     WebCore::Color focusRingColor;
+    String localizedDeviceModel;
 #endif
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (256838 => 256839)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2020-02-18 18:19:13 UTC (rev 256838)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2020-02-18 18:27:01 UTC (rev 256839)
@@ -48,6 +48,7 @@
 #import "WebProcessMessages.h"
 #import "WindowServerConnection.h"
 #import <WebCore/Color.h>
+#import <WebCore/LocalizedDeviceModel.h>
 #import <WebCore/MIMETypeRegistry.h>
 #import <WebCore/NetworkStorageSession.h>
 #import <WebCore/NotImplemented.h>
@@ -408,6 +409,7 @@
     parameters.supportsPictureInPicture = supportsPictureInPicture();
     parameters.cssValueToSystemColorMap = RenderThemeIOS::cssValueToSystemColorMap();
     parameters.focusRingColor = RenderTheme::singleton().focusRingColor(OptionSet<StyleColor::Options>());
+    parameters.localizedDeviceModel = localizedDeviceModel();
 #endif
 
     

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (256838 => 256839)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-02-18 18:19:13 UTC (rev 256838)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-02-18 18:27:01 UTC (rev 256839)
@@ -57,6 +57,7 @@
 #import <WebCore/FontCascade.h>
 #import <WebCore/HistoryController.h>
 #import <WebCore/HistoryItem.h>
+#import <WebCore/LocalizedDeviceModel.h>
 #import <WebCore/LocalizedStrings.h>
 #import <WebCore/LogInitialization.h>
 #import <WebCore/MIMETypeRegistry.h>
@@ -202,6 +203,7 @@
 
 #if PLATFORM(IOS_FAMILY)
     setCurrentUserInterfaceIdiomIsPad(parameters.currentUserInterfaceIdiomIsPad);
+    setLocalizedDeviceModel(parameters.localizedDeviceModel);
     setSupportsPictureInPicture(parameters.supportsPictureInPicture);
 #endif
 

Modified: trunk/Tools/ChangeLog (256838 => 256839)


--- trunk/Tools/ChangeLog	2020-02-18 18:19:13 UTC (rev 256838)
+++ trunk/Tools/ChangeLog	2020-02-18 18:27:01 UTC (rev 256839)
@@ -1,3 +1,14 @@
+2020-02-18  Per Arne Vollan  <pvol...@apple.com>
+
+        Move [UIDevice currentDevice] calls to UI process
+        https://bugs.webkit.org/show_bug.cgi?id=204320
+
+        Reviewed by Darin Adler.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit/LocalizedDeviceModel.mm: Added.
+        (TEST):
+
 2020-02-18  Simon Fraser  <simon.fra...@apple.com>
 
         Move from "layer flush" terminology to "rendering update"

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (256838 => 256839)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2020-02-18 18:19:13 UTC (rev 256838)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2020-02-18 18:27:01 UTC (rev 256839)
@@ -993,6 +993,7 @@
 		E324A6F02041C82000A76593 /* UniqueArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E398BC0F2041C76300387136 /* UniqueArray.cpp */; };
 		E325C90723E3870200BC7D3B /* PictureInPictureSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */; };
 		E32B549222810AC4008AD702 /* Packed.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E32B549122810AC0008AD702 /* Packed.cpp */; };
+		E35B908223F60DD0000011FF /* LocalizedDeviceModel.mm in Sources */ = {isa = PBXBuildFile; fileRef = E35B908123F60DD0000011FF /* LocalizedDeviceModel.mm */; };
 		E35FC7B222B82A7300F32F98 /* JSLockTakesWebThreadLock.mm in Sources */ = {isa = PBXBuildFile; fileRef = E35FC7B122B82A6D00F32F98 /* JSLockTakesWebThreadLock.mm */; };
 		E373D7911F2CF35200C6FAAF /* Signals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3953F951F2CF32100A76A2E /* Signals.cpp */; };
 		E38A0D351FD50CC300E98C8B /* Threading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38A0D341FD50CBC00E98C8B /* Threading.cpp */; };
@@ -2570,6 +2571,7 @@
 		E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = StopLoadingFromDidReceiveResponse.html; sourceTree = "<group>"; };
 		E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PictureInPictureSupport.mm; sourceTree = "<group>"; };
 		E32B549122810AC0008AD702 /* Packed.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Packed.cpp; sourceTree = "<group>"; };
+		E35B908123F60DD0000011FF /* LocalizedDeviceModel.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalizedDeviceModel.mm; sourceTree = "<group>"; };
 		E35FC7B122B82A6D00F32F98 /* JSLockTakesWebThreadLock.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = JSLockTakesWebThreadLock.mm; sourceTree = "<group>"; };
 		E388887020C9098100E632BC /* WorkerPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerPool.cpp; sourceTree = "<group>"; };
 		E38A0D341FD50CBC00E98C8B /* Threading.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Threading.cpp; sourceTree = "<group>"; };
@@ -2875,6 +2877,7 @@
 				C15CBB2F23F1FF1A00300CC7 /* BacklightLevelNotification.mm */,
 				C1692DC923D10DAE006E88F7 /* Battery.mm */,
 				E394AE6E23F2303E005B4936 /* GrantAccessToMobileAssets.mm */,
+				E35B908123F60DD0000011FF /* LocalizedDeviceModel.mm */,
 				C145CC0B23DA5A0F003A5EEB /* MimeTypes.mm */,
 				E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */,
 				C15CBB3E23FB177A00300CC7 /* PreferenceChanges.mm */,
@@ -4859,6 +4862,7 @@
 				7C83E0C01D0A652700FEBCF3 /* LoadInvalidURLRequest.mm in Sources */,
 				7CCE7F001A411AE600447C4C /* LoadPageOnCrash.cpp in Sources */,
 				5778D05622110A2600899E3B /* LoadWebArchive.mm in Sources */,
+				E35B908223F60DD0000011FF /* LocalizedDeviceModel.mm in Sources */,
 				51E6A8941D2F1C0A00C004B6 /* LocalStorageClear.mm in Sources */,
 				CA38459620AE17A900990D3B /* LocalStorageDatabaseTracker.mm in Sources */,
 				46C519DA1D355AB200DAA51A /* LocalStorageNullEntries.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit/LocalizedDeviceModel.mm (0 => 256839)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/LocalizedDeviceModel.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/LocalizedDeviceModel.mm	2020-02-18 18:27:01 UTC (rev 256839)
@@ -0,0 +1,51 @@
+/*
+ * 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 PLATFORM(IOS_FAMILY)
+
+#if WK_HAVE_C_SPI
+
+#import "PlatformUtilities.h"
+#import "TestWKWebView.h"
+#import <WebCore/LocalizedDeviceModel.h>
+
+TEST(WebKit, LocalizedDeviceModel)
+{
+    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]);
+
+    auto localizedDeviceModel = [&] {
+        return [webView stringByEvaluatingJavaScript:@"window.internals.localizedDeviceModel()"].boolValue;
+    };
+
+    ASSERT_TRUE(localizedDeviceModel() == WebCore::localizedDeviceModel());
+}
+
+#endif // WK_HAVE_C_SPI
+#endif // PLATFORM(IOS_FAMILY)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to