Diff
Modified: trunk/Source/WebCore/ChangeLog (254994 => 254995)
--- trunk/Source/WebCore/ChangeLog 2020-01-23 19:56:38 UTC (rev 254994)
+++ trunk/Source/WebCore/ChangeLog 2020-01-23 20:10:47 UTC (rev 254995)
@@ -1,3 +1,26 @@
+2020-01-23 Per Arne Vollan <[email protected]>
+
+ [Cocoa] Broker access to the PowerManagement API
+ https://bugs.webkit.org/show_bug.cgi?id=206373
+
+ Reviewed by Darin Adler.
+
+ Code to determine if device has battery should be executed in the UI process.
+
+ API test: WebKit.SystemHasBattery
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/cocoa/SystemBattery.h: Added.
+ * platform/cocoa/SystemBattery.mm: Added.
+ (WebCore::setSystemHasBattery):
+ (WebCore::systemHasBattery):
+ * platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm:
+ (WebCore::systemHasBattery): Deleted.
+ * testing/Internals.cpp:
+ (WebCore::Internals::systemHasBattery const):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
2020-01-23 Antoine Quint <[email protected]>
[Web Animations] Make AnimationList ref-counted
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (254994 => 254995)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-01-23 19:56:38 UTC (rev 254994)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-01-23 20:10:47 UTC (rev 254995)
@@ -3980,6 +3980,8 @@
C105DA640F3AA6B8001DD44F /* TextEncodingDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */; };
C11A9ECE21403A5C00CFB20A /* SwitchingGPUClient.h in Headers */ = {isa = PBXBuildFile; fileRef = C11A9ECD21403A5C00CFB20A /* SwitchingGPUClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
C14938072234551A000CD707 /* SpeechSynthesisClient.h in Headers */ = {isa = PBXBuildFile; fileRef = C149380522342719000CD707 /* SpeechSynthesisClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ C1692DD223D23ABD006E88F7 /* SystemBattery.mm in Sources */ = {isa = PBXBuildFile; fileRef = C1692DD123D23ABD006E88F7 /* SystemBattery.mm */; };
+ C1692DD523D23E08006E88F7 /* SystemBattery.h in Headers */ = {isa = PBXBuildFile; fileRef = C1692DD423D23AE0006E88F7 /* SystemBattery.h */; settings = {ATTRIBUTES = (Private, ); }; };
C1E1D236203DF15400584665 /* ScreenProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = C1E1D235203DF15400584665 /* ScreenProperties.h */; settings = {ATTRIBUTES = (Private, ); }; };
C2015C0A1BE6FEB200822389 /* FontVariantBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = C2015C091BE6FE2C00822389 /* FontVariantBuilder.h */; };
C21DF2EA1D9E4E9900F5B24C /* CSSFontVariationValue.h in Headers */ = {isa = PBXBuildFile; fileRef = C21DF2E81D9E4E9900F5B24C /* CSSFontVariationValue.h */; };
@@ -13521,6 +13523,8 @@
C11A9ECD21403A5C00CFB20A /* SwitchingGPUClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwitchingGPUClient.h; sourceTree = "<group>"; };
C11A9ED22140578B00CFB20A /* SwitchingGPUClient.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SwitchingGPUClient.cpp; sourceTree = "<group>"; };
C149380522342719000CD707 /* SpeechSynthesisClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SpeechSynthesisClient.h; sourceTree = "<group>"; };
+ C1692DD123D23ABD006E88F7 /* SystemBattery.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemBattery.mm; sourceTree = "<group>"; };
+ C1692DD423D23AE0006E88F7 /* SystemBattery.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SystemBattery.h; sourceTree = "<group>"; };
C1E1D235203DF15400584665 /* ScreenProperties.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScreenProperties.h; sourceTree = "<group>"; };
C2015C091BE6FE2C00822389 /* FontVariantBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontVariantBuilder.h; sourceTree = "<group>"; };
C20F4F6421DFBE5C0070C45A /* WHLSLTypeReference.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLTypeReference.cpp; sourceTree = "<group>"; };
@@ -23150,6 +23154,8 @@
0E7058F31BC5CCD70045A507 /* SearchPopupMenuCocoa.h */,
0E7058ED1BC5BC190045A507 /* SearchPopupMenuCocoa.mm */,
1A4A95510B4EDCFF002D8C3C /* SharedBufferCocoa.mm */,
+ C1692DD423D23AE0006E88F7 /* SystemBattery.h */,
+ C1692DD123D23ABD006E88F7 /* SystemBattery.mm */,
5D5975B119635F1100D00878 /* SystemVersion.h */,
5D5975B219635F1100D00878 /* SystemVersion.mm */,
7CC564B918BAC720001B9652 /* TelephoneNumberDetectorCocoa.cpp */,
@@ -32769,6 +32775,7 @@
5185430B1FB6784500478F95 /* SWServerToContextConnection.h in Headers */,
517A53461F50C17F00DCDC0A /* SWServerWorker.h in Headers */,
E180811716FCF9CB00B80D07 /* SynchronousLoaderClient.h in Headers */,
+ C1692DD523D23E08006E88F7 /* SystemBattery.h in Headers */,
E4E8B4EC216B79E500B8834D /* SystemFontDatabaseCoreText.h in Headers */,
0F03C0741884695E00A5F8CA /* SystemMemory.h in Headers */,
5D5975B319635F1100D00878 /* SystemVersion.h in Headers */,
@@ -33778,6 +33785,7 @@
538F10A81F9022A4005102CE /* SoftLinkLibxslt.cpp in Sources */,
CDC8B5AA18047FF10016E685 /* SourceBufferPrivateAVFObjC.mm in Sources */,
A833C7CA0A2CF06B00D57664 /* SVGNames.cpp in Sources */,
+ C1692DD223D23ABD006E88F7 /* SystemBattery.mm in Sources */,
6E72F54F229DCD1300B3E151 /* TemporaryANGLESetting.cpp in Sources */,
9759E93F14EF1CF80026A2DD /* TextTrack.cpp in Sources */,
9759E94214EF1CF80026A2DD /* TextTrackCue.cpp in Sources */,
Added: trunk/Source/WebCore/platform/cocoa/SystemBattery.h (0 => 254995)
--- trunk/Source/WebCore/platform/cocoa/SystemBattery.h (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/SystemBattery.h 2020-01-23 20:10:47 UTC (rev 254995)
@@ -0,0 +1,33 @@
+/*
+* 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
+
+namespace WebCore {
+
+WEBCORE_EXPORT void setSystemHasBattery(bool);
+WEBCORE_EXPORT bool systemHasBattery();
+
+}
Added: trunk/Source/WebCore/platform/cocoa/SystemBattery.mm (0 => 254995)
--- trunk/Source/WebCore/platform/cocoa/SystemBattery.mm (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/SystemBattery.mm 2020-01-23 20:10:47 UTC (rev 254995)
@@ -0,0 +1,60 @@
+/*
+ * 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 "SystemBattery.h"
+
+#import <pal/spi/cocoa/IOPSLibSPI.h>
+
+namespace WebCore {
+
+static Optional<bool> hasBattery;
+
+void setSystemHasBattery(bool battery)
+{
+ hasBattery = battery;
+}
+
+bool systemHasBattery()
+{
+ if (hasBattery.hasValue())
+ return *hasBattery;
+
+ RetainPtr<CFTypeRef> powerSourcesInfo = adoptCF(IOPSCopyPowerSourcesInfo());
+ if (!powerSourcesInfo)
+ return false;
+ RetainPtr<CFArrayRef> powerSourcesList = adoptCF(IOPSCopyPowerSourcesList(powerSourcesInfo.get()));
+ if (!powerSourcesList)
+ return false;
+ for (CFIndex i = 0, count = CFArrayGetCount(powerSourcesList.get()); i < count; ++i) {
+ CFDictionaryRef description = IOPSGetPowerSourceDescription(powerSourcesInfo.get(), CFArrayGetValueAtIndex(powerSourcesList.get(), i));
+ CFTypeRef value = CFDictionaryGetValue(description, CFSTR(kIOPSTypeKey));
+ if (!value || CFEqual(value, CFSTR(kIOPSInternalBatteryType)))
+ return true;
+ }
+ return false;
+}
+
+}
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm (254994 => 254995)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm 2020-01-23 19:56:38 UTC (rev 254994)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm 2020-01-23 20:10:47 UTC (rev 254995)
@@ -29,31 +29,14 @@
#if ENABLE(VIDEO) && USE(AVFOUNDATION)
#import "FourCC.h"
+#import "SystemBattery.h"
+#import "VideoToolboxSoftLink.h"
#import <AVFoundation/AVAssetTrack.h>
-#import <pal/spi/cocoa/IOPSLibSPI.h>
#import <pal/cf/CoreMediaSoftLink.h>
-#import "VideoToolboxSoftLink.h"
namespace WebCore {
-static bool systemHasBattery()
-{
- RetainPtr<CFTypeRef> powerSourcesInfo = adoptCF(IOPSCopyPowerSourcesInfo());
- if (!powerSourcesInfo)
- return false;
- RetainPtr<CFArrayRef> powerSourcesList = adoptCF(IOPSCopyPowerSourcesList(powerSourcesInfo.get()));
- if (!powerSourcesList)
- return false;
- for (CFIndex i = 0, count = CFArrayGetCount(powerSourcesList.get()); i < count; ++i) {
- CFDictionaryRef description = IOPSGetPowerSourceDescription(powerSourcesInfo.get(), CFArrayGetValueAtIndex(powerSourcesList.get(), i));
- CFTypeRef value = CFDictionaryGetValue(description, CFSTR(kIOPSTypeKey));
- if (!value || CFEqual(value, CFSTR(kIOPSInternalBatteryType)))
- return true;
- }
- return false;
-}
-
static Vector<FourCC> contentTypesToCodecs(const Vector<ContentType>& contentTypes)
{
Vector<FourCC> codecs;
Modified: trunk/Source/WebCore/testing/Internals.cpp (254994 => 254995)
--- trunk/Source/WebCore/testing/Internals.cpp 2020-01-23 19:56:38 UTC (rev 254994)
+++ trunk/Source/WebCore/testing/Internals.cpp 2020-01-23 20:10:47 UTC (rev 254995)
@@ -309,7 +309,8 @@
#endif
#if PLATFORM(COCOA)
-#import <wtf/spi/darwin/SandboxSPI.h>
+#include "SystemBattery.h"
+#include <wtf/spi/darwin/SandboxSPI.h>
#endif
using JSC::CallData;
@@ -5426,4 +5427,13 @@
return RenderTheme::singleton().systemColor(id, options).cssText();
}
+bool Internals::systemHasBattery() const
+{
+#if PLATFORM(COCOA)
+ return WebCore::systemHasBattery();
+#else
+ return false;
+#endif
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/testing/Internals.h (254994 => 254995)
--- trunk/Source/WebCore/testing/Internals.h 2020-01-23 19:56:38 UTC (rev 254994)
+++ trunk/Source/WebCore/testing/Internals.h 2020-01-23 20:10:47 UTC (rev 254995)
@@ -928,6 +928,8 @@
String systemColorForCSSValue(const String& cssValue, bool useDarkModeAppearance, bool useElevatedUserInterfaceLevel);
+ bool systemHasBattery() const;
+
private:
explicit Internals(Document&);
Document* contextDocument() const;
Modified: trunk/Source/WebCore/testing/Internals.idl (254994 => 254995)
--- trunk/Source/WebCore/testing/Internals.idl 2020-01-23 19:56:38 UTC (rev 254994)
+++ trunk/Source/WebCore/testing/Internals.idl 2020-01-23 20:10:47 UTC (rev 254995)
@@ -835,4 +835,6 @@
boolean hasSandboxMachLookupAccessToXPCServiceName(DOMString process, DOMString service);
DOMString systemColorForCSSValue(DOMString cssValue, boolean useDarkModeAppearance, boolean useElevatedUserInterfaceLevel);
+
+ boolean systemHasBattery();
};
Modified: trunk/Source/WebKit/ChangeLog (254994 => 254995)
--- trunk/Source/WebKit/ChangeLog 2020-01-23 19:56:38 UTC (rev 254994)
+++ trunk/Source/WebKit/ChangeLog 2020-01-23 20:10:47 UTC (rev 254995)
@@ -1,3 +1,23 @@
+2020-01-23 Per Arne Vollan <[email protected]>
+
+ [Cocoa] Broker access to the PowerManagement API
+ https://bugs.webkit.org/show_bug.cgi?id=206373
+ <rdar://problem/34722450>
+
+ Reviewed by Darin Adler.
+
+ Send flag indicating whether device has battery to the WebContent process as part of the
+ WebProcess 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-01-23 Ryan Haddad <[email protected]>
Unreviewed, rolling out r254990.
Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (254994 => 254995)
--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp 2020-01-23 19:56:38 UTC (rev 254994)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp 2020-01-23 20:10:47 UTC (rev 254995)
@@ -166,6 +166,7 @@
#if PLATFORM(COCOA)
encoder << neHelperExtensionHandle;
encoder << neSessionManagerExtensionHandle;
+ encoder << systemHasBattery;
#endif
#if PLATFORM(IOS_FAMILY)
@@ -433,6 +434,12 @@
if (!neSessionManagerExtensionHandle)
return false;
parameters.neSessionManagerExtensionHandle = WTFMove(*neSessionManagerExtensionHandle);
+
+ Optional<bool> systemHasBattery;
+ decoder >> systemHasBattery;
+ if (!systemHasBattery)
+ return false;
+ parameters.systemHasBattery = WTFMove(*systemHasBattery);
#endif
#if PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (254994 => 254995)
--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h 2020-01-23 19:56:38 UTC (rev 254994)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h 2020-01-23 20:10:47 UTC (rev 254995)
@@ -208,6 +208,7 @@
#if PLATFORM(COCOA)
Optional<SandboxExtension::Handle> neHelperExtensionHandle;
Optional<SandboxExtension::Handle> neSessionManagerExtensionHandle;
+ bool systemHasBattery { false };
#endif
#if PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (254994 => 254995)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2020-01-23 19:56:38 UTC (rev 254994)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2020-01-23 20:10:47 UTC (rev 254995)
@@ -81,6 +81,7 @@
#endif
#if PLATFORM(COCOA)
+#import <WebCore/SystemBattery.h>
#import <pal/spi/cocoa/NEFilterSourceSPI.h>
SOFT_LINK_FRAMEWORK_OPTIONAL(NetworkExtension);
@@ -343,6 +344,7 @@
#endif
parameters.neSessionManagerExtensionHandle = WTFMove(handle);
}
+ parameters.systemHasBattery = systemHasBattery();
#endif
#if PLATFORM(IOS)
Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (254994 => 254995)
--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2020-01-23 19:56:38 UTC (rev 254994)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2020-01-23 20:10:47 UTC (rev 254995)
@@ -121,6 +121,7 @@
#if PLATFORM(COCOA)
#import <WebCore/NetworkExtensionContentFilter.h>
+#import <WebCore/SystemBattery.h>
#endif
#if HAVE(CSCHECKFIXDISABLE)
@@ -258,6 +259,7 @@
if (parameters.neSessionManagerExtensionHandle)
SandboxExtension::consumePermanently(*parameters.neSessionManagerExtensionHandle);
NetworkExtensionContentFilter::setHasConsumedSandboxExtensions(parameters.neHelperExtensionHandle.hasValue() && parameters.neSessionManagerExtensionHandle.hasValue());
+ setSystemHasBattery(parameters.systemHasBattery);
#endif
#if PLATFORM(IOS_FAMILY)
Modified: trunk/Tools/ChangeLog (254994 => 254995)
--- trunk/Tools/ChangeLog 2020-01-23 19:56:38 UTC (rev 254994)
+++ trunk/Tools/ChangeLog 2020-01-23 20:10:47 UTC (rev 254995)
@@ -1,3 +1,14 @@
+2020-01-23 Per Arne Vollan <[email protected]>
+
+ [Cocoa] Broker access to the PowerManagement API
+ https://bugs.webkit.org/show_bug.cgi?id=206373
+
+ Reviewed by Darin Adler.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit/Battery.mm: Added.
+ (TEST):
+
2020-01-23 Jonathan Bedard <[email protected]>
Fix iOS 13.2 iphoneos build
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (254994 => 254995)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2020-01-23 19:56:38 UTC (rev 254994)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2020-01-23 20:10:47 UTC (rev 254995)
@@ -862,6 +862,7 @@
C0ADBE9612FCA79B00D2C129 /* simple-form.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C0ADBE8412FCA6B600D2C129 /* simple-form.html */; };
C0BD669F131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */; };
C0C5D3C61459912900A802A6 /* GetBackingScaleFactor_Bundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */; };
+ C1692DCA23D10DAE006E88F7 /* Battery.mm in Sources */ = {isa = PBXBuildFile; fileRef = C1692DC923D10DAE006E88F7 /* Battery.mm */; };
C20F88A72295B96700D610FA /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C20F88A62295B96700D610FA /* CoreText.framework */; };
C22FA32B228F8708009D7988 /* TextWidth.mm in Sources */ = {isa = PBXBuildFile; fileRef = C22FA32A228F8708009D7988 /* TextWidth.mm */; };
C22FA32D228F8AEB009D7988 /* TextWidth.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C22FA32C228F877A009D7988 /* TextWidth.html */; };
@@ -2384,6 +2385,7 @@
C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResponsivenessTimerDoesntFireEarly_Bundle.cpp; sourceTree = "<group>"; };
C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor.mm; sourceTree = "<group>"; };
C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor_Bundle.mm; sourceTree = "<group>"; };
+ C1692DC923D10DAE006E88F7 /* Battery.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = Battery.mm; sourceTree = "<group>"; };
C1D8EE212028E8E3008EB141 /* WebProcessTerminate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessTerminate.mm; sourceTree = "<group>"; };
C20F88A62295B96700D610FA /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; };
C22FA32A228F8708009D7988 /* TextWidth.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TextWidth.mm; sourceTree = "<group>"; };
@@ -2823,6 +2825,7 @@
0F139E741A423A4600F590F5 /* cocoa */ = {
isa = PBXGroup;
children = (
+ C1692DC923D10DAE006E88F7 /* Battery.mm */,
0F139E751A423A5300F590F5 /* WeakObjCPtr.mm */,
);
name = cocoa;
@@ -4588,6 +4591,7 @@
0711DF52226A95FC003DD2F7 /* AVFoundationSoftLinkTest.mm in Sources */,
7CCE7EB51A411A7E00447C4C /* BackForwardList.mm in Sources */,
1C7FEB20207C0F2E00D23278 /* BackgroundColor.mm in Sources */,
+ C1692DCA23D10DAE006E88F7 /* Battery.mm in Sources */,
374B7A601DF36EEE00ACCB6C /* BundleEditingDelegate.mm in Sources */,
7A89BB67233164320042CB1E /* BundleFormDelegate.mm in Sources */,
A13EBBB11B87438000097110 /* BundleParameters.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit/Battery.mm (0 => 254995)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit/Battery.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/Battery.mm 2020-01-23 20:10:47 UTC (rev 254995)
@@ -0,0 +1,48 @@
+/*
+ * 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
+
+#import "PlatformUtilities.h"
+#import "TestWKWebView.h"
+#import <WebCore/SystemBattery.h>
+
+TEST(WebKit, SystemHasBattery)
+{
+ 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 hasBattery = [&] {
+ return [webView stringByEvaluatingJavaScript:@"window.internals.systemHasBattery()"].boolValue;
+ };
+
+ ASSERT_TRUE(hasBattery() == WebCore::systemHasBattery());
+}
+
+#endif // WK_HAVE_C_SPI