Diff
Modified: trunk/Source/WebCore/ChangeLog (287039 => 287040)
--- trunk/Source/WebCore/ChangeLog 2021-12-14 20:06:12 UTC (rev 287039)
+++ trunk/Source/WebCore/ChangeLog 2021-12-14 20:11:03 UTC (rev 287040)
@@ -1,3 +1,21 @@
+2021-12-14 Alex Christensen <achristen...@webkit.org>
+
+ Add _WKContentRuleListAction.redirected and .modifiedHeaders
+ https://bugs.webkit.org/show_bug.cgi?id=234289
+
+ Reviewed by Tim Hatcher.
+
+ These inform the UI process about new actions taken by the extension.
+
+ * contentextensions/ContentExtensionsBackend.cpp:
+ (WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForLoad):
+ (WebCore::ContentExtensions::applyResultsToRequest):
+ * contentextensions/ContentRuleListResults.h:
+ (WebCore::ContentRuleListResults::shouldNotifyApplication const):
+ (WebCore::ContentRuleListResults::Result::encode const):
+ (WebCore::ContentRuleListResults::Result::decode):
+ (WebCore::ContentRuleListResults::Result::shouldNotifyApplication const): Deleted.
+
2021-12-14 Tyler Wilcock <tyle...@apple.com>
Web Inspector: test webpage keeps reloading when Inspector is open
Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (287039 => 287040)
--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp 2021-12-14 20:06:12 UTC (rev 287039)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp 2021-12-14 20:11:03 UTC (rev 287040)
@@ -248,11 +248,15 @@
}, [&](const IgnorePreviousRulesAction&) {
RELEASE_ASSERT_NOT_REACHED();
}, [&] (const ModifyHeadersAction& action) {
- if (initiatingDocumentLoader.allowsActiveContentRuleListActionsForURL(contentRuleListIdentifier, url))
+ if (initiatingDocumentLoader.allowsActiveContentRuleListActionsForURL(contentRuleListIdentifier, url)) {
+ result.modifiedHeaders = true;
results.summary.modifyHeadersActions.append(action);
+ }
}, [&] (const RedirectAction& redirectAction) {
- if (initiatingDocumentLoader.allowsActiveContentRuleListActionsForURL(contentRuleListIdentifier, url))
+ if (initiatingDocumentLoader.allowsActiveContentRuleListActionsForURL(contentRuleListIdentifier, url)) {
+ result.redirected = true;
results.summary.redirectActions.append({ redirectAction, m_contentExtensions.get(contentRuleListIdentifier)->extensionBaseURL() });
+ }
}), action.data());
}
Modified: trunk/Source/WebCore/contentextensions/ContentRuleListResults.h (287039 => 287040)
--- trunk/Source/WebCore/contentextensions/ContentRuleListResults.h 2021-12-14 20:06:12 UTC (rev 287039)
+++ trunk/Source/WebCore/contentextensions/ContentRuleListResults.h 2021-12-14 20:11:03 UTC (rev 287040)
@@ -39,6 +39,8 @@
bool blockedLoad { false };
bool madeHTTPS { false };
bool blockedCookies { false };
+ bool modifiedHeaders { false };
+ bool redirected { false };
Vector<String> notifications;
bool shouldNotifyApplication() const
@@ -46,6 +48,8 @@
return blockedLoad
|| madeHTTPS
|| blockedCookies
+ || modifiedHeaders
+ || redirected
|| !notifications.isEmpty();
}
@@ -73,6 +77,8 @@
return summary.blockedLoad
|| summary.madeHTTPS
|| summary.blockedCookies
+ || !summary.modifyHeadersActions.isEmpty()
+ || !summary.redirectActions.isEmpty()
|| summary.hasNotifications;
}
@@ -105,6 +111,8 @@
encoder << blockedLoad;
encoder << madeHTTPS;
encoder << blockedCookies;
+ encoder << modifiedHeaders;
+ encoder << redirected;
encoder << notifications;
}
@@ -125,6 +133,16 @@
if (!blockedCookies)
return std::nullopt;
+ std::optional<bool> modifiedHeaders;
+ decoder >> modifiedHeaders;
+ if (!modifiedHeaders)
+ return std::nullopt;
+
+ std::optional<bool> redirected;
+ decoder >> redirected;
+ if (!redirected)
+ return std::nullopt;
+
std::optional<Vector<String>> notifications;
decoder >> notifications;
if (!notifications)
@@ -134,6 +152,8 @@
WTFMove(*blockedLoad),
WTFMove(*madeHTTPS),
WTFMove(*blockedCookies),
+ WTFMove(*modifiedHeaders),
+ WTFMove(*redirected),
WTFMove(*notifications)
}};
}
Modified: trunk/Source/WebKit/ChangeLog (287039 => 287040)
--- trunk/Source/WebKit/ChangeLog 2021-12-14 20:06:12 UTC (rev 287039)
+++ trunk/Source/WebKit/ChangeLog 2021-12-14 20:11:03 UTC (rev 287040)
@@ -1,5 +1,23 @@
2021-12-14 Alex Christensen <achristen...@webkit.org>
+ Add _WKContentRuleListAction.redirected and .modifiedHeaders
+ https://bugs.webkit.org/show_bug.cgi?id=234289
+
+ Reviewed by Tim Hatcher.
+
+ * UIProcess/API/APIContentRuleListAction.cpp:
+ (API::ContentRuleListAction::redirected const):
+ (API::ContentRuleListAction::modifiedHeaders const):
+ * UIProcess/API/APIContentRuleListAction.h:
+ * UIProcess/API/Cocoa/_WKContentRuleListAction.h:
+ * UIProcess/API/Cocoa/_WKContentRuleListAction.mm:
+ (-[_WKContentRuleListAction redirected]):
+ (-[_WKContentRuleListAction modifiedHeaders]):
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::contentRuleListNotification):
+
+2021-12-14 Alex Christensen <achristen...@webkit.org>
+
Move FTP disabling from NetworkLoad::start to NetworkDataTask::NetworkDataTask
https://bugs.webkit.org/show_bug.cgi?id=234280
<rdar://85015428>
Modified: trunk/Source/WebKit/UIProcess/API/APIContentRuleListAction.cpp (287039 => 287040)
--- trunk/Source/WebKit/UIProcess/API/APIContentRuleListAction.cpp 2021-12-14 20:06:12 UTC (rev 287039)
+++ trunk/Source/WebKit/UIProcess/API/APIContentRuleListAction.cpp 2021-12-14 20:11:03 UTC (rev 287040)
@@ -57,6 +57,16 @@
return m_result.blockedCookies;
}
+bool ContentRuleListAction::redirected() const
+{
+ return m_result.redirected;
+}
+
+bool ContentRuleListAction::modifiedHeaders() const
+{
+ return m_result.modifiedHeaders;
+}
+
const Vector<WTF::String>& ContentRuleListAction::notifications() const
{
return m_result.notifications;
Modified: trunk/Source/WebKit/UIProcess/API/APIContentRuleListAction.h (287039 => 287040)
--- trunk/Source/WebKit/UIProcess/API/APIContentRuleListAction.h 2021-12-14 20:06:12 UTC (rev 287039)
+++ trunk/Source/WebKit/UIProcess/API/APIContentRuleListAction.h 2021-12-14 20:11:03 UTC (rev 287040)
@@ -40,6 +40,8 @@
bool blockedLoad() const;
bool madeHTTPS() const;
bool blockedCookies() const;
+ bool redirected() const;
+ bool modifiedHeaders() const;
const Vector<WTF::String>& notifications() const;
private:
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKContentRuleListAction.h (287039 => 287040)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKContentRuleListAction.h 2021-12-14 20:06:12 UTC (rev 287039)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKContentRuleListAction.h 2021-12-14 20:11:03 UTC (rev 287040)
@@ -32,6 +32,8 @@
@property (nonatomic, readonly) BOOL blockedLoad;
@property (nonatomic, readonly) BOOL blockedCookies;
@property (nonatomic, readonly) BOOL madeHTTPS;
+@property (nonatomic, readonly) BOOL redirected WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, readonly) BOOL modifiedHeaders WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
@property (nonatomic, readonly, copy) NSArray<NSString *> *notifications;
@end
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKContentRuleListAction.mm (287039 => 287040)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKContentRuleListAction.mm 2021-12-14 20:06:12 UTC (rev 287039)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKContentRuleListAction.mm 2021-12-14 20:11:03 UTC (rev 287040)
@@ -68,6 +68,24 @@
#endif
}
+- (BOOL)redirected
+{
+#if ENABLE(CONTENT_EXTENSIONS)
+ return _action->redirected();
+#else
+ return NO;
+#endif
+}
+
+- (BOOL)modifiedHeaders
+{
+#if ENABLE(CONTENT_EXTENSIONS)
+ return _action->modifiedHeaders();
+#else
+ return NO;
+#endif
+}
+
- (NSArray<NSString *> *)notifications
{
#if ENABLE(CONTENT_EXTENSIONS)
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (287039 => 287040)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2021-12-14 20:06:12 UTC (rev 287039)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2021-12-14 20:11:03 UTC (rev 287040)
@@ -1002,7 +1002,6 @@
void WebChromeClient::contentRuleListNotification(const URL& url, const ContentRuleListResults& results)
{
#if ENABLE(CONTENT_EXTENSIONS)
- ASSERT(results.shouldNotifyApplication());
m_page.send(Messages::WebPageProxy::ContentRuleListNotification(url, results));
#endif
}
Modified: trunk/Tools/ChangeLog (287039 => 287040)
--- trunk/Tools/ChangeLog 2021-12-14 20:06:12 UTC (rev 287039)
+++ trunk/Tools/ChangeLog 2021-12-14 20:11:03 UTC (rev 287040)
@@ -1,5 +1,19 @@
2021-12-14 Alex Christensen <achristen...@webkit.org>
+ Add _WKContentRuleListAction.redirected and .modifiedHeaders
+ https://bugs.webkit.org/show_bug.cgi?id=234289
+
+ Reviewed by Tim Hatcher.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm:
+ (checkURLs):
+ (TEST_F):
+ * TestWebKitAPI/cocoa/TestNavigationDelegate.h:
+ * TestWebKitAPI/cocoa/TestNavigationDelegate.mm:
+ (-[TestNavigationDelegate _webView:contentRuleListWithIdentifier:performedAction:forURL:]):
+
+2021-12-14 Alex Christensen <achristen...@webkit.org>
+
Move FTP disabling from NetworkLoad::start to NetworkDataTask::NetworkDataTask
https://bugs.webkit.org/show_bug.cgi?id=234280
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm (287039 => 287040)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm 2021-12-14 20:06:12 UTC (rev 287039)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm 2021-12-14 20:11:03 UTC (rev 287040)
@@ -34,10 +34,12 @@
#import <WebKit/WKContentRuleListStorePrivate.h>
#import <WebKit/WKUserContentControllerPrivate.h>
#import <WebKit/WKWebpagePreferencesPrivate.h>
+#import <WebKit/_WKContentRuleListAction.h>
#import <WebKit/_WKUserContentExtensionStore.h>
#import <WebKit/_WKUserContentFilter.h>
#import <wtf/RetainPtr.h>
#import <wtf/Vector.h>
+#import <wtf/text/WTFString.h>
class WKContentRuleListStoreTest : public testing::Test {
public:
@@ -505,6 +507,13 @@
return delegate;
}
+static void checkURLs(const Vector<String>& actual, const Vector<String>& expected)
+{
+ EXPECT_EQ(actual.size(), expected.size());
+ for (size_t i = 0; i < std::min(actual.size(), expected.size()); i++)
+ EXPECT_WK_STREQ(actual[i], expected[i]);
+}
+
TEST_F(WKContentRuleListStoreTest, ModifyHeaders)
{
auto list = compileContentRuleList(R"JSON(
@@ -562,9 +571,22 @@
[[configuration userContentController] addContentRuleList:list.get()];
[configuration setURLSchemeHandler:handler.get() forURLScheme:@"testscheme"];
auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSZeroRect configuration:configuration.get()]);
- webView.get().navigationDelegate = navigationDelegateAllowingActiveActionsOnTestHost().get();
+ auto delegate = navigationDelegateAllowingActiveActionsOnTestHost().get();
+ webView.get().navigationDelegate = delegate;
+ __block bool receivedActionNotification { false };
+ __block Vector<String> urls;
+ delegate.contentRuleListPerformedAction = ^(WKWebView *, NSString *identifier, _WKContentRuleListAction *action, NSURL *url) {
+ urls.append(url.absoluteString);
+ EXPECT_TRUE(action.modifiedHeaders);
+ receivedActionNotification = true;
+ };
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"testscheme://testhost/main.html"]]];
TestWebKitAPI::Util::run(&receivedAllRequests);
+ TestWebKitAPI::Util::run(&receivedActionNotification);
+ checkURLs(urls, {
+ "testscheme://testhost/main.html",
+ "testscheme://testhost/fetch.txt"
+ });
// FIXME: Appending to the User-Agent replaces the user agent because we haven't added the user agent yet when processing the request.
}
@@ -667,11 +689,21 @@
[configuration setURLSchemeHandler:handler.get() forURLScheme:@"testscheme"];
[configuration setURLSchemeHandler:handler.get() forURLScheme:@"othertestscheme"];
auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSZeroRect configuration:configuration.get()]);
- webView.get().navigationDelegate = navigationDelegateAllowingActiveActionsOnTestHost().get();
+ auto delegate = navigationDelegateAllowingActiveActionsOnTestHost().get();
+ webView.get().navigationDelegate = delegate;
+ __block bool receivedActionNotification { false };
+ __block Vector<String> urlsFromCallback;
+ delegate.contentRuleListPerformedAction = ^(WKWebView *, NSString *identifier, _WKContentRuleListAction *action, NSURL *url) {
+ urlsFromCallback.append(url.absoluteString);
+ EXPECT_TRUE(action.redirected);
+ receivedActionNotification = true;
+ };
+
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"testscheme://testhost/main.html"]]];
TestWebKitAPI::Util::run(&receivedAllRequests);
+ TestWebKitAPI::Util::run(&receivedActionNotification);
- Vector<const char*> expectedRequestedURLs {
+ Vector<String> expectedRequestedURLs {
"testscheme://testhost/main.html",
"othertestscheme://not-testhost/1-redirected.txt",
"testscheme://not-testhost-should-not-trigger-action/2.txt",
@@ -685,6 +717,10 @@
EXPECT_EQ(expectedRequestedURLs.size(), [urls count]);
for (size_t i = 0; i < expectedRequestedURLs.size(); i++)
EXPECT_WK_STREQ(expectedRequestedURLs[i], [[urls objectAtIndex:i] absoluteString]);
+
+ expectedRequestedURLs.remove(0);
+ expectedRequestedURLs[1] = "testscheme://testhost:123/2.txt";
+ checkURLs(urlsFromCallback, expectedRequestedURLs);
}
TEST_F(WKContentRuleListStoreTest, NullPatternSet)
Modified: trunk/Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.h (287039 => 287040)
--- trunk/Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.h 2021-12-14 20:06:12 UTC (rev 287039)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.h 2021-12-14 20:11:03 UTC (rev 287040)
@@ -26,6 +26,8 @@
#import <WebKit/WKNavigationDelegatePrivate.h>
#import <WebKit/WebKit.h>
+@class _WKContentRuleListAction;
+
@interface TestNavigationDelegate : NSObject <WKNavigationDelegate>
@property (nonatomic, copy) void (^decidePolicyForNavigationAction)(WKNavigationAction *, void (^)(WKNavigationActionPolicy));
@@ -38,6 +40,7 @@
@property (nonatomic, copy) void (^renderingProgressDidChange)(WKWebView *, _WKRenderingProgressEvents);
@property (nonatomic, copy) void (^webContentProcessDidTerminate)(WKWebView *);
@property (nonatomic, copy) void (^didReceiveAuthenticationChallenge)(WKWebView *, NSURLAuthenticationChallenge *, void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *));
+@property (nonatomic, copy) void (^contentRuleListPerformedAction)(WKWebView *, NSString *, _WKContentRuleListAction *, NSURL *);
- (void)waitForDidStartProvisionalNavigation;
- (void)waitForDidFinishNavigation;
Modified: trunk/Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.mm (287039 => 287040)
--- trunk/Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.mm 2021-12-14 20:06:12 UTC (rev 287039)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.mm 2021-12-14 20:11:03 UTC (rev 287040)
@@ -169,6 +169,12 @@
return _navigationError.autorelease();
}
+- (void)_webView:(WKWebView *)webView contentRuleListWithIdentifier:(NSString *)identifier performedAction:(_WKContentRuleListAction *)action forURL:(NSURL *)url
+{
+ if (_contentRuleListPerformedAction)
+ _contentRuleListPerformedAction(webView, identifier, action, url);
+}
+
@end
@implementation WKWebView (TestWebKitAPIExtras)