Diff
Modified: trunk/Source/WTF/ChangeLog (282880 => 282881)
--- trunk/Source/WTF/ChangeLog 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Source/WTF/ChangeLog 2021-09-22 17:58:45 UTC (rev 282881)
@@ -1,3 +1,17 @@
+2021-09-22 Brady Eidson <beid...@apple.com>
+
+ Disable FTP.
+ <rdar://81193860> and https://bugs.webkit.org/show_bug.cgi?id=230477
+
+ Reviewed by Geoff Garen.
+
+ * Scripts/Preferences/WebPreferencesExperimental.yaml:
+
+ * wtf/URL.cpp:
+ (WTF::URL::protocolIsInFTPFamily const):
+ (WTF::protocolIsInFTPFamily):
+ * wtf/URL.h:
+
2021-09-22 Simon Fraser <simon.fra...@apple.com>
Remove ENABLE(SMOOTH_SCROLLING)
Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (282880 => 282881)
--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml 2021-09-22 17:58:45 UTC (rev 282881)
@@ -421,6 +421,18 @@
WebCore:
default: false
+FTPEnabled:
+ type: bool
+ humanReadableName: "FTP support enabled"
+ humanReadableDescription: "FTP support enabled"
+ defaultValue:
+ WebCore:
+ default: false
+ WebKit:
+ default: false
+ WebKitLegacy:
+ default: false
+
# FIXME: This seems to be accidentally enabled for WebKit1 right now due to the old code using the
# wrong preference key in some places. We should identify whether it really makes sense to keep this
# enabled.
Modified: trunk/Source/WTF/wtf/URL.cpp (282880 => 282881)
--- trunk/Source/WTF/wtf/URL.cpp 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Source/WTF/wtf/URL.cpp 2021-09-22 17:58:45 UTC (rev 282881)
@@ -329,6 +329,11 @@
return WTF::protocolIsJavaScript(string());
}
+bool URL::protocolIsInFTPFamily() const
+{
+ return WTF::protocolIsInFTPFamily(string());
+}
+
bool URL::protocolIs(const char* protocol) const
{
assertProtocolIsGood(protocol);
@@ -856,6 +861,17 @@
return protocolIsInternal(string, "_javascript_");
}
+bool protocolIsInFTPFamily(StringView url)
+{
+ auto length = url.length();
+ // Do the comparison without making a new string object.
+ return length >= 4
+ && isASCIIAlphaCaselessEqual(url[0], 'f')
+ && isASCIIAlphaCaselessEqual(url[1], 't')
+ && isASCIIAlphaCaselessEqual(url[2], 'p')
+ && (url[3] == ':' || (isASCIIAlphaCaselessEqual(url[3], 's') && length >= 5 && url[4] == ':'));
+}
+
bool protocolIsInHTTPFamily(StringView url)
{
auto length = url.length();
Modified: trunk/Source/WTF/wtf/URL.h (282880 => 282881)
--- trunk/Source/WTF/wtf/URL.h 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Source/WTF/wtf/URL.h 2021-09-22 17:58:45 UTC (rev 282881)
@@ -136,6 +136,7 @@
bool protocolIsData() const { return protocolIs("data"); }
WTF_EXPORT_PRIVATE bool protocolIsAbout() const;
WTF_EXPORT_PRIVATE bool protocolIsJavaScript() const;
+ WTF_EXPORT_PRIVATE bool protocolIsInFTPFamily() const;
bool protocolIsInHTTPFamily() const;
WTF_EXPORT_PRIVATE bool isLocalFile() const;
bool cannotBeABaseURL() const { return m_cannotBeABaseURL; }
@@ -259,6 +260,7 @@
WTF_EXPORT_PRIVATE bool protocolIs(StringView url, const char* protocol);
WTF_EXPORT_PRIVATE bool protocolIsJavaScript(StringView url);
+WTF_EXPORT_PRIVATE bool protocolIsInFTPFamily(StringView url);
WTF_EXPORT_PRIVATE bool protocolIsInHTTPFamily(StringView url);
WTF_EXPORT_PRIVATE std::optional<uint16_t> defaultPortForProtocol(StringView protocol);
Modified: trunk/Source/WebKit/ChangeLog (282880 => 282881)
--- trunk/Source/WebKit/ChangeLog 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Source/WebKit/ChangeLog 2021-09-22 17:58:45 UTC (rev 282881)
@@ -1,3 +1,29 @@
+2021-09-22 Brady Eidson <beid...@apple.com>
+
+ Disable FTP.
+ <rdar://81193860> and https://bugs.webkit.org/show_bug.cgi?id=230477
+
+ Reviewed by Geoff Garen.
+
+ Covered by new API tests.
+
+ * NetworkProcess/NetworkLoad.cpp:
+ (WebKit::NetworkLoad::start):
+ (WebKit::NetworkLoad::willPerformHTTPRedirection):
+
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::initializeNetworkProcess):
+ * NetworkProcess/NetworkProcess.h:
+ (WebKit::NetworkProcess::ftpEnabled const):
+
+ * NetworkProcess/NetworkProcessCreationParameters.cpp:
+ (WebKit::NetworkProcessCreationParameters::encode const):
+ (WebKit::NetworkProcessCreationParameters::decode):
+ * NetworkProcess/NetworkProcessCreationParameters.h:
+
+ * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+ (WebKit::WebProcessPool::platformInitializeNetworkProcess):
+
2021-09-22 Megan Gardner <megan_gard...@apple.com>
Build fix for 230521
Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp (282880 => 282881)
--- trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp 2021-09-22 17:58:45 UTC (rev 282881)
@@ -58,8 +58,18 @@
void NetworkLoad::start()
{
- if (m_task)
- m_task->resume();
+ if (!m_task)
+ return;
+
+ if (!m_networkProcess->ftpEnabled() && m_parameters.request.url().protocolIsInFTPFamily()) {
+ m_task->clearClient();
+ m_task = nullptr;
+ WebCore::NetworkLoadMetrics emptyMetrics;
+ didCompleteWithError(ResourceError { errorDomainWebKitInternal, 0, url(), "FTP URLs are disabled"_s, ResourceError::Type::AccessControl }, emptyMetrics);
+ return;
+ }
+
+ m_task->resume();
}
void NetworkLoad::startWithScheduling()
@@ -181,6 +191,17 @@
ASSERT(RunLoop::isMain());
ASSERT(!m_redirectCompletionHandler);
+ if (!m_networkProcess->ftpEnabled() && request.url().protocolIsInFTPFamily()) {
+ m_task->clearClient();
+ m_task = nullptr;
+ WebCore::NetworkLoadMetrics emptyMetrics;
+ didCompleteWithError(ResourceError { errorDomainWebKitInternal, 0, url(), "FTP URLs are disabled"_s, ResourceError::Type::AccessControl }, emptyMetrics);
+
+ if (completionHandler)
+ completionHandler({ });
+ return;
+ }
+
redirectResponse.setSource(ResourceResponse::Source::Network);
m_redirectCompletionHandler = WTFMove(completionHandler);
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (282880 => 282881)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2021-09-22 17:58:45 UTC (rev 282881)
@@ -346,6 +346,7 @@
setPrivateClickMeasurementEnabled(parameters.enablePrivateClickMeasurement);
setPrivateClickMeasurementDebugMode(parameters.enablePrivateClickMeasurementDebugMode);
+ m_ftpEnabled = parameters.ftpEnabled;
for (auto& supplement : m_supplements.values())
supplement->initialize(parameters);
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (282880 => 282881)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2021-09-22 17:58:45 UTC (rev 282881)
@@ -390,6 +390,8 @@
RTCDataChannelRemoteManagerProxy& rtcDataChannelProxy();
#endif
+ bool ftpEnabled() const { return m_ftpEnabled; }
+
private:
void platformInitializeNetworkProcess(const NetworkProcessCreationParameters&);
@@ -615,6 +617,7 @@
bool m_privateClickMeasurementEnabled { true };
bool m_privateClickMeasurementDebugModeEnabled { false };
+ bool m_ftpEnabled { false };
HashMap<PAL::SessionID, Ref<NetworkStorageManager>> m_storageManagers;
};
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp (282880 => 282881)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp 2021-09-22 17:58:45 UTC (rev 282881)
@@ -72,6 +72,7 @@
encoder << enablePrivateClickMeasurement;
encoder << enablePrivateClickMeasurementDebugMode;
+ encoder << ftpEnabled;
encoder << websiteDataStoreParameters;
}
@@ -146,6 +147,8 @@
return false;
if (!decoder.decode(result.enablePrivateClickMeasurementDebugMode))
return false;
+ if (!decoder.decode(result.ftpEnabled))
+ return false;
std::optional<Vector<WebsiteDataStoreParameters>> websiteDataStoreParameters;
decoder >> websiteDataStoreParameters;
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h (282880 => 282881)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h 2021-09-22 17:58:45 UTC (rev 282881)
@@ -88,6 +88,7 @@
bool enablePrivateClickMeasurement { true };
bool enablePrivateClickMeasurementDebugMode { false };
+ bool ftpEnabled { false };
Vector<WebsiteDataStoreParameters> websiteDataStoreParameters;
};
Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (282880 => 282881)
--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp 2021-09-22 17:58:45 UTC (rev 282881)
@@ -347,7 +347,8 @@
else
m_networkLoad->startWithScheduling();
- LOADER_RELEASE_LOG("startNetworkLoad: Going to the network (description=%" PUBLIC_LOG_STRING ")", m_networkLoad->description().utf8().data());
+ if (m_networkLoad)
+ LOADER_RELEASE_LOG("startNetworkLoad: Going to the network (description=%" PUBLIC_LOG_STRING ")", m_networkLoad->description().utf8().data());
}
ResourceLoadInfo NetworkResourceLoader::resourceLoadInfo()
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (282880 => 282881)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2021-09-22 17:58:45 UTC (rev 282881)
@@ -567,6 +567,8 @@
NSString *format = @"WebKitExperimental%@";
#endif
parameters.enablePrivateClickMeasurementDebugMode = [defaults boolForKey:[NSString stringWithFormat:format, WebPreferencesKey::privateClickMeasurementDebugModeEnabledKey().createCFString().get()]];
+
+ parameters.ftpEnabled = [defaults objectForKey:WebPreferencesKey::ftpEnabledKey()] && [defaults boolForKey:WebPreferencesKey::ftpEnabledKey()];
}
void WebProcessPool::platformInvalidateContext()
Modified: trunk/Tools/ChangeLog (282880 => 282881)
--- trunk/Tools/ChangeLog 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Tools/ChangeLog 2021-09-22 17:58:45 UTC (rev 282881)
@@ -1,3 +1,25 @@
+2021-09-22 Brady Eidson <beid...@apple.com>
+
+ Disable FTP.
+ <rdar://81193860> and https://bugs.webkit.org/show_bug.cgi?id=230477
+
+ Reviewed by Geoff Garen.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+
+ * TestWebKitAPI/Tests/WebKitCocoa/BundlePageConsoleMessage.mm: Added.
+ (willAddMessageToConsoleCallback):
+ (-[BundlePageConsoleMessage webProcessPlugIn:didCreateBrowserContextController:]):
+
+ * TestWebKitAPI/Tests/WebKitCocoa/FTP.mm: Added.
+ (TestWebKitAPI::didReceivePageMessageFromInjectedBundle):
+ (TestWebKitAPI::setInjectedBundleClient):
+ (TestWebKitAPI::TEST):
+
+ * TestWebKitAPI/PlatformUtilities.h:
+ * TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm:
+ (TestWebKitAPI::Util::toNS):
+
2021-09-22 Philippe Normand <pnorm...@igalia.com>
[Flatpak SDK] Switch runtime to 21.08 SDK
Modified: trunk/Tools/TestWebKitAPI/PlatformUtilities.h (282880 => 282881)
--- trunk/Tools/TestWebKitAPI/PlatformUtilities.h 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Tools/TestWebKitAPI/PlatformUtilities.h 2021-09-22 17:58:45 UTC (rev 282881)
@@ -66,6 +66,11 @@
std::string toSTD(WKStringRef);
std::string toSTD(WKRetainPtr<WKStringRef>);
+#if PLATFORM(MAC)
+NSString *toNS(WKStringRef);
+NSString *toNS(WKRetainPtr<WKStringRef>);
+#endif // PLATFORM(MAC)
+
WKRetainPtr<WKStringRef> toWK(const char* utf8String);
#endif // WK_HAVE_C_SPI
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (282880 => 282881)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-09-22 17:58:45 UTC (rev 282881)
@@ -348,7 +348,9 @@
51714EB41CF8C78C004723C4 /* WebProcessKillIDBCleanup-1.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51714EB21CF8C761004723C4 /* WebProcessKillIDBCleanup-1.html */; };
51714EB51CF8C78C004723C4 /* WebProcessKillIDBCleanup-2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51714EB31CF8C761004723C4 /* WebProcessKillIDBCleanup-2.html */; };
51714EB81CF8CA17004723C4 /* WebProcessKillIDBCleanup.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51714EB61CF8C7A4004723C4 /* WebProcessKillIDBCleanup.mm */; };
+ 5175C7A226F876230003AF5C /* BundlePageConsoleMessage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5175C7A126F876230003AF5C /* BundlePageConsoleMessage.mm */; };
517E7E04151119C100D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */; };
+ 51819F2A26EAC98300E47375 /* FTP.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51819F2926EAC98200E47375 /* FTP.mm */; };
51820A4D22F4EE7F00DF0A01 /* _javascript_URLNavigation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51820A4C22F4EE7700DF0A01 /* _javascript_URLNavigation.mm */; };
5182C22E1F2BCE540059BA7C /* WKURLSchemeHandler-leaks.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5182C22D1F2BCB410059BA7C /* WKURLSchemeHandler-leaks.mm */; };
518C1153205B0504001FF4AE /* ProcessSwapOnNavigation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 518C1152205B04F9001FF4AE /* ProcessSwapOnNavigation.mm */; };
@@ -2194,8 +2196,10 @@
51714EB31CF8C761004723C4 /* WebProcessKillIDBCleanup-2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "WebProcessKillIDBCleanup-2.html"; sourceTree = "<group>"; };
51714EB61CF8C7A4004723C4 /* WebProcessKillIDBCleanup.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessKillIDBCleanup.mm; sourceTree = "<group>"; };
51714EB91D087416004723C4 /* CrossThreadTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CrossThreadTask.cpp; sourceTree = "<group>"; };
+ 5175C7A126F876230003AF5C /* BundlePageConsoleMessage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BundlePageConsoleMessage.mm; sourceTree = "<group>"; };
517E7DFB15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCachePruneWithinResourceLoadDelegate.mm; sourceTree = "<group>"; };
517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = MemoryCachePruneWithinResourceLoadDelegate.html; sourceTree = "<group>"; };
+ 51819F2926EAC98200E47375 /* FTP.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FTP.mm; sourceTree = "<group>"; };
51820A4C22F4EE7700DF0A01 /* _javascript_URLNavigation.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = _javascript_URLNavigation.mm; sourceTree = "<group>"; };
5182C22D1F2BCB410059BA7C /* WKURLSchemeHandler-leaks.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = "WKURLSchemeHandler-leaks.mm"; sourceTree = "<group>"; };
518C1152205B04F9001FF4AE /* ProcessSwapOnNavigation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProcessSwapOnNavigation.mm; sourceTree = "<group>"; };
@@ -3435,6 +3439,7 @@
7A89BB652331635D0042CB1E /* BundleFormDelegate.mm */,
7A89BB662331635D0042CB1E /* BundleFormDelegatePlugIn.mm */,
7A89BB69233165650042CB1E /* BundleFormDelegateProtocol.h */,
+ 5175C7A126F876230003AF5C /* BundlePageConsoleMessage.mm */,
A13EBBAC1B87436F00097110 /* BundleParameters.mm */,
A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */,
37A709AD1E3EA8B000CA5969 /* BundleRangeHandle.mm */,
@@ -3486,6 +3491,7 @@
6B25A75125DC8D4E0070744F /* EventAttribution.mm */,
CDA29B2820FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm */,
1D12BEBF245BEF85004C0B7A /* ExitPiPOnSuspendVideoElement.mm */,
+ 51819F2926EAC98200E47375 /* FTP.mm */,
2D8104CB1BEC13E70020DA46 /* FindInPage.mm */,
51242CD42374E61E00EED9C1 /* FindInPageAPI.mm */,
118153472208BADF00B2CCD2 /* FirstVisuallyNonEmptyMilestone.mm */,
@@ -5836,6 +5842,7 @@
7CCE7F141A411AE600447C4C /* ShouldKeepCurrentBackForwardListItemInList.cpp in Sources */,
37BCA61C1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm in Sources */,
7C83E0C51D0A654600FEBCF3 /* ShrinkToFit.mm in Sources */,
+ 51819F2A26EAC98300E47375 /* FTP.mm in Sources */,
7CCE7ECD1A411A7E00447C4C /* SimplifyMarkup.mm in Sources */,
C149D550242E98DF003EBB12 /* SleepDisabler.mm in Sources */,
2DFF7B6D1DA487AF00814614 /* SnapshotStore.mm in Sources */,
@@ -6072,6 +6079,7 @@
2D3CA3A8221DF4B40088E803 /* PageOverlayPlugin.mm in Sources */,
F44C7A0020F9EEBF0014478C /* ParserYieldTokenPlugIn.mm in Sources */,
A13EBBAB1B87434600097110 /* PlatformUtilitiesCocoa.mm in Sources */,
+ 5175C7A226F876230003AF5C /* BundlePageConsoleMessage.mm in Sources */,
1A4F81CF1BDFFD53004E672E /* RemoteObjectRegistryPlugIn.mm in Sources */,
A12DDC021E837C2400CF6CAE /* RenderedImageWithOptionsPlugIn.mm in Sources */,
5245178721B9F57B0082CB34 /* RenderingProgressPlugIn.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundlePageConsoleMessage.mm (0 => 282881)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundlePageConsoleMessage.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundlePageConsoleMessage.mm 2021-09-22 17:58:45 UTC (rev 282881)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2021 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 PLATFORM(MAC)
+
+#import <WebKit/WKBundlePage.h>
+#import <WebKit/WKBundlePageUIClient.h>
+#import <WebKit/WKRetainPtr.h>
+#import <WebKit/WKWebProcessPlugIn.h>
+#import <WebKit/WKWebProcessPlugInBrowserContextControllerPrivate.h>
+
+void willAddMessageToConsoleCallback(WKBundlePageRef page, WKStringRef message, uint32_t lineNumber, const void *)
+{
+ WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("ConsoleMessage"));
+ WKBundlePagePostMessage(page, messageName.get(), message);
+}
+
+@interface BundlePageConsoleMessage : NSObject <WKWebProcessPlugIn>
+@end
+
+@implementation BundlePageConsoleMessage
+
+- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController
+{
+ WKBundlePageUIClientV4 client;
+ memset(&client, 0, sizeof(client));
+ client.base.version = 4;
+ client.willAddMessageToConsole = willAddMessageToConsoleCallback;
+ WKBundlePageSetUIClient([browserContextController _bundlePageRef], &client.base);
+}
+
+@end
+
+#endif // PLATFORM(MAC)
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FTP.mm (0 => 282881)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FTP.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FTP.mm 2021-09-22 17:58:45 UTC (rev 282881)
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2021 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 PLATFORM(MAC)
+
+#import "HTTPServer.h"
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import "TestNavigationDelegate.h"
+#import "TestWKWebView.h"
+#import "WKWebViewConfigurationExtras.h"
+#import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebViewPrivateForTesting.h>
+#import <WebKit/WKWebpagePreferencesPrivate.h>
+#import <WebKit/WebKit.h>
+#import <wtf/text/WTFString.h>
+
+namespace TestWebKitAPI {
+
+static RetainPtr<NSMutableArray> consoleMessages;
+
+static void didReceivePageMessageFromInjectedBundle(WKPageRef, WKStringRef messageName, WKTypeRef message, const void*)
+{
+ if (WKStringIsEqualToUTF8CString(messageName, "ConsoleMessage"))
+ [consoleMessages addObject:Util::toNS((WKStringRef)message)];
+}
+
+static void setInjectedBundleClient(WKWebView *webView)
+{
+ WKPageInjectedBundleClientV0 injectedBundleClient = {
+ { 0, nullptr },
+ didReceivePageMessageFromInjectedBundle,
+ nullptr,
+ };
+ WKPageSetPageInjectedBundleClient(webView._pageRefForTransitionToWKWebView, &injectedBundleClient.base);
+}
+
+TEST(WKWebView, FTPMainResource)
+{
+ WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"BundlePageConsoleMessage"];
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration]);
+ setInjectedBundleClient(webView.get());
+
+ consoleMessages = [NSMutableArray arrayWithCapacity:2];
+
+ [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"ftp://example.com/main.html"]]];
+ [webView _test_waitForDidFailProvisionalNavigation];
+
+ EXPECT_EQ([consoleMessages count], 1u);
+ EXPECT_TRUE([consoleMessages.get()[0] isEqualToString:@"FTP URLs are disabled"]);
+}
+
+TEST(WKWebView, FTPMainResourceRedirect)
+{
+ HTTPServer httpServer({
+ { "/ftp_redirect", { 301, {{ "Location", "ftp://example.com/" }} } },
+ });
+
+ WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"BundlePageConsoleMessage"];
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration]);
+ setInjectedBundleClient(webView.get());
+
+ consoleMessages = [NSMutableArray arrayWithCapacity:2];
+
+ [webView loadRequest:httpServer.request("/ftp_redirect")];
+ [webView _test_waitForDidFailProvisionalNavigation];
+
+ EXPECT_EQ([consoleMessages count], 1u);
+ EXPECT_TRUE([consoleMessages.get()[0] isEqualToString:@"FTP URLs are disabled"]);
+}
+
+
+static const char* subresourceBytes = R"FTPRESOURCE(
+Hello
+<img src=""
+Goodbye
+)FTPRESOURCE";
+
+TEST(WKWebView, FTPSubresource)
+{
+ WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"BundlePageConsoleMessage"];
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration]);
+ setInjectedBundleClient(webView.get());
+
+ consoleMessages = [NSMutableArray arrayWithCapacity:2];
+ [webView synchronouslyLoadHTMLString:[NSString stringWithUTF8String:subresourceBytes]];
+
+ EXPECT_EQ([consoleMessages count], 2u);
+ EXPECT_TRUE([consoleMessages.get()[0] isEqualToString:@"FTP URLs are disabled"]);
+ EXPECT_TRUE([consoleMessages.get()[1] isEqualToString:@"Cannot load image ftp://example.com/webkitten.png due to access control checks."]);
+}
+
+// Redirect from HTTP to FTP already fails, but let's make sure it keeps failing
+TEST(WKWebView, FTPSubresourceRedirect)
+{
+ HTTPServer httpServer({
+ { "/webkitten.png", { 301, {{ "Location", "ftp://example.com/webkitten.png" }} } },
+ });
+
+ WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"BundlePageConsoleMessage"];
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration]);
+
+ // Allow HTTP to redirect away from HTTP for subresources for the purposes of this test
+ auto preferences = (__bridge WKPreferencesRef)[[webView configuration] preferences];
+ WKPreferencesSetRestrictedHTTPResponseAccess(preferences, false);
+
+ setInjectedBundleClient(webView.get());
+
+ consoleMessages = [NSMutableArray arrayWithCapacity:2];
+
+ auto htmlString = makeString("<img src=''>");
+ [webView synchronouslyLoadHTMLString:[NSString stringWithUTF8String:htmlString.utf8().data()]];
+
+ EXPECT_EQ([consoleMessages count], 2u);
+ EXPECT_TRUE([consoleMessages.get()[0] isEqualToString:@"FTP URLs are disabled"]);
+}
+
+} // namespace TestWebKitAPI
+
+#endif // PLATFORM(MAC)
Modified: trunk/Tools/TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm (282880 => 282881)
--- trunk/Tools/TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm 2021-09-22 17:19:36 UTC (rev 282880)
+++ trunk/Tools/TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm 2021-09-22 17:58:45 UTC (rev 282881)
@@ -33,6 +33,25 @@
namespace TestWebKitAPI {
namespace Util {
+#if PLATFORM(MAC)
+
+NSString *toNS(WKStringRef string)
+{
+ size_t bufferSize = WKStringGetMaximumUTF8CStringSize(string) + 1;
+ auto buffer = makeUniqueWithoutFastMallocCheck<char[]>(bufferSize);
+ size_t stringLength = WKStringGetUTF8CString(string, buffer.get(), bufferSize);
+ buffer[stringLength] = '\0';
+
+ return [NSString stringWithUTF8String:buffer.get()];
+}
+
+NSString *toNS(WKRetainPtr<WKStringRef> string)
+{
+ return toNS(string.get());
+}
+
+#endif // PLATFORM(MAC)
+
std::string toSTD(NSString *string)
{
if (!string)