Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 1915cc5dfc4b0301a2ac9da6ecb239bb9b478dd1
https://github.com/WebKit/WebKit/commit/1915cc5dfc4b0301a2ac9da6ecb239bb9b478dd1
Author: Elijah Sawyers <[email protected]>
Date: 2025-03-21 (Fri, 21 Mar 2025)
Changed paths:
M
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.mm
M
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm
Log Message:
-----------
[DNR] requestDomains/excludedRequestDomains should operate on the domain of
the network request, not the domain of the loaded page
https://bugs.webkit.org/show_bug.cgi?id=289205
rdar://113878444
Reviewed by Timothy Hatcher.
This patch makes it so that requestDomains and excludedRequestDomains operate
on the
domain of the network request.
To do this, we need to include the requestDomains and excludedRequestDomains in
the
url-filter of the WebKit rule that we convert the dNR rule into. However, we
can't
include all domains in the url-filter because the regex doesn't allow for
complex
rules (such as the | operator). To get around this, we create one WebKit rule
per
request domain, and we combine each request domain with the urlFilter (if there
is
one). Additionally, we create one ignore-previous-rules rule for each excluded
request domain.
This patch also uses the new top-document and child-document resource types to
stop
having to create multiple rules if the dNR rule doesn't specify resource types.
It's also worth noting that if a dNR rule has requestDomains and a regexFilter,
we
throw away the requestDomains.
*
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.mm:
(WebKit::if):
(-[_WKWebExtensionDeclarativeNetRequestRule ruleInWebKitFormat]):
(-[_WKWebExtensionDeclarativeNetRequestRule
_convertRulesWithModifiedCondition:webKitActionType:chromeActionType:]):
(-[_WKWebExtensionDeclarativeNetRequestRule
_webKitRuleWithWebKitActionType:chromeActionType:condition:]):
(-[_WKWebExtensionDeclarativeNetRequestRule
_chromeResourceTypeToWebKitResourceType]):
(-[_WKWebExtensionDeclarativeNetRequestRule
_allChromeResourceTypesForCondition:]):
(-[_WKWebExtensionDeclarativeNetRequestRule
_findLongestCommonSubstringWithString:andString:]):
(-[_WKWebExtensionDeclarativeNetRequestRule
_combineRequestDomain:withURLFilter:]):
(-[_WKWebExtensionDeclarativeNetRequestRule
_convertedRulesForWebKitActionType:chromeActionType:]): Deleted.
(-[_WKWebExtensionDeclarativeNetRequestRule
_webKitRuleWithWebKitActionType:chromeActionType:chromeResourceTypes:]):
Deleted.
(-[_WKWebExtensionDeclarativeNetRequestRule
_chromeResourceTypeToWebKitLoadContext]): Deleted.
(-[_WKWebExtensionDeclarativeNetRequestRule _allChromeResourceTypes]): Deleted.
Modify the dNR to WebKit rule conversion logic to work as described in the
summary.
*
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest,
MainFrameResourceRuleConversion)):
(TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest,
SubFrameResourceRuleConversion)):
(TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest,
RepeatedMainFrameResourceRuleConversion)):
(TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest,
ConvertingMultipleResourceTypes)):
(TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest,
ConvertingXHRWebSocketAndOtherTypes)):
(TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest,
UpgradeSchemeForMainFrameRuleConversion)):
(TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest,
RuleConversionWithDomainType)):
(TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest,
RuleConversionWithNoSpecifiedResourceTypes)):
(TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest,
RuleConversionWithUnsupportedExcludedResourceTypes)):
(TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest,
RuleConversionWithEmptyExcludedResourceTypes)):
(TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest,
RuleConversionWithURLFilterAndRequestDomains)):
(TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest,
RuleConversionWithRequestDomains)):
(TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest,
RuleConversionWithExcludedRequestDomains)):
Modify the rule conversion tests to pass, and write a new test,
RuleConversionWithURLFilterAndRequestDomains, to ensure that
rules that combine request domains and URL filters converts
as expected.
Canonical link: https://commits.webkit.org/292528@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes