Diff
Modified: trunk/Source/WebCore/ChangeLog (281776 => 281777)
--- trunk/Source/WebCore/ChangeLog 2021-08-30 21:46:40 UTC (rev 281776)
+++ trunk/Source/WebCore/ChangeLog 2021-08-30 22:06:02 UTC (rev 281777)
@@ -1,3 +1,19 @@
+2021-08-30 Alex Christensen <[email protected]>
+
+ WKWebViewConfiguration._loadsSubresources=NO should prevent preconnecting
+ https://bugs.webkit.org/show_bug.cgi?id=229684
+
+ Reviewed by Tim Horton.
+
+ * Modules/websockets/ThreadableWebSocketChannel.cpp:
+ (WebCore::ThreadableWebSocketChannel::validateURL):
+ * loader/ResourceLoadNotifier.cpp:
+ (WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
+ * page/Page.cpp:
+ (WebCore::Page::allowsLoadFromURL const):
+ * page/Page.h:
+ (WebCore::Page::loadsSubresources const): Deleted.
+
2021-08-30 Lauro Moura <[email protected]>
[LFC][IFC] Remove unused variables after r281744
Modified: trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp (281776 => 281777)
--- trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp 2021-08-30 21:46:40 UTC (rev 281776)
+++ trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp 2021-08-30 22:06:02 UTC (rev 281777)
@@ -90,7 +90,7 @@
{
ValidatedURL validatedURL { requestedURL, true };
if (auto* page = document.page()) {
- if (!page->allowsLoadFromURL(requestedURL))
+ if (!page->allowsLoadFromURL(requestedURL, MainFrameMainResource::No))
return { };
#if ENABLE(CONTENT_EXTENSIONS)
if (auto* documentLoader = document.loader()) {
Modified: trunk/Source/WebCore/loader/ResourceLoadNotifier.cpp (281776 => 281777)
--- trunk/Source/WebCore/loader/ResourceLoadNotifier.cpp 2021-08-30 21:46:40 UTC (rev 281776)
+++ trunk/Source/WebCore/loader/ResourceLoadNotifier.cpp 2021-08-30 22:06:02 UTC (rev 281777)
@@ -138,10 +138,8 @@
m_frame.loader().client().dispatchWillSendRequest(loader, identifier, request, redirectResponse);
if (auto* page = m_frame.page()) {
- if (!page->loadsSubresources()) {
- if (!m_frame.isMainFrame() || (m_initialRequestIdentifier && *m_initialRequestIdentifier != identifier))
- request = { };
- } else if (!page->allowsLoadFromURL(request.url()))
+ auto mainFrameMainResource = m_frame.isMainFrame() && m_initialRequestIdentifier == identifier ? MainFrameMainResource::Yes : MainFrameMainResource::No;
+ if (!page->allowsLoadFromURL(request.url(), mainFrameMainResource))
request = { };
}
Modified: trunk/Source/WebCore/page/Page.cpp (281776 => 281777)
--- trunk/Source/WebCore/page/Page.cpp 2021-08-30 21:46:40 UTC (rev 281776)
+++ trunk/Source/WebCore/page/Page.cpp 2021-08-30 22:06:02 UTC (rev 281777)
@@ -3361,8 +3361,10 @@
#endif
}
-bool Page::allowsLoadFromURL(const URL& url) const
+bool Page::allowsLoadFromURL(const URL& url, MainFrameMainResource mainFrameMainResource) const
{
+ if (mainFrameMainResource == MainFrameMainResource::No && !m_loadsSubresources)
+ return false;
if (!m_allowedNetworkHosts)
return true;
if (!url.protocolIsInHTTPFamily() && !url.protocolIs("ws") && !url.protocolIs("wss"))
Modified: trunk/Source/WebCore/page/Page.h (281776 => 281777)
--- trunk/Source/WebCore/page/Page.h 2021-08-30 21:46:40 UTC (rev 281776)
+++ trunk/Source/WebCore/page/Page.h 2021-08-30 22:06:02 UTC (rev 281777)
@@ -174,6 +174,7 @@
enum class ShouldTreatAsContinuingLoad : uint8_t;
enum class EventThrottlingBehavior : bool { Responsive, Unresponsive };
+enum class MainFrameMainResource : bool { No, Yes };
enum class CompositingPolicy : bool {
Normal,
@@ -815,8 +816,7 @@
bool isOnlyNonUtilityPage() const;
bool isUtilityPage() const { return m_isUtilityPage; }
- bool loadsSubresources() const { return m_loadsSubresources; }
- WEBCORE_EXPORT bool allowsLoadFromURL(const URL&) const;
+ WEBCORE_EXPORT bool allowsLoadFromURL(const URL&, MainFrameMainResource) const;
ShouldRelaxThirdPartyCookieBlocking shouldRelaxThirdPartyCookieBlocking() const { return m_shouldRelaxThirdPartyCookieBlocking; }
bool isLowPowerModeEnabled() const { return m_throttlingReasons.contains(ThrottlingReason::LowPowerMode); }
Modified: trunk/Source/WebKit/ChangeLog (281776 => 281777)
--- trunk/Source/WebKit/ChangeLog 2021-08-30 21:46:40 UTC (rev 281776)
+++ trunk/Source/WebKit/ChangeLog 2021-08-30 22:06:02 UTC (rev 281777)
@@ -1,3 +1,16 @@
+2021-08-30 Alex Christensen <[email protected]>
+
+ WKWebViewConfiguration._loadsSubresources=NO should prevent preconnecting
+ https://bugs.webkit.org/show_bug.cgi?id=229684
+
+ Reviewed by Tim Horton.
+
+ This is like bug 228044 and even uses the same test setup.
+ This should fix rdar://79307070
+
+ * WebProcess/Network/WebLoaderStrategy.cpp:
+ (WebKit::WebLoaderStrategy::preconnectTo):
+
2021-08-30 Sihui Liu <[email protected]>
Add stubs for Permissions API
Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (281776 => 281777)
--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2021-08-30 21:46:40 UTC (rev 281776)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2021-08-30 22:06:02 UTC (rev 281777)
@@ -775,7 +775,7 @@
void WebLoaderStrategy::preconnectTo(WebCore::ResourceRequest&& request, WebPage& webPage, WebFrame& webFrame, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, PreconnectCompletionHandler&& completionHandler)
{
- if (webPage.corePage() && !webPage.corePage()->allowsLoadFromURL(request.url())) {
+ if (webPage.corePage() && !webPage.corePage()->allowsLoadFromURL(request.url(), MainFrameMainResource::No)) {
if (completionHandler)
completionHandler({ });
return;
Modified: trunk/Tools/ChangeLog (281776 => 281777)
--- trunk/Tools/ChangeLog 2021-08-30 21:46:40 UTC (rev 281776)
+++ trunk/Tools/ChangeLog 2021-08-30 22:06:02 UTC (rev 281777)
@@ -1,3 +1,16 @@
+2021-08-30 Alex Christensen <[email protected]>
+
+ WKWebViewConfiguration._loadsSubresources=NO should prevent preconnecting
+ https://bugs.webkit.org/show_bug.cgi?id=229684
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/Preconnect.mm:
+ (TestWebKitAPI::verifyPreconnectDisabled):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebKitCocoa/WebSocket.mm:
+ (TestWebKitAPI::TEST):
+
2021-08-30 Aakash Jain <[email protected]>
ews might mark build as successful if JSC tests fail to run
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Preconnect.mm (281776 => 281777)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Preconnect.mm 2021-08-30 21:46:40 UTC (rev 281776)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Preconnect.mm 2021-08-30 22:06:02 UTC (rev 281777)
@@ -232,7 +232,7 @@
#endif // HAVE(PRECONNECT_PING)
-TEST(Preconnect, DisablePreconnect)
+static void verifyPreconnectDisabled(void(*disabler)(WKWebViewConfiguration *))
{
size_t connectionCount { 0 };
HTTPServer server([&](Connection) {
@@ -242,7 +242,7 @@
{
auto configuration = adoptNS([WKWebViewConfiguration new]);
- configuration.get()._allowedNetworkHosts = [NSSet set];
+ disabler(configuration.get());
auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration.get()]);
[webView loadHTMLString:html baseURL:nil];
[webView _test_waitForDidFinishNavigation];
@@ -261,4 +261,14 @@
}
}
+TEST(Preconnect, DisablePreconnect)
+{
+ verifyPreconnectDisabled([] (WKWebViewConfiguration *configuration) {
+ configuration._allowedNetworkHosts = [NSSet set];
+ });
+ verifyPreconnectDisabled([] (WKWebViewConfiguration *configuration) {
+ configuration._loadsSubresources = NO;
+ });
}
+
+}
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebSocket.mm (281776 => 281777)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebSocket.mm 2021-08-30 21:46:40 UTC (rev 281776)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebSocket.mm 2021-08-30 22:06:02 UTC (rev 281777)
@@ -212,4 +212,29 @@
}
#endif // HAVE(NSURLSESSION_WEBSOCKET)
+TEST(WebSocket, BlockedWithSubresources)
+{
+ HTTPServer server([](Connection connection) {
+ connection.webSocketHandshake();
+ });
+
+ NSString *html = [NSString stringWithFormat:@""
+ "<script>"
+ " var ws = new WebSocket('ws://127.0.0.1:%d/');"
+ " ws._onopen_ = function() { alert('opened successfully'); };"
+ " ws._onerror_ = function(error) { alert('FAIL - error ' + error.message); }"
+ "</script>", server.port()];
+
+ {
+ auto configuration = adoptNS([WKWebViewConfiguration new]);
+ configuration.get()._loadsSubresources = NO;
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration.get()]);
+ [webView loadHTMLString:html baseURL:nil];
+ EXPECT_WK_STREQ([webView _test_waitForAlert], "FAIL - error undefined");
+ }
+ auto webView = adoptNS([WKWebView new]);
+ [webView loadHTMLString:html baseURL:nil];
+ EXPECT_WK_STREQ([webView _test_waitForAlert], "opened successfully");
}
+
+}