Diff
Modified: trunk/Source/WTF/ChangeLog (245978 => 245979)
--- trunk/Source/WTF/ChangeLog 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WTF/ChangeLog 2019-05-31 20:00:07 UTC (rev 245979)
@@ -1,3 +1,15 @@
+2019-05-31 Tim Horton <timothy_hor...@apple.com>
+
+ Optionally respect device management restrictions when loading from the network
+ https://bugs.webkit.org/show_bug.cgi?id=198318
+ <rdar://problem/44263806>
+
+ Reviewed by Alex Christensen.
+
+ * wtf/Platform.h:
+ Add a HAVE flag for DeviceManagement.framework.
+ It does exist in the simulator, but does not function; pretend it doesn't exist.
+
2019-05-31 Geoffrey Garen <gga...@apple.com>
Some WeakPtr cleanup
Modified: trunk/Source/WTF/wtf/Platform.h (245978 => 245979)
--- trunk/Source/WTF/wtf/Platform.h 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WTF/wtf/Platform.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -1547,6 +1547,10 @@
#define HAVE_ROUTE_SHARING_POLICY_LONG_FORM_VIDEO 1
#endif
+#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000 && !PLATFORM(IOS_SIMULATOR))
+#define HAVE_DEVICE_MANAGEMENT 1
+#endif
+
#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED < 101500
#define USE_REALPATH_FOR_DLOPEN_PREFLIGHT 1
#endif
Modified: trunk/Source/WebCore/ChangeLog (245978 => 245979)
--- trunk/Source/WebCore/ChangeLog 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebCore/ChangeLog 2019-05-31 20:00:07 UTC (rev 245979)
@@ -1,3 +1,13 @@
+2019-05-31 Tim Horton <timothy_hor...@apple.com>
+
+ Optionally respect device management restrictions when loading from the network
+ https://bugs.webkit.org/show_bug.cgi?id=198318
+ <rdar://problem/44263806>
+
+ Reviewed by Alex Christensen.
+
+ * en.lproj/Localizable.strings:
+
2019-05-31 Simon Fraser <simon.fra...@apple.com>
Move code that sets compositing paint phases into a single function
Modified: trunk/Source/WebCore/en.lproj/Localizable.strings (245978 => 245979)
--- trunk/Source/WebCore/en.lproj/Localizable.strings 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebCore/en.lproj/Localizable.strings 2019-05-31 20:00:07 UTC (rev 245979)
@@ -802,6 +802,9 @@
/* WebKitErrorFrameLoadBlockedByContentFilter description */
"The URL was blocked by a content filter" = "The URL was blocked by a content filter";
+/* WebKitErrorFrameLoadBlockedByRestrictions description */
+"The URL was blocked by device restrictions" = "The URL was blocked by device restrictions";
+
/* WKErrorWebViewInvalidated description */
"The WKWebView was invalidated" = "The WKWebView was invalidated";
Modified: trunk/Source/WebKit/ChangeLog (245978 => 245979)
--- trunk/Source/WebKit/ChangeLog 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/ChangeLog 2019-05-31 20:00:07 UTC (rev 245979)
@@ -1,3 +1,115 @@
+2019-05-31 Tim Horton <timothy_hor...@apple.com>
+
+ Optionally respect device management restrictions when loading from the network
+ https://bugs.webkit.org/show_bug.cgi?id=198318
+ <rdar://problem/44263806>
+
+ Reviewed by Alex Christensen.
+
+ * Configurations/Network-iOS.entitlements:
+ * Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb:
+ Add some entitlements and sandbox holes required to talk to DeviceManagement.
+
+ * NetworkProcess/NetworkCORSPreflightChecker.cpp:
+ (WebKit::NetworkCORSPreflightChecker::wasBlockedByRestrictions):
+ * NetworkProcess/NetworkCORSPreflightChecker.h:
+ * NetworkProcess/NetworkLoad.cpp:
+ (WebKit::NetworkLoad::wasBlockedByRestrictions):
+ * NetworkProcess/NetworkLoad.h:
+ * NetworkProcess/PingLoad.cpp:
+ (WebKit::PingLoad::wasBlockedByRestrictions):
+ * NetworkProcess/PingLoad.h:
+ * Shared/WebErrors.cpp:
+ (WebKit::wasBlockedByRestrictionsError):
+ * Shared/WebErrors.h:
+ * NetworkProcess/NetworkDataTask.cpp:
+ (WebKit::NetworkDataTask::create):
+ (WebKit::NetworkDataTask::failureTimerFired):
+ * NetworkProcess/NetworkDataTask.h:
+ * Shared/API/APIError.h:
+ * Shared/API/c/WKErrorRef.cpp:
+ (WKErrorGetErrorCode):
+ * Shared/API/c/WKErrorRef.h:
+ Plumb a new error for loads that are blocked by device management restrictions.
+
+ * NetworkProcess/NetworkLoadParameters.h:
+ * NetworkProcess/NetworkResourceLoadParameters.cpp:
+ (WebKit::NetworkResourceLoadParameters::encode const):
+ (WebKit::NetworkResourceLoadParameters::decode):
+ * WebProcess/Network/WebLoaderStrategy.cpp:
+ (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
+ Plumb a new bit that indicates whether a load is for the main resource of a frame.
+ We will only apply device management restrictions to main resources.
+
+ * NetworkProcess/NetworkSessionCreationParameters.cpp:
+ (WebKit::NetworkSessionCreationParameters::privateSessionParameters):
+ (WebKit::NetworkSessionCreationParameters::encode const):
+ (WebKit::NetworkSessionCreationParameters::decode):
+ * NetworkProcess/NetworkSessionCreationParameters.h:
+ * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+ (WebKit::WebsiteDataStore::parameters):
+ Plumb a new bit indicating whether a network session should respect device mangement
+ restrictions.
+
+ * NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
+ * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+ (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
+ (WebKit::NetworkDataTaskCocoa::resume):
+ Defer resuming the load until we have a reply from DeviceManagement framework
+ about whether the URL should be blocked. If it is blocked, instead fail the load.
+
+ * NetworkProcess/cocoa/NetworkSessionCocoa.h:
+ * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+ (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]):
+ (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
+ (WebKit::NetworkSessionCocoa::deviceManagementPolicyMonitor):
+ Cache a single DMFWebsitePolicyMonitor instance per NetworkSession.
+
+ * UIProcess/API/APIWebsiteDataStore.cpp:
+ (API::WebsiteDataStore::defaultDataStoreConfiguration):
+ The default data store is persistent; its configuration should reflect that.
+
+ * UIProcess/API/Cocoa/WKProcessPool.mm:
+ (-[WKProcessPool _setAllowsAnySSLCertificateForServiceWorker:]): Style.
+
+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+ (-[WKWebsiteDataStore _initWithConfiguration:]):
+ Make it possible to create a non-persistent WKWebsiteDataStore from a
+ configuration, and ensure that it does not have any persistent storage directories set.
+
+ * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
+ * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
+ (-[_WKWebsiteDataStoreConfiguration init]):
+ (-[_WKWebsiteDataStoreConfiguration initWithNonPersistentConfiguration]):
+ (-[_WKWebsiteDataStoreConfiguration isPersistent]):
+ (-[_WKWebsiteDataStoreConfiguration _setWebStorageDirectory:]):
+ (-[_WKWebsiteDataStoreConfiguration _setIndexedDBDatabaseDirectory:]):
+ (-[_WKWebsiteDataStoreConfiguration _setWebSQLDatabaseDirectory:]):
+ (-[_WKWebsiteDataStoreConfiguration _setCookieStorageFile:]):
+ (-[_WKWebsiteDataStoreConfiguration _setResourceLoadStatisticsDirectory:]):
+ (-[_WKWebsiteDataStoreConfiguration _setCacheStorageDirectory:]):
+ (-[_WKWebsiteDataStoreConfiguration _setServiceWorkerRegistrationDirectory:]):
+ (-[_WKWebsiteDataStoreConfiguration deviceManagementRestrictionsEnabled]):
+ (-[_WKWebsiteDataStoreConfiguration setDeviceManagementRestrictionsEnabled:]):
+ * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
+ (WebKit::WebsiteDataStoreConfiguration::copy):
+ * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
+ (WebKit::WebsiteDataStoreConfiguration::isPersistent const):
+ (WebKit::WebsiteDataStoreConfiguration::setPersistent):
+ (WebKit::WebsiteDataStoreConfiguration::perOriginStorageQuota const):
+ (WebKit::WebsiteDataStoreConfiguration::deviceManagementRestrictionsEnabled const):
+ (WebKit::WebsiteDataStoreConfiguration::setDeviceManagementRestrictionsEnabled):
+ (WebKit::WebsiteDataStoreConfiguration::perOriginStorageQuota): Deleted.
+ Make it possible to create a _WKWebsiteDataStoreConfiguration that will create a non-persistent
+ data store. Add a bit to _WKWebsiteDataStoreConfiguration that controls whether the network
+ session will respect device management restrictions.
+
+ * WebKit.xcodeproj/project.pbxproj:
+ * WebKit/NetworkProcess/cocoa/DeviceManagementSoftLink.h:
+ * WebKit/NetworkProcess/cocoa/DeviceManagementSoftLink.mm:
+ * WebKit/Platform/spi/Cocoa/DeviceManagementSPI.h:
+ Add some soft-linking and SPI headers.
+
2019-05-31 Ryan Haddad <ryanhad...@apple.com>
Unreviewed, rolling out r245943.
Modified: trunk/Source/WebKit/Configurations/Network-iOS.entitlements (245978 => 245979)
--- trunk/Source/WebKit/Configurations/Network-iOS.entitlements 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/Configurations/Network-iOS.entitlements 2019-05-31 20:00:07 UTC (rev 245979)
@@ -1,20 +1,2 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>com.apple.multitasking.systemappassertions</key>
- <true/>
- <key>com.apple.payment.all-access</key>
- <true/>
- <key>com.apple.private.accounts.bundleidspoofing</key>
- <true/>
- <key>com.apple.private.memorystatus</key>
- <true/>
- <key>com.apple.private.network.socket-delegate</key>
- <true/>
- <key>seatbelt-profiles</key>
- <array>
- <string>com.apple.WebKit.Networking</string>
- </array>
-</dict>
-</plist>
+bplist00\xD7
+_+com.apple.private.accounts.bundleidspoofing_com.apple.private.memorystatus_seatbelt-profiles_com.apple.payment.all-access_)com.apple.private.network.socket-delegate_com.apple.private.dmd.policy_*com.apple.multitasking.systemappassertions \xA1_com.apple.WebKit.Networking Efz\x99\xC5\xE434567
\ No newline at end of file
Modified: trunk/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.cpp (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.cpp 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.cpp 2019-05-31 20:00:07 UTC (rev 245979)
@@ -163,6 +163,12 @@
m_completionCallback(ResourceError { errorDomainWebKitInternal, 0, m_parameters.originalRequest.url(), "Preflight response was blocked"_s, ResourceError::Type::AccessControl });
}
+void NetworkCORSPreflightChecker::wasBlockedByRestrictions()
+{
+ RELEASE_LOG_IF_ALLOWED("wasBlockedByRestrictions");
+ m_completionCallback(ResourceError { errorDomainWebKitInternal, 0, m_parameters.originalRequest.url(), "Preflight response was blocked"_s, ResourceError::Type::AccessControl });
+}
+
NetworkTransactionInformation NetworkCORSPreflightChecker::takeInformation()
{
ASSERT(m_shouldCaptureExtraNetworkLoadMetrics);
Modified: trunk/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.h (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.h 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -72,6 +72,7 @@
void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) final;
void wasBlocked() final;
void cannotShowURL() final;
+ void wasBlockedByRestrictions() final;
Parameters m_parameters;
Ref<NetworkProcess> m_networkProcess;
Modified: trunk/Source/WebKit/NetworkProcess/NetworkDataTask.cpp (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/NetworkDataTask.cpp 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/NetworkDataTask.cpp 2019-05-31 20:00:07 UTC (rev 245979)
@@ -50,7 +50,7 @@
{
ASSERT(!parameters.request.url().protocolIsBlob());
#if PLATFORM(COCOA)
- return NetworkDataTaskCocoa::create(session, client, parameters.request, parameters.webFrameID, parameters.webPageID, parameters.storedCredentialsPolicy, parameters.contentSniffingPolicy, parameters.contentEncodingSniffingPolicy, parameters.shouldClearReferrerOnHTTPSToHTTPRedirect, parameters.shouldPreconnectOnly, parameters.isMainFrameNavigation, parameters.networkActivityTracker);
+ return NetworkDataTaskCocoa::create(session, client, parameters.request, parameters.webFrameID, parameters.webPageID, parameters.storedCredentialsPolicy, parameters.contentSniffingPolicy, parameters.contentEncodingSniffingPolicy, parameters.shouldClearReferrerOnHTTPSToHTTPRedirect, parameters.shouldPreconnectOnly, parameters.isMainFrameNavigation, parameters.isMainResourceNavigationForAnyFrame, parameters.networkActivityTracker);
#endif
#if USE(SOUP)
return NetworkDataTaskSoup::create(session, client, parameters.request, parameters.storedCredentialsPolicy, parameters.contentSniffingPolicy, parameters.contentEncodingSniffingPolicy, parameters.shouldClearReferrerOnHTTPSToHTTPRedirect, parameters.isMainFrameNavigation);
@@ -133,6 +133,11 @@
if (m_client)
m_client->cannotShowURL();
return;
+ case RestrictedURLFailure:
+ m_scheduledFailureType = NoFailure;
+ if (m_client)
+ m_client->wasBlockedByRestrictions();
+ return;
case NoFailure:
ASSERT_NOT_REACHED();
break;
Modified: trunk/Source/WebKit/NetworkProcess/NetworkDataTask.h (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/NetworkDataTask.h 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/NetworkDataTask.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -65,6 +65,7 @@
virtual void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) = 0;
virtual void wasBlocked() = 0;
virtual void cannotShowURL() = 0;
+ virtual void wasBlockedByRestrictions() = 0;
virtual bool shouldCaptureExtraNetworkLoadMetrics() const { return false; }
@@ -134,7 +135,8 @@
enum FailureType {
NoFailure,
BlockedFailure,
- InvalidURLFailure
+ InvalidURLFailure,
+ RestrictedURLFailure
};
void failureTimerFired();
void scheduleFailure(FailureType);
Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp 2019-05-31 20:00:07 UTC (rev 245979)
@@ -276,6 +276,10 @@
m_client.get().didFailLoading(cannotShowURLError(m_currentRequest));
}
+void NetworkLoad::wasBlockedByRestrictions()
+{
+ m_client.get().didFailLoading(wasBlockedByRestrictionsError(m_currentRequest));
+}
String NetworkLoad::description() const
{
Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoad.h (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/NetworkLoad.h 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoad.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -80,6 +80,7 @@
void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) final;
void wasBlocked() final;
void cannotShowURL() final;
+ void wasBlockedByRestrictions() final;
void notifyDidReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&);
void throttleDelayCompleted();
Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoadParameters.h (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/NetworkLoadParameters.h 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoadParameters.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -51,6 +51,7 @@
bool shouldClearReferrerOnHTTPSToHTTPRedirect { true };
bool needsCertificateInfo { false };
bool isMainFrameNavigation { false };
+ bool isMainResourceNavigationForAnyFrame { false };
Vector<RefPtr<WebCore::BlobDataFileReference>> blobFileReferences;
PreconnectOnly shouldPreconnectOnly { PreconnectOnly::No };
Optional<NetworkActivityTracker> networkActivityTracker;
Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp 2019-05-31 20:00:07 UTC (rev 245979)
@@ -78,6 +78,7 @@
encoder << shouldClearReferrerOnHTTPSToHTTPRedirect;
encoder << needsCertificateInfo;
encoder << isMainFrameNavigation;
+ encoder << isMainResourceNavigationForAnyFrame;
encoder << maximumBufferingTime;
encoder << static_cast<bool>(sourceOrigin);
@@ -169,6 +170,8 @@
return false;
if (!decoder.decode(result.isMainFrameNavigation))
return false;
+ if (!decoder.decode(result.isMainResourceNavigationForAnyFrame))
+ return false;
if (!decoder.decode(result.maximumBufferingTime))
return false;
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp 2019-05-31 20:00:07 UTC (rev 245979)
@@ -50,7 +50,7 @@
#if USE(CURL)
, { }, { }
#endif
- , { }, { }, false, { }, { }, { }, { }, { }
+ , { }, { }, false, { }, { }, { }, { }, { }, { }, { }
};
}
@@ -84,7 +84,10 @@
encoder << enableResourceLoadStatisticsDebugMode;
encoder << resourceLoadStatisticsManualPrevalentResource;
- encoder << localStorageDirectory << localStorageDirectoryExtensionHandle;
+ encoder << localStorageDirectory << localStorageDirectoryExtensionHandle;
+
+ encoder << deviceManagementRestrictionsEnabled;
+ encoder << allLoadsBlockedByDeviceManagementRestrictionsForTesting;
}
Optional<NetworkSessionCreationParameters> NetworkSessionCreationParameters::decode(IPC::Decoder& decoder)
@@ -208,6 +211,16 @@
if (!localStorageDirectoryExtensionHandle)
return WTF::nullopt;
+ Optional<bool> deviceManagementRestrictionsEnabled;
+ decoder >> deviceManagementRestrictionsEnabled;
+ if (!deviceManagementRestrictionsEnabled)
+ return WTF::nullopt;
+
+ Optional<bool> allLoadsBlockedByDeviceManagementRestrictionsForTesting;
+ decoder >> allLoadsBlockedByDeviceManagementRestrictionsForTesting;
+ if (!allLoadsBlockedByDeviceManagementRestrictionsForTesting)
+ return WTF::nullopt;
+
return {{
sessionID
, WTFMove(*boundInterfaceIdentifier)
@@ -235,6 +248,8 @@
, WTFMove(*enableResourceLoadStatistics)
, WTFMove(*shouldIncludeLocalhostInResourceLoadStatistics)
, WTFMove(*enableResourceLoadStatisticsDebugMode)
+ , WTFMove(*deviceManagementRestrictionsEnabled)
+ , WTFMove(*allLoadsBlockedByDeviceManagementRestrictionsForTesting)
, WTFMove(*resourceLoadStatisticsManualPrevalentResource)
, WTFMove(*localStorageDirectory)
, WTFMove(*localStorageDirectoryExtensionHandle)
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -86,6 +86,8 @@
bool enableResourceLoadStatistics { false };
bool shouldIncludeLocalhostInResourceLoadStatistics { true };
bool enableResourceLoadStatisticsDebugMode { false };
+ bool deviceManagementRestrictionsEnabled { false };
+ bool allLoadsBlockedByDeviceManagementRestrictionsForTesting { false };
WebCore::RegistrableDomain resourceLoadStatisticsManualPrevalentResource { };
String localStorageDirectory;
Modified: trunk/Source/WebKit/NetworkProcess/PingLoad.cpp (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/PingLoad.cpp 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/PingLoad.cpp 2019-05-31 20:00:07 UTC (rev 245979)
@@ -200,6 +200,12 @@
didFinish(cannotShowURLError(ResourceRequest { currentURL() }));
}
+void PingLoad::wasBlockedByRestrictions()
+{
+ RELEASE_LOG_IF_ALLOWED("wasBlockedByRestrictions");
+ didFinish(wasBlockedByRestrictionsError(ResourceRequest { currentURL() }));
+}
+
void PingLoad::timeoutTimerFired()
{
RELEASE_LOG_IF_ALLOWED("timeoutTimerFired");
Modified: trunk/Source/WebKit/NetworkProcess/PingLoad.h (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/PingLoad.h 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/PingLoad.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -58,6 +58,7 @@
void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) final;
void wasBlocked() final;
void cannotShowURL() final;
+ void wasBlockedByRestrictions() final;
void timeoutTimerFired();
void loadRequest(NetworkProcess&, WebCore::ResourceRequest&&);
Added: trunk/Source/WebKit/NetworkProcess/cocoa/DeviceManagementSoftLink.h (0 => 245979)
--- trunk/Source/WebKit/NetworkProcess/cocoa/DeviceManagementSoftLink.h (rev 0)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/DeviceManagementSoftLink.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#if HAVE(DEVICE_MANAGEMENT)
+
+#import "DeviceManagementSPI.h"
+#import <wtf/SoftLinking.h>
+
+SOFT_LINK_FRAMEWORK_FOR_HEADER(WebKit, DeviceManagement);
+SOFT_LINK_CLASS_FOR_HEADER(WebKit, DMFWebsitePolicyMonitor);
+
+#endif // HAVE(DEVICE_MANAGEMENT)
Added: trunk/Source/WebKit/NetworkProcess/cocoa/DeviceManagementSoftLink.mm (0 => 245979)
--- trunk/Source/WebKit/NetworkProcess/cocoa/DeviceManagementSoftLink.mm (rev 0)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/DeviceManagementSoftLink.mm 2019-05-31 20:00:07 UTC (rev 245979)
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+#import "config.h"
+
+#if HAVE(DEVICE_MANAGEMENT)
+
+#import "DeviceManagementSPI.h"
+#import <wtf/SoftLinking.h>
+
+SOFT_LINK_PRIVATE_FRAMEWORK_FOR_SOURCE(WebKit, DeviceManagement);
+SOFT_LINK_CLASS_FOR_SOURCE(WebKit, DeviceManagement, DMFWebsitePolicyMonitor);
+
+#endif // HAVE(DEVICE_MANAGEMENT)
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -42,9 +42,9 @@
class NetworkDataTaskCocoa final : public NetworkDataTask {
friend class NetworkSessionCocoa;
public:
- static Ref<NetworkDataTask> create(NetworkSession& session, NetworkDataTaskClient& client, const WebCore::ResourceRequest& request, uint64_t frameID, WebCore::PageIdentifier pageID, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, WebCore::ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy shouldContentEncodingSniff, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly shouldPreconnectOnly, bool dataTaskIsForMainFrameNavigation, Optional<NetworkActivityTracker> networkActivityTracker)
+ static Ref<NetworkDataTask> create(NetworkSession& session, NetworkDataTaskClient& client, const WebCore::ResourceRequest& request, uint64_t frameID, WebCore::PageIdentifier pageID, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, WebCore::ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy shouldContentEncodingSniff, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly shouldPreconnectOnly, bool dataTaskIsForMainFrameNavigation, bool dataTaskIsForMainResourceNavigationForAnyFrame, Optional<NetworkActivityTracker> networkActivityTracker)
{
- return adoptRef(*new NetworkDataTaskCocoa(session, client, request, frameID, pageID, storedCredentialsPolicy, shouldContentSniff, shouldContentEncodingSniff, shouldClearReferrerOnHTTPSToHTTPRedirect, shouldPreconnectOnly, dataTaskIsForMainFrameNavigation, networkActivityTracker));
+ return adoptRef(*new NetworkDataTaskCocoa(session, client, request, frameID, pageID, storedCredentialsPolicy, shouldContentSniff, shouldContentEncodingSniff, shouldClearReferrerOnHTTPSToHTTPRedirect, shouldPreconnectOnly, dataTaskIsForMainFrameNavigation, dataTaskIsForMainResourceNavigationForAnyFrame, networkActivityTracker));
}
~NetworkDataTaskCocoa();
@@ -75,7 +75,7 @@
String description() const override;
private:
- NetworkDataTaskCocoa(NetworkSession&, NetworkDataTaskClient&, const WebCore::ResourceRequest&, uint64_t frameID, WebCore::PageIdentifier, WebCore::StoredCredentialsPolicy, WebCore::ContentSniffingPolicy, WebCore::ContentEncodingSniffingPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly, bool dataTaskIsForMainFrameNavigation, Optional<NetworkActivityTracker>);
+ NetworkDataTaskCocoa(NetworkSession&, NetworkDataTaskClient&, const WebCore::ResourceRequest&, uint64_t frameID, WebCore::PageIdentifier, WebCore::StoredCredentialsPolicy, WebCore::ContentSniffingPolicy, WebCore::ContentEncodingSniffingPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly, bool dataTaskIsForMainFrameNavigation, bool dataTaskIsForMainResourceNavigationForAnyFrame, Optional<NetworkActivityTracker>);
bool tryPasswordBasedAuthentication(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&);
void applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(__strong NSURLRequest*&, bool shouldContentSniff, bool shouldContentEncodingSniff);
@@ -98,6 +98,8 @@
#if ENABLE(RESOURCE_LOAD_STATISTICS)
bool m_hasBeenSetToUseStatelessCookieStorage { false };
#endif
+
+ bool m_isForMainResourceNavigationForAnyFrame { false };
};
WebCore::Credential serverTrustCredential(const WebCore::AuthenticationChallenge&);
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm 2019-05-31 20:00:07 UTC (rev 245979)
@@ -28,6 +28,7 @@
#import "AuthenticationChallengeDisposition.h"
#import "AuthenticationManager.h"
+#import "DeviceManagementSPI.h"
#import "Download.h"
#import "DownloadProxyMessages.h"
#import "Logging.h"
@@ -39,6 +40,7 @@
#import <WebCore/NotImplemented.h>
#import <WebCore/ResourceRequest.h>
#import <pal/spi/cf/CFNetworkSPI.h>
+#import <wtf/BlockPtr.h>
#import <wtf/FileSystem.h>
#import <wtf/MainThread.h>
#import <wtf/ProcessPrivilege.h>
@@ -160,10 +162,11 @@
#endif
}
-NetworkDataTaskCocoa::NetworkDataTaskCocoa(NetworkSession& session, NetworkDataTaskClient& client, const WebCore::ResourceRequest& requestWithCredentials, uint64_t frameID, WebCore::PageIdentifier pageID, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, WebCore::ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy shouldContentEncodingSniff, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly shouldPreconnectOnly, bool dataTaskIsForMainFrameNavigation, Optional<NetworkActivityTracker> networkActivityTracker)
+NetworkDataTaskCocoa::NetworkDataTaskCocoa(NetworkSession& session, NetworkDataTaskClient& client, const WebCore::ResourceRequest& requestWithCredentials, uint64_t frameID, WebCore::PageIdentifier pageID, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, WebCore::ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy shouldContentEncodingSniff, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly shouldPreconnectOnly, bool dataTaskIsForMainFrameNavigation, bool dataTaskIsForMainResourceNavigationForAnyFrame, Optional<NetworkActivityTracker> networkActivityTracker)
: NetworkDataTask(session, client, requestWithCredentials, storedCredentialsPolicy, shouldClearReferrerOnHTTPSToHTTPRedirect, dataTaskIsForMainFrameNavigation)
, m_frameID(frameID)
, m_pageID(pageID)
+ , m_isForMainResourceNavigationForAnyFrame(dataTaskIsForMainResourceNavigationForAnyFrame)
{
if (m_scheduledFailureType != NoFailure)
return;
@@ -489,6 +492,36 @@
{
if (m_scheduledFailureType != NoFailure)
m_failureTimer.startOneShot(0_s);
+
+ auto& cocoaSession = static_cast<NetworkSessionCocoa&>(m_session.get());
+ if (cocoaSession.deviceManagementRestrictionsEnabled() && m_isForMainResourceNavigationForAnyFrame) {
+ auto didDetermineDeviceRestrictionPolicyForURL = makeBlockPtr([this, protectedThis = makeRef(*this)](BOOL isBlocked) {
+ callOnMainThread([this, protectedThis = makeRef(*this), isBlocked] {
+ if (isBlocked) {
+ scheduleFailure(RestrictedURLFailure);
+ return;
+ }
+
+ [m_task resume];
+ });
+ });
+
+#if HAVE(DEVICE_MANAGEMENT)
+ if (cocoaSession.allLoadsBlockedByDeviceManagementRestrictionsForTesting())
+ didDetermineDeviceRestrictionPolicyForURL(true);
+ else {
+ RetainPtr<NSURL> urlToCheck = [m_task currentRequest].URL;
+ [cocoaSession.deviceManagementPolicyMonitor() requestPoliciesForWebsites:@[ urlToCheck.get() ] completionHandler:makeBlockPtr([didDetermineDeviceRestrictionPolicyForURL, urlToCheck] (NSDictionary<NSURL *, NSNumber *> *policies, NSError *error) {
+ bool isBlocked = error || policies[urlToCheck.get()].integerValue != DMFPolicyOK;
+ didDetermineDeviceRestrictionPolicyForURL(isBlocked);
+ }).get()];
+ }
+#else
+ didDetermineDeviceRestrictionPolicyForURL(cocoaSession.allLoadsBlockedByDeviceManagementRestrictionsForTesting());
+#endif
+ return;
+ }
+
[m_task resume];
}
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -25,6 +25,7 @@
#pragma once
+OBJC_CLASS DMFWebsitePolicyMonitor;
OBJC_CLASS NSData;
OBJC_CLASS NSURLSession;
OBJC_CLASS NSURLSessionDownloadTask;
@@ -69,6 +70,10 @@
void continueDidReceiveChallenge(const WebCore::AuthenticationChallenge&, NetworkDataTaskCocoa::TaskIdentifier, NetworkDataTaskCocoa*, CompletionHandler<void(WebKit::AuthenticationChallengeDisposition, const WebCore::Credential&)>&&);
+ bool deviceManagementRestrictionsEnabled() const { return m_deviceManagementRestrictionsEnabled; }
+ bool allLoadsBlockedByDeviceManagementRestrictionsForTesting() const { return m_allLoadsBlockedByDeviceManagementRestrictionsForTesting; }
+ DMFWebsitePolicyMonitor *deviceManagementPolicyMonitor();
+
private:
NetworkSessionCocoa(NetworkProcess&, NetworkSessionCreationParameters&&);
@@ -93,6 +98,9 @@
String m_sourceApplicationBundleIdentifier;
String m_sourceApplicationSecondaryIdentifier;
RetainPtr<CFDictionaryRef> m_proxyConfiguration;
+ RetainPtr<DMFWebsitePolicyMonitor> m_deviceManagementPolicyMonitor;
+ bool m_deviceManagementRestrictionsEnabled { false };
+ bool m_allLoadsBlockedByDeviceManagementRestrictionsForTesting { false };
bool m_shouldLogCookieInformation { false };
Seconds m_loadThrottleLatency;
};
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (245978 => 245979)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm 2019-05-31 20:00:07 UTC (rev 245979)
@@ -51,6 +51,7 @@
#import <wtf/NeverDestroyed.h>
#import <wtf/ObjCRuntimeExtras.h>
#import <wtf/ProcessPrivilege.h>
+#import <wtf/SoftLinking.h>
#import <wtf/URL.h>
#import <wtf/text/WTFString.h>
@@ -58,6 +59,8 @@
#include <WebKitAdditions/NetworkSessionCocoaAdditions.h>
#endif
+#import "DeviceManagementSoftLink.h"
+
using namespace WebKit;
CFStringRef const WebKit2HTTPProxyDefaultsKey = static_cast<CFStringRef>(@"WebKit2HTTPProxy");
@@ -721,7 +724,7 @@
ASSERT(RunLoop::isMain());
// Avoid MIME type sniffing if the response comes back as 304 Not Modified.
- int statusCode = [response respondsToSelector:@selector(statusCode)] ? [(id)response statusCode] : 0;
+ int statusCode = [response isKindOfClass:NSHTTPURLResponse.class] ? [(NSHTTPURLResponse *)response statusCode] : 0;
if (statusCode != 304) {
bool isMainResourceLoad = networkDataTask->firstRequest().requester() == WebCore::ResourceRequest::Requester::Main;
WebCore::adjustMIMETypeIfNecessary(response._CFURLResponse, isMainResourceLoad);
@@ -989,6 +992,9 @@
m_statelessSessionDelegate = adoptNS([[WKNetworkSessionDelegate alloc] initWithNetworkSession:*this withCredentials:false]);
m_statelessSession = [NSURLSession sessionWithConfiguration:configuration delegate:static_cast<id>(m_statelessSessionDelegate.get()) delegateQueue:[NSOperationQueue mainQueue]];
+ m_deviceManagementRestrictionsEnabled = parameters.deviceManagementRestrictionsEnabled;
+ m_allLoadsBlockedByDeviceManagementRestrictionsForTesting = parameters.allLoadsBlockedByDeviceManagementRestrictionsForTesting;
+
#if ENABLE(RESOURCE_LOAD_STATISTICS)
m_resourceLoadStatisticsDirectory = parameters.resourceLoadStatisticsDirectory;
m_shouldIncludeLocalhostInResourceLoadStatistics = parameters.shouldIncludeLocalhostInResourceLoadStatistics ? ShouldIncludeLocalhost::Yes : ShouldIncludeLocalhost::No;
@@ -1175,4 +1181,17 @@
networkDataTask->didReceiveChallenge(WTFMove(authenticationChallenge), WTFMove(challengeCompletionHandler));
}
+DMFWebsitePolicyMonitor *NetworkSessionCocoa::deviceManagementPolicyMonitor()
+{
+#if HAVE(DEVICE_MANAGEMENT)
+ ASSERT(m_deviceManagementRestrictionsEnabled);
+ if (!m_deviceManagementPolicyMonitor)
+ m_deviceManagementPolicyMonitor = adoptNS([allocDMFWebsitePolicyMonitorInstance() initWithPolicyChangeHandler:nil]);
+ return m_deviceManagementPolicyMonitor.get();
+#else
+ RELEASE_ASSERT_NOT_REACHED();
+ return nil;
+#endif
}
+
+}
Added: trunk/Source/WebKit/Platform/spi/Cocoa/DeviceManagementSPI.h (0 => 245979)
--- trunk/Source/WebKit/Platform/spi/Cocoa/DeviceManagementSPI.h (rev 0)
+++ trunk/Source/WebKit/Platform/spi/Cocoa/DeviceManagementSPI.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#if HAVE(DEVICE_MANAGEMENT)
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <DeviceManagement/DeviceManagement.h>
+
+#else
+
+@interface DMFWebsitePolicyMonitor : NSObject
+
+- (instancetype)initWithPolicyChangeHandler:(void(^)(void))changeHandler;
+- (void)requestPoliciesForWebsites:(NSArray<NSURL *> *)websiteURLs completionHandler:(void (^)(NSDictionary<NSURL *, NSNumber *> *policies, NSError *error))completionHandler;
+
+@end
+
+typedef NS_ENUM(NSInteger, DMFPolicy) {
+ DMFPolicyOK = 0,
+ DMFPolicyBlocked = 4,
+};
+
+#endif // USE(APPLE_INTERNAL_SDK)
+
+#endif // HAVE(DEVICE_MANAGEMENT)
Modified: trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb (245978 => 245979)
--- trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb 2019-05-31 20:00:07 UTC (rev 245979)
@@ -82,6 +82,11 @@
(global-name "com.apple.passd.in-app-payment")
(global-name "com.apple.passd.library"))
+(allow mach-lookup
+ (global-name "com.apple.dmd.policy")
+ (global-name "com.apple.siri.context.service")
+ (global-name "com.apple.ctcategories.service"))
+
(deny file-write-create
(vnode-type SYMLINK))
Modified: trunk/Source/WebKit/Shared/API/APIError.h (245978 => 245979)
--- trunk/Source/WebKit/Shared/API/APIError.h 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/Shared/API/APIError.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -65,7 +65,8 @@
FrameLoadInterruptedByPolicyChange = 102,
CannotUseRestrictedPort = 103,
FrameLoadBlockedByContentBlocker = 104,
- FrameLoadBlockedByContentFilter = 105
+ FrameLoadBlockedByContentFilter = 105,
+ FrameLoadBlockedByRestrictions = 106,
};
static const WTF::String& webKitPolicyErrorDomain();
Modified: trunk/Source/WebKit/Shared/API/c/WKErrorRef.cpp (245978 => 245979)
--- trunk/Source/WebKit/Shared/API/c/WKErrorRef.cpp 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/Shared/API/c/WKErrorRef.cpp 2019-05-31 20:00:07 UTC (rev 245979)
@@ -58,6 +58,8 @@
return kWKErrorCodeCannotUseRestrictedPort;
case API::Error::Policy::FrameLoadBlockedByContentBlocker:
return kWKErrorCodeFrameLoadBlockedByContentBlocker;
+ case API::Error::Policy::FrameLoadBlockedByRestrictions:
+ return kWKErrorCodeFrameLoadBlockedByRestrictions;
case API::Error::Policy::FrameLoadBlockedByContentFilter:
return kWKErrorCodeFrameLoadBlockedByContentFilter;
case API::Error::Plugin::CannotFindPlugIn:
Modified: trunk/Source/WebKit/Shared/API/c/WKErrorRef.h (245978 => 245979)
--- trunk/Source/WebKit/Shared/API/c/WKErrorRef.h 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/Shared/API/c/WKErrorRef.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -39,6 +39,7 @@
kWKErrorCodeCannotUseRestrictedPort = 103,
kWKErrorCodeFrameLoadBlockedByContentBlocker = 104,
kWKErrorCodeFrameLoadBlockedByContentFilter = 105,
+ kWKErrorCodeFrameLoadBlockedByRestrictions = 106,
kWKErrorCodeCannotFindPlugIn = 200,
kWKErrorCodeCannotLoadPlugIn = 201,
kWKErrorCodeJavaUnavailable = 202,
Modified: trunk/Source/WebKit/Shared/WebErrors.cpp (245978 => 245979)
--- trunk/Source/WebKit/Shared/WebErrors.cpp 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/Shared/WebErrors.cpp 2019-05-31 20:00:07 UTC (rev 245979)
@@ -52,6 +52,11 @@
return ResourceError(API::Error::webKitPolicyErrorDomain(), API::Error::Policy::CannotShowURL, request.url(), WEB_UI_STRING("The URL can’t be shown", "WebKitErrorCannotShowURL description"));
}
+ResourceError wasBlockedByRestrictionsError(const ResourceRequest& request)
+{
+ return ResourceError(API::Error::webKitPolicyErrorDomain(), API::Error::Policy::FrameLoadBlockedByRestrictions, request.url(), WEB_UI_STRING("The URL was blocked by device restrictions", "WebKitErrorFrameLoadBlockedByRestrictions description"));
+}
+
ResourceError interruptedForPolicyChangeError(const ResourceRequest& request)
{
return ResourceError(API::Error::webKitPolicyErrorDomain(), API::Error::Policy::FrameLoadInterruptedByPolicyChange, request.url(), WEB_UI_STRING("Frame load interrupted", "WebKitErrorFrameLoadInterruptedByPolicyChange description"));
Modified: trunk/Source/WebKit/Shared/WebErrors.h (245978 => 245979)
--- trunk/Source/WebKit/Shared/WebErrors.h 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/Shared/WebErrors.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -39,6 +39,7 @@
WebCore::ResourceError blockedError(const WebCore::ResourceRequest&);
WebCore::ResourceError blockedByContentBlockerError(const WebCore::ResourceRequest&);
WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&);
+WebCore::ResourceError wasBlockedByRestrictionsError(const WebCore::ResourceRequest&);
WebCore::ResourceError interruptedForPolicyChangeError(const WebCore::ResourceRequest&);
WebCore::ResourceError failedCustomProtocolSyncLoad(const WebCore::ResourceRequest&);
#if ENABLE(CONTENT_FILTERING)
Modified: trunk/Source/WebKit/UIProcess/API/APIWebsiteDataStore.cpp (245978 => 245979)
--- trunk/Source/WebKit/UIProcess/API/APIWebsiteDataStore.cpp 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/UIProcess/API/APIWebsiteDataStore.cpp 2019-05-31 20:00:07 UTC (rev 245979)
@@ -145,6 +145,8 @@
{
auto configuration = WebKit::WebsiteDataStoreConfiguration::create();
+ configuration->setPersistent(true);
+
configuration->setApplicationCacheDirectory(defaultApplicationCacheDirectory());
configuration->setApplicationCacheFlatFileSubdirectoryName("Files");
configuration->setCacheStorageDirectory(defaultCacheStorageDirectory());
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKErrorPrivate.h (245978 => 245979)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKErrorPrivate.h 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKErrorPrivate.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -29,6 +29,7 @@
typedef NS_ENUM(NSInteger, _WKLegacyErrorCode) {
_WKErrorCodeFrameLoadInterruptedByPolicyChange WK_API_AVAILABLE(macos(10.11), ios(9.0)) = 102,
+ _WKErrorCodeFrameLoadBlockedByRestrictions WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)) = 106,
_WKLegacyErrorPlugInWillHandleLoad = 204,
} WK_API_AVAILABLE(macos(10.11), ios(8.3));
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm (245978 => 245979)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm 2019-05-31 20:00:07 UTC (rev 245979)
@@ -584,7 +584,7 @@
_processPool->synthesizeAppIsBackground(background);
}
-- (void)_setAllowsAnySSLCertificateForServiceWorker:(BOOL) allows
+- (void)_setAllowsAnySSLCertificateForServiceWorker:(BOOL)allows
{
#if ENABLE(SERVICE_WORKER)
_processPool->setAllowsAnySSLCertificateForServiceWorker(allows);
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (245978 => 245979)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2019-05-31 20:00:07 UTC (rev 245979)
@@ -229,22 +229,35 @@
if (!(self = [super init]))
return nil;
- auto config = API::WebsiteDataStore::defaultDataStoreConfiguration();
+ auto config = configuration.isPersistent ? API::WebsiteDataStore::defaultDataStoreConfiguration() : WebKit::WebsiteDataStoreConfiguration::create();
- if (configuration._webStorageDirectory)
- config->setLocalStorageDirectory(configuration._webStorageDirectory.path);
- if (configuration._webSQLDatabaseDirectory)
- config->setWebSQLDatabaseDirectory(configuration._webSQLDatabaseDirectory.path);
- if (configuration._indexedDBDatabaseDirectory)
- config->setIndexedDBDatabaseDirectory(configuration._indexedDBDatabaseDirectory.path);
- if (configuration._cookieStorageFile)
- config->setCookieStorageFile(configuration._cookieStorageFile.path);
- if (configuration._resourceLoadStatisticsDirectory)
- config->setResourceLoadStatisticsDirectory(configuration._resourceLoadStatisticsDirectory.path);
- if (configuration._cacheStorageDirectory)
- config->setCacheStorageDirectory(configuration._cacheStorageDirectory.path);
- if (configuration._serviceWorkerRegistrationDirectory)
- config->setServiceWorkerRegistrationDirectory(configuration._serviceWorkerRegistrationDirectory.path);
+ RELEASE_ASSERT(config->isPersistent() == configuration.isPersistent);
+
+ if (configuration.isPersistent) {
+ if (configuration._webStorageDirectory)
+ config->setLocalStorageDirectory(configuration._webStorageDirectory.path);
+ if (configuration._webSQLDatabaseDirectory)
+ config->setWebSQLDatabaseDirectory(configuration._webSQLDatabaseDirectory.path);
+ if (configuration._indexedDBDatabaseDirectory)
+ config->setIndexedDBDatabaseDirectory(configuration._indexedDBDatabaseDirectory.path);
+ if (configuration._cookieStorageFile)
+ config->setCookieStorageFile(configuration._cookieStorageFile.path);
+ if (configuration._resourceLoadStatisticsDirectory)
+ config->setResourceLoadStatisticsDirectory(configuration._resourceLoadStatisticsDirectory.path);
+ if (configuration._cacheStorageDirectory)
+ config->setCacheStorageDirectory(configuration._cacheStorageDirectory.path);
+ if (configuration._serviceWorkerRegistrationDirectory)
+ config->setServiceWorkerRegistrationDirectory(configuration._serviceWorkerRegistrationDirectory.path);
+ } else {
+ RELEASE_ASSERT(!configuration._webStorageDirectory);
+ RELEASE_ASSERT(!configuration._webSQLDatabaseDirectory);
+ RELEASE_ASSERT(!configuration._indexedDBDatabaseDirectory);
+ RELEASE_ASSERT(!configuration._cookieStorageFile);
+ RELEASE_ASSERT(!configuration._resourceLoadStatisticsDirectory);
+ RELEASE_ASSERT(!configuration._cacheStorageDirectory);
+ RELEASE_ASSERT(!configuration._serviceWorkerRegistrationDirectory);
+ }
+
if (configuration.sourceApplicationBundleIdentifier)
config->setSourceApplicationBundleIdentifier(configuration.sourceApplicationBundleIdentifier);
if (configuration.sourceApplicationSecondaryIdentifier)
@@ -253,9 +266,13 @@
config->setHTTPProxy(configuration.httpProxy);
if (configuration.httpsProxy)
config->setHTTPSProxy(configuration.httpsProxy);
+ config->setDeviceManagementRestrictionsEnabled(configuration.deviceManagementRestrictionsEnabled);
+ config->setAllLoadsBlockedByDeviceManagementRestrictionsForTesting(configuration.allLoadsBlockedByDeviceManagementRestrictionsForTesting);
- API::Object::constructInWrapper<API::WebsiteDataStore>(self, WTFMove(config), PAL::SessionID::generatePersistentSessionID());
+ auto sessionID = configuration.isPersistent ? PAL::SessionID::generatePersistentSessionID() : PAL::SessionID::generateEphemeralSessionID();
+ API::Object::constructInWrapper<API::WebsiteDataStore>(self, WTFMove(config), sessionID);
+
return self;
}
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h (245978 => 245979)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -32,6 +32,20 @@
WK_CLASS_AVAILABLE(macos(10.13), ios(11.0))
@interface _WKWebsiteDataStoreConfiguration : NSObject
+- (instancetype)init; // Creates a persistent configuration.
+- (instancetype)initNonPersistentConfiguration WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
+@property (nonatomic, readonly, getter=isPersistent) BOOL persistent WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
+// These properties apply to both persistent and non-persistent data stores.
+@property (nonatomic, nullable, copy) NSString *sourceApplicationBundleIdentifier WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
+@property (nonatomic, nullable, copy) NSString *sourceApplicationSecondaryIdentifier WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
+@property (nonatomic, nullable, copy, setter=setHTTPProxy:) NSURL *httpProxy WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
+@property (nonatomic, nullable, copy, setter=setHTTPSProxy:) NSURL *httpsProxy WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
+@property (nonatomic) BOOL deviceManagementRestrictionsEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
+// These properties only make sense for persistent data stores, and will throw
+// an exception if set for non-persistent stores.
@property (nonatomic, copy, setter=_setWebStorageDirectory:) NSURL *_webStorageDirectory;
@property (nonatomic, copy, setter=_setIndexedDBDatabaseDirectory:) NSURL *_indexedDBDatabaseDirectory;
@property (nonatomic, copy, setter=_setWebSQLDatabaseDirectory:) NSURL *_webSQLDatabaseDirectory;
@@ -39,11 +53,10 @@
@property (nonatomic, copy, setter=_setResourceLoadStatisticsDirectory:) NSURL *_resourceLoadStatisticsDirectory WK_API_AVAILABLE(macos(10.13.4), ios(11.3));
@property (nonatomic, copy, setter=_setCacheStorageDirectory:) NSURL *_cacheStorageDirectory WK_API_AVAILABLE(macos(10.13.4), ios(11.3));
@property (nonatomic, copy, setter=_setServiceWorkerRegistrationDirectory:) NSURL *_serviceWorkerRegistrationDirectory WK_API_AVAILABLE(macos(10.13.4), ios(11.3));
-@property (nonatomic, nullable, copy) NSString *sourceApplicationBundleIdentifier WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
-@property (nonatomic, nullable, copy) NSString *sourceApplicationSecondaryIdentifier WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
-@property (nonatomic, nullable, copy, setter=setHTTPProxy:) NSURL *httpProxy WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
-@property (nonatomic, nullable, copy, setter=setHTTPSProxy:) NSURL *httpsProxy WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
+// Testing only.
+@property (nonatomic) BOOL allLoadsBlockedByDeviceManagementRestrictionsForTesting WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
@end
NS_ASSUME_NONNULL_END
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm (245978 => 245979)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm 2019-05-31 20:00:07 UTC (rev 245979)
@@ -36,6 +36,33 @@
@implementation _WKWebsiteDataStoreConfiguration
+- (instancetype)init
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _configuration->setPersistent(true);
+
+ return self;
+}
+
+- (instancetype)initNonPersistentConfiguration
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _configuration->setPersistent(false);
+
+ return self;
+}
+
+- (BOOL)isPersistent
+{
+ return _configuration->isPersistent();
+}
+
- (NSURL *)_webStorageDirectory
{
return [NSURL fileURLWithPath:_configuration->webStorageDirectory() isDirectory:YES];
@@ -43,6 +70,8 @@
- (void)_setWebStorageDirectory:(NSURL *)url
{
+ if (!_configuration->isPersistent())
+ [NSException raise:NSInvalidArgumentException format:@"Cannot set _webStorageDirectory on a non-persistent _WKWebsiteDataStoreConfiguration."];
checkURLArgument(url);
_configuration->setWebStorageDirectory(url.path);
}
@@ -54,6 +83,8 @@
- (void)_setIndexedDBDatabaseDirectory:(NSURL *)url
{
+ if (!_configuration->isPersistent())
+ [NSException raise:NSInvalidArgumentException format:@"Cannot set _indexedDBDatabaseDirectory on a non-persistent _WKWebsiteDataStoreConfiguration."];
checkURLArgument(url);
_configuration->setIndexedDBDatabaseDirectory(url.path);
}
@@ -65,6 +96,8 @@
- (void)_setWebSQLDatabaseDirectory:(NSURL *)url
{
+ if (!_configuration->isPersistent())
+ [NSException raise:NSInvalidArgumentException format:@"Cannot set _webSQLDatabaseDirectory on a non-persistent _WKWebsiteDataStoreConfiguration."];
checkURLArgument(url);
_configuration->setWebSQLDatabaseDirectory(url.path);
}
@@ -96,6 +129,8 @@
- (void)_setCookieStorageFile:(NSURL *)url
{
+ if (!_configuration->isPersistent())
+ [NSException raise:NSInvalidArgumentException format:@"Cannot set _cookieStorageFile on a non-persistent _WKWebsiteDataStoreConfiguration."];
checkURLArgument(url);
if ([url hasDirectoryPath])
[NSException raise:NSInvalidArgumentException format:@"The cookie storage path must point to a file, not a directory."];
@@ -110,6 +145,8 @@
- (void)_setResourceLoadStatisticsDirectory:(NSURL *)url
{
+ if (!_configuration->isPersistent())
+ [NSException raise:NSInvalidArgumentException format:@"Cannot set _resourceLoadStatisticsDirectory on a non-persistent _WKWebsiteDataStoreConfiguration."];
checkURLArgument(url);
_configuration->setResourceLoadStatisticsDirectory(url.path);
}
@@ -121,6 +158,8 @@
- (void)_setCacheStorageDirectory:(NSURL *)url
{
+ if (!_configuration->isPersistent())
+ [NSException raise:NSInvalidArgumentException format:@"Cannot set _cacheStorageDirectory on a non-persistent _WKWebsiteDataStoreConfiguration."];
checkURLArgument(url);
_configuration->setCacheStorageDirectory(url.path);
}
@@ -132,6 +171,8 @@
- (void)_setServiceWorkerRegistrationDirectory:(NSURL *)url
{
+ if (!_configuration->isPersistent())
+ [NSException raise:NSInvalidArgumentException format:@"Cannot set _serviceWorkerRegistrationDirectory on a non-persistent _WKWebsiteDataStoreConfiguration."];
checkURLArgument(url);
_configuration->setServiceWorkerRegistrationDirectory(url.path);
}
@@ -156,6 +197,26 @@
_configuration->setSourceApplicationSecondaryIdentifier(identifier);
}
+- (BOOL)deviceManagementRestrictionsEnabled
+{
+ return _configuration->deviceManagementRestrictionsEnabled();
+}
+
+- (void)setDeviceManagementRestrictionsEnabled:(BOOL)enabled
+{
+ _configuration->setDeviceManagementRestrictionsEnabled(enabled);
+}
+
+- (BOOL)allLoadsBlockedByDeviceManagementRestrictionsForTesting
+{
+ return _configuration->allLoadsBlockedByDeviceManagementRestrictionsForTesting();
+}
+
+- (void)setAllLoadsBlockedByDeviceManagementRestrictionsForTesting:(BOOL)blocked
+{
+ _configuration->setAllLoadsBlockedByDeviceManagementRestrictionsForTesting(blocked);
+}
+
- (API::Object&)_apiObject
{
return *_configuration;
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm (245978 => 245979)
--- trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm 2019-05-31 20:00:07 UTC (rev 245979)
@@ -131,6 +131,8 @@
false,
shouldIncludeLocalhostInResourceLoadStatistics,
enableResourceLoadStatisticsDebugMode,
+ m_configuration->deviceManagementRestrictionsEnabled(),
+ m_configuration->allLoadsBlockedByDeviceManagementRestrictionsForTesting(),
WTFMove(resourceLoadStatisticsManualPrevalentResource),
WTFMove(localStorageDirectory),
WTFMove(localStorageDirectoryExtensionHandle)
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp (245978 => 245979)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp 2019-05-31 20:00:07 UTC (rev 245979)
@@ -39,6 +39,8 @@
{
auto copy = WebsiteDataStoreConfiguration::create();
+ copy->m_isPersistent = this->m_isPersistent;
+
copy->m_cacheStorageDirectory = this->m_cacheStorageDirectory;
copy->m_perOriginStorageQuota = this->m_perOriginStorageQuota;
copy->m_networkCacheDirectory = this->m_networkCacheDirectory;
@@ -59,6 +61,8 @@
copy->m_sourceApplicationSecondaryIdentifier = this->m_sourceApplicationSecondaryIdentifier;
copy->m_httpProxy = this->m_httpProxy;
copy->m_httpsProxy = this->m_httpsProxy;
+ copy->m_deviceManagementRestrictionsEnabled = this->m_deviceManagementRestrictionsEnabled;
+ copy->m_allLoadsBlockedByDeviceManagementRestrictionsForTesting = this->m_allLoadsBlockedByDeviceManagementRestrictionsForTesting;
return copy;
}
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h (245978 => 245979)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h 2019-05-31 20:00:07 UTC (rev 245979)
@@ -38,7 +38,10 @@
Ref<WebsiteDataStoreConfiguration> copy();
- uint64_t perOriginStorageQuota() { return m_perOriginStorageQuota; }
+ bool isPersistent() const { return m_isPersistent; }
+ void setPersistent(bool isPersistent) { m_isPersistent = isPersistent; }
+
+ uint64_t perOriginStorageQuota() const { return m_perOriginStorageQuota; }
void setPerOriginStorageQuota(uint64_t quota) { m_perOriginStorageQuota = quota; }
const String& applicationCacheDirectory() const { return m_applicationCacheDirectory; }
@@ -98,9 +101,17 @@
const URL& httpsProxy() const { return m_httpsProxy; }
void setHTTPSProxy(URL&& proxy) { m_httpsProxy = WTFMove(proxy); }
+ bool deviceManagementRestrictionsEnabled() const { return m_deviceManagementRestrictionsEnabled; }
+ void setDeviceManagementRestrictionsEnabled(bool enabled) { m_deviceManagementRestrictionsEnabled = enabled; }
+
+ bool allLoadsBlockedByDeviceManagementRestrictionsForTesting() const { return m_allLoadsBlockedByDeviceManagementRestrictionsForTesting; }
+ void setAllLoadsBlockedByDeviceManagementRestrictionsForTesting(bool blocked) { m_allLoadsBlockedByDeviceManagementRestrictionsForTesting = blocked; }
+
private:
WebsiteDataStoreConfiguration();
+ bool m_isPersistent { false };
+
String m_cacheStorageDirectory;
uint64_t m_perOriginStorageQuota { WebCore::StorageQuotaManager::defaultQuota() };
String m_networkCacheDirectory;
@@ -121,6 +132,8 @@
String m_sourceApplicationSecondaryIdentifier;
URL m_httpProxy;
URL m_httpsProxy;
+ bool m_deviceManagementRestrictionsEnabled { false };
+ bool m_allLoadsBlockedByDeviceManagementRestrictionsForTesting { false };
};
}
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (245978 => 245979)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2019-05-31 20:00:07 UTC (rev 245979)
@@ -430,6 +430,8 @@
2984F589164BA095004BC0C6 /* LegacyCustomProtocolManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 2984F587164BA095004BC0C6 /* LegacyCustomProtocolManagerMessages.h */; };
29AD3093164B4C5D0072DEA9 /* LegacyCustomProtocolManagerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 29AD3092164B4C5D0072DEA9 /* LegacyCustomProtocolManagerProxy.h */; };
29CD55AA128E294F00133C85 /* WKAccessibilityWebPageObjectBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CD55A8128E294F00133C85 /* WKAccessibilityWebPageObjectBase.h */; };
+ 2D0C56FD229F1DEA00BD33E7 /* DeviceManagementSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D0C56FB229F1DEA00BD33E7 /* DeviceManagementSoftLink.h */; };
+ 2D0C56FE229F1DEA00BD33E7 /* DeviceManagementSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D0C56FC229F1DEA00BD33E7 /* DeviceManagementSoftLink.mm */; };
2D1087611D2C573E00B85F82 /* LoadParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D10875F1D2C573E00B85F82 /* LoadParameters.h */; };
2D11B7512126A282006F8878 /* UnifiedSource1-mm.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D7DEC9421269E4C00B9F73C /* UnifiedSource1-mm.mm */; };
2D11B7522126A282006F8878 /* UnifiedSource1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D7DED5B21269E4D00B9F73C /* UnifiedSource1.cpp */; };
@@ -702,6 +704,7 @@
2DA6731A20C754B1003CB401 /* DynamicViewportSizeUpdate.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DA6731920C754B1003CB401 /* DynamicViewportSizeUpdate.h */; };
2DA944A01884E4F000ED86DB /* WebIOSEventFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DA944991884E4F000ED86DB /* WebIOSEventFactory.h */; };
2DA944A41884E4F000ED86DB /* GestureTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DA9449D1884E4F000ED86DB /* GestureTypes.h */; };
+ 2DAADA8F2298C21000E36B0C /* DeviceManagementSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DAADA8E2298C21000E36B0C /* DeviceManagementSPI.h */; };
2DABA7721A817B1700EF0F1A /* WKPageRenderingProgressEventsInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DABA7711A817B1700EF0F1A /* WKPageRenderingProgressEventsInternal.h */; };
2DABA7741A817EE600EF0F1A /* WKPluginLoadPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DABA7731A817EE600EF0F1A /* WKPluginLoadPolicy.h */; settings = {ATTRIBUTES = (Private, ); }; };
2DABA7761A82B42100EF0F1A /* APIHistoryClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DABA7751A82B42100EF0F1A /* APIHistoryClient.h */; };
@@ -2506,6 +2509,8 @@
29D04E2821F7C73D0076741D /* AccessibilityPrivSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AccessibilityPrivSPI.h; sourceTree = "<group>"; };
2D0035221BC7414800DA8716 /* PDFPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPlugin.h; path = PDF/PDFPlugin.h; sourceTree = "<group>"; };
2D0035231BC7414800DA8716 /* PDFPlugin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPlugin.mm; path = PDF/PDFPlugin.mm; sourceTree = "<group>"; };
+ 2D0C56FB229F1DEA00BD33E7 /* DeviceManagementSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceManagementSoftLink.h; sourceTree = "<group>"; };
+ 2D0C56FC229F1DEA00BD33E7 /* DeviceManagementSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeviceManagementSoftLink.mm; sourceTree = "<group>"; };
2D0CF64B21F2A80300787566 /* TextCheckingController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TextCheckingController.mm; sourceTree = "<group>"; };
2D0CF64C21F2A80300787566 /* TextCheckingController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextCheckingController.h; sourceTree = "<group>"; };
2D10875E1D2C573E00B85F82 /* LoadParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadParameters.cpp; sourceTree = "<group>"; };
@@ -2798,6 +2803,7 @@
2DA944AC1884E9BA00ED86DB /* WebProcessProxyIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebProcessProxyIOS.mm; path = ios/WebProcessProxyIOS.mm; sourceTree = "<group>"; };
2DA944B61884EA3500ED86DB /* WebPageIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebPageIOS.mm; path = ios/WebPageIOS.mm; sourceTree = "<group>"; };
2DA944BC188511E700ED86DB /* NetworkProcessIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkProcessIOS.mm; sourceTree = "<group>"; };
+ 2DAADA8E2298C21000E36B0C /* DeviceManagementSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceManagementSPI.h; sourceTree = "<group>"; };
2DABA7711A817B1700EF0F1A /* WKPageRenderingProgressEventsInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPageRenderingProgressEventsInternal.h; sourceTree = "<group>"; };
2DABA7731A817EE600EF0F1A /* WKPluginLoadPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPluginLoadPolicy.h; sourceTree = "<group>"; };
2DABA7751A82B42100EF0F1A /* APIHistoryClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIHistoryClient.h; sourceTree = "<group>"; };
@@ -6105,6 +6111,7 @@
37C21CAD1E994C0C0029D5F9 /* CorePredictionSPI.h */,
A1FB68261F6E51C100C43F9F /* CrashReporterClientSPI.h */,
57DCEDAA214B9B430016B847 /* DeviceIdentitySPI.h */,
+ 2DAADA8E2298C21000E36B0C /* DeviceManagementSPI.h */,
3754D5441B3A29FD003A4C7F /* NSInvocationSPI.h */,
37B47E2C1D64DB76005F4EFF /* objcSPI.h */,
0E97D74C200E8FF300BF6643 /* SafeBrowsingSPI.h */,
@@ -7136,6 +7143,8 @@
7EC4F0F818E4A922008056AF /* cocoa */ = {
isa = PBXGroup;
children = (
+ 2D0C56FB229F1DEA00BD33E7 /* DeviceManagementSoftLink.h */,
+ 2D0C56FC229F1DEA00BD33E7 /* DeviceManagementSoftLink.mm */,
5315876B2076B713004BF9F3 /* NetworkActivityTrackerCocoa.mm */,
5321594F1DBAE6D70054AA3C /* NetworkDataTaskCocoa.h */,
5CBC9B8B1C65257300A8FDCF /* NetworkDataTaskCocoa.mm */,
@@ -9223,6 +9232,8 @@
BC032DA610F437D10058C15A /* Decoder.h in Headers */,
57DCEDAB214C60090016B847 /* DeviceIdentitySPI.h in Headers */,
07297F9F1C17BBEA015F0735 /* DeviceIdHashSaltStorage.h in Headers */,
+ 2D0C56FD229F1DEA00BD33E7 /* DeviceManagementSoftLink.h in Headers */,
+ 2DAADA8F2298C21000E36B0C /* DeviceManagementSPI.h in Headers */,
83891B6C1A68C30B0030F386 /* DiagnosticLoggingClient.h in Headers */,
C18173612058424700DFDA65 /* DisplayLink.h in Headers */,
5C1427021C23F84C00D41183 /* Download.h in Headers */,
@@ -10982,6 +10993,7 @@
2D92A77D212B6A7100F493FD /* Connection.cpp in Sources */,
2D92A77E212B6A7100F493FD /* DataReference.cpp in Sources */,
2D92A77F212B6A7100F493FD /* Decoder.cpp in Sources */,
+ 2D0C56FE229F1DEA00BD33E7 /* DeviceManagementSoftLink.mm in Sources */,
1AB7D6191288B9D900CFD08C /* DownloadProxyMessageReceiver.cpp in Sources */,
1A64229912DD029200CAAE2C /* DrawingAreaMessageReceiver.cpp in Sources */,
1A64230812DD09EB00CAAE2C /* DrawingAreaProxyMessageReceiver.cpp in Sources */,
Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (245978 => 245979)
--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2019-05-31 20:00:07 UTC (rev 245979)
@@ -335,6 +335,8 @@
loadParameters.isMainFrameNavigation = resourceLoader.frame() && resourceLoader.frame()->isMainFrame() && resourceLoader.options().mode == FetchOptions::Mode::Navigate;
+ loadParameters.isMainResourceNavigationForAnyFrame = resourceLoader.frame() && resourceLoader.options().mode == FetchOptions::Mode::Navigate;
+
loadParameters.shouldEnableCrossOriginResourcePolicy = RuntimeEnabledFeatures::sharedFeatures().crossOriginResourcePolicyEnabled() && !loadParameters.isMainFrameNavigation;
if (resourceLoader.options().mode == FetchOptions::Mode::Navigate) {
Modified: trunk/Tools/ChangeLog (245978 => 245979)
--- trunk/Tools/ChangeLog 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Tools/ChangeLog 2019-05-31 20:00:07 UTC (rev 245979)
@@ -1,3 +1,27 @@
+2019-05-31 Tim Horton <timothy_hor...@apple.com>
+
+ Optionally respect device management restrictions when loading from the network
+ https://bugs.webkit.org/show_bug.cgi?id=198318
+ <rdar://problem/44263806>
+
+ Reviewed by Alex Christensen.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitCocoa/DeviceManagementRestrictions.mm: Added.
+ (TEST):
+ * TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm:
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
+ (TEST):
+ Clone a test that tests non-persistent data stores and ensure
+ that it works if the data store is created via a configuration as well.
+
+ Add a test that ensures that you can't create a data store configuration
+ with an invalid set of options.
+
+ Add a test that device management restrictions (when mocked) correctly
+ fail the load with a new, appropriate error.
+
2019-05-31 Ryan Haddad <ryanhad...@apple.com>
Unreviewed, rolling out r245943.
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (245978 => 245979)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-05-31 20:00:07 UTC (rev 245979)
@@ -96,6 +96,7 @@
2D1C04A71D76298B000A6816 /* TestNavigationDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D1C04A61D76298B000A6816 /* TestNavigationDelegate.mm */; };
2D21FE591F04642900B58E7D /* WKPDFViewStablePresentationUpdateCallback.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D21FE581F04642800B58E7D /* WKPDFViewStablePresentationUpdateCallback.mm */; };
2D2BEB2D22324E5F005544CA /* RequestTextInputContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D2BEB2C22324E5F005544CA /* RequestTextInputContext.mm */; };
+ 2D2D13B3229F408B005068AF /* DeviceManagementRestrictions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D2D13B2229F408B005068AF /* DeviceManagementRestrictions.mm */; };
2D3CA3A8221DF4B40088E803 /* PageOverlayPlugin.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D3CA3A4221DF2390088E803 /* PageOverlayPlugin.mm */; };
2D4CF8BD1D8360CC0001CE8D /* WKThumbnailView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D4CF8BC1D8360CC0001CE8D /* WKThumbnailView.mm */; };
2D51A0C71C8BF00C00765C45 /* DOMHTMLVideoElementWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D51A0C51C8BF00400765C45 /* DOMHTMLVideoElementWrapper.mm */; };
@@ -1476,6 +1477,7 @@
2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FixedLayoutSize.mm; sourceTree = "<group>"; };
2D21FE581F04642800B58E7D /* WKPDFViewStablePresentationUpdateCallback.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPDFViewStablePresentationUpdateCallback.mm; sourceTree = "<group>"; };
2D2BEB2C22324E5F005544CA /* RequestTextInputContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RequestTextInputContext.mm; sourceTree = "<group>"; };
+ 2D2D13B2229F408B005068AF /* DeviceManagementRestrictions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeviceManagementRestrictions.mm; sourceTree = "<group>"; };
2D3CA3A4221DF2390088E803 /* PageOverlayPlugin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageOverlayPlugin.mm; sourceTree = "<group>"; };
2D4CF8BC1D8360CC0001CE8D /* WKThumbnailView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKThumbnailView.mm; path = WebKit/WKThumbnailView.mm; sourceTree = "<group>"; };
2D51A0C51C8BF00400765C45 /* DOMHTMLVideoElementWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMHTMLVideoElementWrapper.mm; sourceTree = "<group>"; };
@@ -2599,6 +2601,7 @@
46A911582108E66B0078D40D /* CustomUserAgent.mm */,
2DC4CF761D2D9DD800ECCC94 /* DataDetection.mm */,
518EE51C20A78D3300E024F3 /* DecidePolicyForNavigationAction.mm */,
+ 2D2D13B2229F408B005068AF /* DeviceManagementRestrictions.mm */,
46918EFB2237283500468DFE /* DeviceOrientation.mm */,
CEA7F57B20895F5B0078EF6E /* DidResignInputElementStrongPasswordAppearance.mm */,
518EE51A20A78CFB00E024F3 /* DoAfterNextPresentationUpdateAfterCrash.mm */,
@@ -4141,6 +4144,7 @@
9BAD7F3E22690F2000F8DA66 /* DeallocWebViewInEventListener.mm in Sources */,
518EE51D20A78D3600E024F3 /* DecidePolicyForNavigationAction.mm in Sources */,
2D1646E21D1862CD00015A1A /* DeferredViewInWindowStateChange.mm in Sources */,
+ 2D2D13B3229F408B005068AF /* DeviceManagementRestrictions.mm in Sources */,
46918EFC2237283C00468DFE /* DeviceOrientation.mm in Sources */,
7CCE7EB91A411A7E00447C4C /* DeviceScaleFactorInDashboardRegions.mm in Sources */,
7CCE7EBA1A411A7E00447C4C /* DeviceScaleFactorOnBack.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DeviceManagementRestrictions.mm (0 => 245979)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DeviceManagementRestrictions.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DeviceManagementRestrictions.mm 2019-05-31 20:00:07 UTC (rev 245979)
@@ -0,0 +1,63 @@
+/*
+ * 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 "Test.h"
+#import "TestNavigationDelegate.h"
+#import "TestWKWebView.h"
+#import <WebKit/WKErrorPrivate.h>
+#import <WebKit/WKWebsiteDataStorePrivate.h>
+#import <WebKit/WebKit.h>
+#import <WebKit/_WKWebsiteDataStoreConfiguration.h>
+#import <wtf/RetainPtr.h>
+
+TEST(WebKit, DeviceManagementRestrictions)
+{
+ RetainPtr<_WKWebsiteDataStoreConfiguration> dataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] initNonPersistentConfiguration]);
+ [dataStoreConfiguration setDeviceManagementRestrictionsEnabled:YES];
+ [dataStoreConfiguration setAllLoadsBlockedByDeviceManagementRestrictionsForTesting:YES];
+
+ RetainPtr<WKWebViewConfiguration> webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [webViewConfiguration setWebsiteDataStore:[[[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration.get()] autorelease]];
+
+ RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectZero configuration:webViewConfiguration.get() addToWindow:YES]);
+
+ RetainPtr<TestNavigationDelegate> delegate = adoptNS([[TestNavigationDelegate alloc] init]);
+ [webView setNavigationDelegate:delegate.get()];
+
+ __block bool done = false;
+ [delegate setDidFailProvisionalNavigation:^(WKWebView *webView, WKNavigation *navigation, NSError *error) {
+ EXPECT_WK_STREQ(_WKLegacyErrorDomain, error.domain);
+ EXPECT_EQ(_WKErrorCodeFrameLoadBlockedByRestrictions, error.code);
+ done = true;
+ }];
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+ [webView loadRequest:request];
+
+ TestWebKitAPI::Util::run(&done);
+}
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm (245978 => 245979)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm 2019-05-31 20:00:07 UTC (rev 245979)
@@ -33,6 +33,7 @@
#import <WebKit/WKWebsiteDataRecordPrivate.h>
#import <WebKit/WKWebsiteDataStorePrivate.h>
#import <WebKit/WebKit.h>
+#import <WebKit/_WKWebsiteDataStoreConfiguration.h>
#import <wtf/text/WTFString.h>
static bool readyToContinue;
@@ -304,4 +305,49 @@
TestWebKitAPI::Util::run(&done);
}
+TEST(WebKit, SettingNonPersistentDataStorePathsThrowsException)
+{
+ auto configuration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] initNonPersistentConfiguration]);
+
+ auto shouldThrowExceptionWhenUsed = [](Function<void(void)>&& modifier) {
+ @try {
+ modifier();
+ EXPECT_TRUE(false);
+ } @catch (NSException *exception) {
+ EXPECT_WK_STREQ(NSInvalidArgumentException, exception.name);
+ }
+ };
+
+ NSURL *fileURL = [NSURL fileURLWithPath:@"/tmp"];
+
+ shouldThrowExceptionWhenUsed([&] {
+ [configuration _setWebStorageDirectory:fileURL];
+ });
+ shouldThrowExceptionWhenUsed([&] {
+ [configuration _setIndexedDBDatabaseDirectory:fileURL];
+ });
+ shouldThrowExceptionWhenUsed([&] {
+ [configuration _setWebSQLDatabaseDirectory:fileURL];
+ });
+ shouldThrowExceptionWhenUsed([&] {
+ [configuration _setCookieStorageFile:fileURL];
+ });
+ shouldThrowExceptionWhenUsed([&] {
+ [configuration _setResourceLoadStatisticsDirectory:fileURL];
+ });
+ shouldThrowExceptionWhenUsed([&] {
+ [configuration _setCacheStorageDirectory:fileURL];
+ });
+ shouldThrowExceptionWhenUsed([&] {
+ [configuration _setServiceWorkerRegistrationDirectory:fileURL];
+ });
+
+ // These properties shouldn't throw exceptions when set on a non-persistent data store.
+ [configuration setDeviceManagementRestrictionsEnabled:YES];
+ [configuration setHTTPProxy:[NSURL URLWithString:@"http://www.apple.com/"]];
+ [configuration setHTTPSProxy:[NSURL URLWithString:@"https://www.apple.com/"]];
+ [configuration setSourceApplicationBundleIdentifier:@"com.apple.Safari"];
+ [configuration setSourceApplicationSecondaryIdentifier:@"com.apple.Safari"];
}
+
+}
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm (245978 => 245979)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm 2019-05-31 19:49:16 UTC (rev 245978)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm 2019-05-31 20:00:07 UTC (rev 245979)
@@ -427,8 +427,54 @@
EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:defaultResourceLoadStatisticsPath.path]);
EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:defaultResourceLoadStatisticsFilePath.path]);
+
+ [[NSFileManager defaultManager] removeItemAtURL:defaultResourceLoadStatisticsPath error:nil];
}
+TEST(WebKit, WebsiteDataStoreEphemeralViaConfiguration)
+{
+ RetainPtr<WebsiteDataStoreCustomPathsMessageHandler> handler = adoptNS([[WebsiteDataStoreCustomPathsMessageHandler alloc] init]);
+ RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"testHandler"];
+
+ NSURL *defaultResourceLoadStatisticsPath = [NSURL fileURLWithPath:[@"~/Library/WebKit/TestWebKitAPI/WebsiteData/ResourceLoadStatistics/" stringByExpandingTildeInPath] isDirectory:YES];
+
+ [[NSFileManager defaultManager] removeItemAtURL:defaultResourceLoadStatisticsPath error:nil];
+
+ EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:defaultResourceLoadStatisticsPath.path]);
+
+ RetainPtr<_WKWebsiteDataStoreConfiguration> dataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] initNonPersistentConfiguration]);
+ configuration.get().websiteDataStore = [[[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration.get()] autorelease];
+ [configuration.get().websiteDataStore _setResourceLoadStatisticsEnabled:YES];
+
+ // We expect the directory to be created by starting up the data store machinery, but not the data file.
+ EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:defaultResourceLoadStatisticsPath.path]);
+
+ NSURL *defaultResourceLoadStatisticsFilePath = [NSURL fileURLWithPath:[@"~/Library/WebKit/TestWebKitAPI/WebsiteData/ResourceLoadStatistics/full_browsing_session_resourceLog.plist" stringByExpandingTildeInPath] isDirectory:NO];
+ EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:defaultResourceLoadStatisticsFilePath.path]);
+
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"WebsiteDataStoreCustomPaths" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+ [webView loadRequest:request];
+
+ [[[webView configuration] processPool] _syncNetworkProcessCookies];
+
+ // Forcibly shut down everything of WebKit that we can.
+ auto pid = [webView _webProcessIdentifier];
+ if (pid)
+ kill(pid, SIGKILL);
+
+ webView = nil;
+ handler = nil;
+ configuration = nil;
+
+ EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:defaultResourceLoadStatisticsPath.path]);
+ EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:defaultResourceLoadStatisticsFilePath.path]);
+
+ [[NSFileManager defaultManager] removeItemAtURL:defaultResourceLoadStatisticsPath error:nil];
+}
+
TEST(WebKit, DoLoadWithNonDefaultDataStoreAfterTerminatingNetworkProcess)
{
auto websiteDataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]);