-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Introduce a new WebKit Content Blocking condition to act on the current frame or ancestor frame URL #47251
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
Introduce a new WebKit Content Blocking condition to act on the current frame or ancestor frame URL #47251
Conversation
EWS run on previous version of this PR (hash 6af1347) |
Do we need to bump the content blocker version here? |
6af1347
to
f474759
Compare
EWS run on previous version of this PR (hash f474759) |
f474759
to
253b7b7
Compare
EWS run on previous version of this PR (hash 253b7b7) |
253b7b7
to
9a2314d
Compare
EWS run on previous version of this PR (hash 9a2314d) |
No reviewer information in commit message, blocking PR #47251. Details: Build #17663 |
No reviewer information in commit message, blocking PR #47251. Details: Build #17664 |
9a2314d
to
864d003
Compare
EWS run on current version of this PR (hash 864d003) |
…nt frame or ancestor frame URL https://bugs.webkit.org/show_bug.cgi?id=295036 rdar://154404658 Reviewed by Brian Weinstein and Timothy Hatcher. This patch introduces a new condition type for WebKit content blockers, if- ancestor-frame-url. The condition makes it so that the rule applies if the current frame's URL, or any of the ancestor frames URLs, are in the provided array of URLs. We need this functionality to be able to support dNR allowAllRequests rules for sub frames. Added a new test to validate the fix. Note: the dNR fix is tracked with https://bugs.webkit.org/show_bug.cgi?id=295043 * 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: * Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp: (TestWebKitAPI::TEST_F(ContentExtensionTest, InvalidJSON)): (TestWebKitAPI::TEST_F(ContentExtensionTest, IfFrameOrAncestorsURL)): Canonical link: https://commits.webkit.org/296754@main
864d003
to
0d65d2e
Compare
Committed 296754@main (0d65d2e): https://commits.webkit.org/296754@main Reviewed commits have been landed. Closing PR #47251 and removing active labels. |
https://bugs.webkit.org/show_bug.cgi?id=295043 rdar://154124673 Reviewed by NOBODY (OOPS!). 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)):
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
0d65d2e
864d003
🛠 win🧪 wpe-wk2🧪 win-tests🧪 ios-wk2🧪 api-mac🧪 api-wpe🧪 ios-wk2-wpt🧪 mac-wk1🧪 api-ios🧪 mac-wk2🧪 mac-AS-debug-wk2🧪 gtk-wk2🧪 mac-wk2-stress🧪 api-gtk🧪 vision-wk2🧪 mac-intel-wk2🛠 playstation🛠 mac-safer-cpp🛠 tv-sim🛠 watch