Changeset 287040 in webkit
- Timestamp:
- Dec 14, 2021, 12:11:03 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (modified) (1 diff)
-
Source/WebCore/contentextensions/ContentRuleListResults.h (modified) (6 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/API/APIContentRuleListAction.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/API/APIContentRuleListAction.h (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/_WKContentRuleListAction.h (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/_WKContentRuleListAction.mm (modified) (1 diff)
-
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm (modified) (5 diffs)
-
Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.h (modified) (2 diffs)
-
Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r287038 r287040 1 2021-12-14 Alex Christensen <achristensen@webkit.org> 2 3 Add _WKContentRuleListAction.redirected and .modifiedHeaders 4 https://bugs.webkit.org/show_bug.cgi?id=234289 5 6 Reviewed by Tim Hatcher. 7 8 These inform the UI process about new actions taken by the extension. 9 10 * contentextensions/ContentExtensionsBackend.cpp: 11 (WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForLoad): 12 (WebCore::ContentExtensions::applyResultsToRequest): 13 * contentextensions/ContentRuleListResults.h: 14 (WebCore::ContentRuleListResults::shouldNotifyApplication const): 15 (WebCore::ContentRuleListResults::Result::encode const): 16 (WebCore::ContentRuleListResults::Result::decode): 17 (WebCore::ContentRuleListResults::Result::shouldNotifyApplication const): Deleted. 18 1 19 2021-12-14 Tyler Wilcock <tyler_w@apple.com> 2 20 -
trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
r287010 r287040 249 249 RELEASE_ASSERT_NOT_REACHED(); 250 250 }, [&] (const ModifyHeadersAction& action) { 251 if (initiatingDocumentLoader.allowsActiveContentRuleListActionsForURL(contentRuleListIdentifier, url)) 251 if (initiatingDocumentLoader.allowsActiveContentRuleListActionsForURL(contentRuleListIdentifier, url)) { 252 result.modifiedHeaders = true; 252 253 results.summary.modifyHeadersActions.append(action); 254 } 253 255 }, [&] (const RedirectAction& redirectAction) { 254 if (initiatingDocumentLoader.allowsActiveContentRuleListActionsForURL(contentRuleListIdentifier, url)) 256 if (initiatingDocumentLoader.allowsActiveContentRuleListActionsForURL(contentRuleListIdentifier, url)) { 257 result.redirected = true; 255 258 results.summary.redirectActions.append({ redirectAction, m_contentExtensions.get(contentRuleListIdentifier)->extensionBaseURL() }); 259 } 256 260 }), action.data()); 257 261 } -
trunk/Source/WebCore/contentextensions/ContentRuleListResults.h
r286084 r287040 40 40 bool madeHTTPS { false }; 41 41 bool blockedCookies { false }; 42 bool modifiedHeaders { false }; 43 bool redirected { false }; 42 44 Vector<String> notifications; 43 45 … … 47 49 || madeHTTPS 48 50 || blockedCookies 51 || modifiedHeaders 52 || redirected 49 53 || !notifications.isEmpty(); 50 54 } … … 74 78 || summary.madeHTTPS 75 79 || summary.blockedCookies 80 || !summary.modifyHeadersActions.isEmpty() 81 || !summary.redirectActions.isEmpty() 76 82 || summary.hasNotifications; 77 83 } … … 106 112 encoder << madeHTTPS; 107 113 encoder << blockedCookies; 114 encoder << modifiedHeaders; 115 encoder << redirected; 108 116 encoder << notifications; 109 117 } … … 124 132 decoder >> blockedCookies; 125 133 if (!blockedCookies) 134 return std::nullopt; 135 136 std::optional<bool> modifiedHeaders; 137 decoder >> modifiedHeaders; 138 if (!modifiedHeaders) 139 return std::nullopt; 140 141 std::optional<bool> redirected; 142 decoder >> redirected; 143 if (!redirected) 126 144 return std::nullopt; 127 145 … … 135 153 WTFMove(*madeHTTPS), 136 154 WTFMove(*blockedCookies), 155 WTFMove(*modifiedHeaders), 156 WTFMove(*redirected), 137 157 WTFMove(*notifications) 138 158 }}; -
trunk/Source/WebKit/ChangeLog
r287039 r287040 1 2021-12-14 Alex Christensen <achristensen@webkit.org> 2 3 Add _WKContentRuleListAction.redirected and .modifiedHeaders 4 https://bugs.webkit.org/show_bug.cgi?id=234289 5 6 Reviewed by Tim Hatcher. 7 8 * UIProcess/API/APIContentRuleListAction.cpp: 9 (API::ContentRuleListAction::redirected const): 10 (API::ContentRuleListAction::modifiedHeaders const): 11 * UIProcess/API/APIContentRuleListAction.h: 12 * UIProcess/API/Cocoa/_WKContentRuleListAction.h: 13 * UIProcess/API/Cocoa/_WKContentRuleListAction.mm: 14 (-[_WKContentRuleListAction redirected]): 15 (-[_WKContentRuleListAction modifiedHeaders]): 16 * WebProcess/WebCoreSupport/WebChromeClient.cpp: 17 (WebKit::WebChromeClient::contentRuleListNotification): 18 1 19 2021-12-14 Alex Christensen <achristensen@webkit.org> 2 20 -
trunk/Source/WebKit/UIProcess/API/APIContentRuleListAction.cpp
r285980 r287040 58 58 } 59 59 60 bool ContentRuleListAction::redirected() const 61 { 62 return m_result.redirected; 63 } 64 65 bool ContentRuleListAction::modifiedHeaders() const 66 { 67 return m_result.modifiedHeaders; 68 } 69 60 70 const Vector<WTF::String>& ContentRuleListAction::notifications() const 61 71 { -
trunk/Source/WebKit/UIProcess/API/APIContentRuleListAction.h
r285980 r287040 41 41 bool madeHTTPS() const; 42 42 bool blockedCookies() const; 43 bool redirected() const; 44 bool modifiedHeaders() const; 43 45 const Vector<WTF::String>& notifications() const; 44 46 -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKContentRuleListAction.h
r252174 r287040 33 33 @property (nonatomic, readonly) BOOL blockedCookies; 34 34 @property (nonatomic, readonly) BOOL madeHTTPS; 35 @property (nonatomic, readonly) BOOL redirected WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 36 @property (nonatomic, readonly) BOOL modifiedHeaders WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 35 37 @property (nonatomic, readonly, copy) NSArray<NSString *> *notifications; 36 38 -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKContentRuleListAction.mm
r285980 r287040 69 69 } 70 70 71 - (BOOL)redirected 72 { 73 #if ENABLE(CONTENT_EXTENSIONS) 74 return _action->redirected(); 75 #else 76 return NO; 77 #endif 78 } 79 80 - (BOOL)modifiedHeaders 81 { 82 #if ENABLE(CONTENT_EXTENSIONS) 83 return _action->modifiedHeaders(); 84 #else 85 return NO; 86 #endif 87 } 88 71 89 - (NSArray<NSString *> *)notifications 72 90 { -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
r286886 r287040 1003 1003 { 1004 1004 #if ENABLE(CONTENT_EXTENSIONS) 1005 ASSERT(results.shouldNotifyApplication());1006 1005 m_page.send(Messages::WebPageProxy::ContentRuleListNotification(url, results)); 1007 1006 #endif -
trunk/Tools/ChangeLog
r287039 r287040 1 2021-12-14 Alex Christensen <achristensen@webkit.org> 2 3 Add _WKContentRuleListAction.redirected and .modifiedHeaders 4 https://bugs.webkit.org/show_bug.cgi?id=234289 5 6 Reviewed by Tim Hatcher. 7 8 * TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm: 9 (checkURLs): 10 (TEST_F): 11 * TestWebKitAPI/cocoa/TestNavigationDelegate.h: 12 * TestWebKitAPI/cocoa/TestNavigationDelegate.mm: 13 (-[TestNavigationDelegate _webView:contentRuleListWithIdentifier:performedAction:forURL:]): 14 1 15 2021-12-14 Alex Christensen <achristensen@webkit.org> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm
r286545 r287040 35 35 #import <WebKit/WKUserContentControllerPrivate.h> 36 36 #import <WebKit/WKWebpagePreferencesPrivate.h> 37 #import <WebKit/_WKContentRuleListAction.h> 37 38 #import <WebKit/_WKUserContentExtensionStore.h> 38 39 #import <WebKit/_WKUserContentFilter.h> 39 40 #import <wtf/RetainPtr.h> 40 41 #import <wtf/Vector.h> 42 #import <wtf/text/WTFString.h> 41 43 42 44 class WKContentRuleListStoreTest : public testing::Test { … … 504 506 }; 505 507 return delegate; 508 } 509 510 static void checkURLs(const Vector<String>& actual, const Vector<String>& expected) 511 { 512 EXPECT_EQ(actual.size(), expected.size()); 513 for (size_t i = 0; i < std::min(actual.size(), expected.size()); i++) 514 EXPECT_WK_STREQ(actual[i], expected[i]); 506 515 } 507 516 … … 563 572 [configuration setURLSchemeHandler:handler.get() forURLScheme:@"testscheme"]; 564 573 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSZeroRect configuration:configuration.get()]); 565 webView.get().navigationDelegate = navigationDelegateAllowingActiveActionsOnTestHost().get(); 574 auto delegate = navigationDelegateAllowingActiveActionsOnTestHost().get(); 575 webView.get().navigationDelegate = delegate; 576 __block bool receivedActionNotification { false }; 577 __block Vector<String> urls; 578 delegate.contentRuleListPerformedAction = ^(WKWebView *, NSString *identifier, _WKContentRuleListAction *action, NSURL *url) { 579 urls.append(url.absoluteString); 580 EXPECT_TRUE(action.modifiedHeaders); 581 receivedActionNotification = true; 582 }; 566 583 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"testscheme://testhost/main.html"]]]; 567 584 TestWebKitAPI::Util::run(&receivedAllRequests); 585 TestWebKitAPI::Util::run(&receivedActionNotification); 586 checkURLs(urls, { 587 "testscheme://testhost/main.html", 588 "testscheme://testhost/fetch.txt" 589 }); 568 590 569 591 // FIXME: Appending to the User-Agent replaces the user agent because we haven't added the user agent yet when processing the request. … … 668 690 [configuration setURLSchemeHandler:handler.get() forURLScheme:@"othertestscheme"]; 669 691 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSZeroRect configuration:configuration.get()]); 670 webView.get().navigationDelegate = navigationDelegateAllowingActiveActionsOnTestHost().get(); 692 auto delegate = navigationDelegateAllowingActiveActionsOnTestHost().get(); 693 webView.get().navigationDelegate = delegate; 694 __block bool receivedActionNotification { false }; 695 __block Vector<String> urlsFromCallback; 696 delegate.contentRuleListPerformedAction = ^(WKWebView *, NSString *identifier, _WKContentRuleListAction *action, NSURL *url) { 697 urlsFromCallback.append(url.absoluteString); 698 EXPECT_TRUE(action.redirected); 699 receivedActionNotification = true; 700 }; 701 671 702 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"testscheme://testhost/main.html"]]]; 672 703 TestWebKitAPI::Util::run(&receivedAllRequests); 673 674 Vector<const char*> expectedRequestedURLs { 704 TestWebKitAPI::Util::run(&receivedActionNotification); 705 706 Vector<String> expectedRequestedURLs { 675 707 "testscheme://testhost/main.html", 676 708 "othertestscheme://not-testhost/1-redirected.txt", … … 686 718 for (size_t i = 0; i < expectedRequestedURLs.size(); i++) 687 719 EXPECT_WK_STREQ(expectedRequestedURLs[i], [[urls objectAtIndex:i] absoluteString]); 720 721 expectedRequestedURLs.remove(0); 722 expectedRequestedURLs[1] = "testscheme://testhost:123/2.txt"; 723 checkURLs(urlsFromCallback, expectedRequestedURLs); 688 724 } 689 725 -
trunk/Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.h
r275166 r287040 27 27 #import <WebKit/WebKit.h> 28 28 29 @class _WKContentRuleListAction; 30 29 31 @interface TestNavigationDelegate : NSObject <WKNavigationDelegate> 30 32 … … 39 41 @property (nonatomic, copy) void (^webContentProcessDidTerminate)(WKWebView *); 40 42 @property (nonatomic, copy) void (^didReceiveAuthenticationChallenge)(WKWebView *, NSURLAuthenticationChallenge *, void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *)); 43 @property (nonatomic, copy) void (^contentRuleListPerformedAction)(WKWebView *, NSString *, _WKContentRuleListAction *, NSURL *); 41 44 42 45 - (void)waitForDidStartProvisionalNavigation; -
trunk/Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.mm
r275166 r287040 170 170 } 171 171 172 - (void)_webView:(WKWebView *)webView contentRuleListWithIdentifier:(NSString *)identifier performedAction:(_WKContentRuleListAction *)action forURL:(NSURL *)url 173 { 174 if (_contentRuleListPerformedAction) 175 _contentRuleListPerformedAction(webView, identifier, action, url); 176 } 177 172 178 @end 173 179
Note:
See TracChangeset
for help on using the changeset viewer.