-
Notifications
You must be signed in to change notification settings - Fork 1.6k
dNR: fix sub_frame resourceType allowAllRequests rules #47328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
webkit-commit-queue
merged 1 commit into
WebKit:main
from
elijahsawyers:eng/esawyers/295043
Jun 30, 2025
Merged
dNR: fix sub_frame resourceType allowAllRequests rules #47328
webkit-commit-queue
merged 1 commit into
WebKit:main
from
elijahsawyers:eng/esawyers/295043
Jun 30, 2025
+149
−33
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EWS run on current version of this PR (hash a14d249) |
xeenon
approved these changes
Jun 28, 2025
https://bugs.webkit.org/show_bug.cgi?id=295043 rdar://154124673 Reviewed by Timothy Hatcher. This patch fixes allowAllRequests rules for sub_frame resource types. First, I renamed the recently added if-ancestor-frame-url content blocker condition to be if-ancestor-subframe-url and made it exclude the main frame. While working on that patch (see WebKit#47251), it was thought that it'd be better to include the main frame in the condition, but it turns out that it's not. It's better to split main_frame and sub_frame rules out into their own rules using if-top-url and if-ancestor-subframe-url, respectively. Therefore, dNR allowAllRequests rules convert into the following content blocker rules: // dNR { "id": 1, "action": { "type": "allowAllRequests" }, "condition": { "urlFilter": "apple.com", "resourceTypes": [ "main_frame", "sub_frame" ] } } // WebKit content blocking { "action": { "type": "ignore-following-rules", }, "trigger": { "url-filter": ".*", "if-top-url": [ "apple\\.com" ], } }, { "action": { "type": "ignore-following-rules", }, "trigger": { "url-filter": ".*", "if-ancestor-subframe-url": [ "apple\\.com" ], } } I wrote new tests to validate the rule conversions and functionality. * Source/WebCore/contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::compileRuleList): * Source/WebCore/contentextensions/ContentExtensionParser.cpp: (WebCore::ContentExtensions::loadTrigger): * Source/WebCore/contentextensions/ContentExtensionRule.h: (WebCore::ContentExtensions::Trigger::checkValidity): * Source/WebCore/contentextensions/ContentExtensionsBackend.cpp: (WebCore::ContentExtensions::ContentExtensionsBackend::actionsFromContentRuleList const): (WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForLoad): * Source/WebCore/loader/ResourceLoadInfo.h: * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.mm: (-[_WKWebExtensionDeclarativeNetRequestRule _convertRulesWithModifiedCondition:webKitActionType:chromeActionType:]): (-[_WKWebExtensionDeclarativeNetRequestRule _webKitRuleWithWebKitActionType:chromeActionType:condition:]): * Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp: (TestWebKitAPI::TEST_F(ContentExtensionTest, InvalidJSON)): (TestWebKitAPI::TEST_F(ContentExtensionTest, IfAncestorSubframeURL)): (TestWebKitAPI::TEST_F(ContentExtensionTest, IfFrameOrAncestorsURL)): Deleted. * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest, MainFrameAllowAllRequests)): (TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest, SubFrameAllowAllRequests)): (TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest, RuleConversionWithMainFrameAllowAllRequests)): (TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest, RuleConversionWithSubFrameAllowAllRequests)): (TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest, RuleConversionWithMainFrameAndSubFrameAllowAllRequests)): Canonical link: https://commits.webkit.org/296799@main
a14d249
to
34e4b87
Compare
Committed 296799@main (34e4b87): https://commits.webkit.org/296799@main Reviewed commits have been landed. Closing PR #47328 and removing active labels. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
34e4b87
a14d249