-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Introduce top-document and child-document content blocking resource types #42722
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 top-document and child-document content blocking resource types #42722
Conversation
|
EWS run on previous version of this PR (hash b40a662) Details |
achristensen07
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I think it needs a test that verifies that if you use child-document the action will apply to an iframe load but not the main frame load and vice versa.
b40a662 to
eadd155
Compare
|
EWS run on previous version of this PR (hash eadd155) Details |
eadd155 to
9424e1e
Compare
|
EWS run on previous version of this PR (hash 9424e1e) Details |
|
Failed mac-AS-debug-wk2 checks. Please resolve failures and re-apply Rejecting #42722 from merge queue. |
|
Safe-Merge-Queue: Build #52069. |
9424e1e to
08a644d
Compare
|
EWS run on current version of this PR (hash 08a644d) Details |
…ypes https://bugs.webkit.org/show_bug.cgi?id=290067 rdar://147442279 Reviewed by Timothy Hatcher and Alex Christensen. This patch breaks out the Document resource type to be TopDocument and ChildDocument. The motive behind this change is that currently, a dNR rule that doesn't specify resource types gets converted into two WebKit content blocking rules. E.g. { ... trigger = { load-context = child-frame resource-type = document } ... } { ... trigger = { resource-type = script, ping, ... } ... } By introducing the child-document resource type, those two rules can be collapsed into one. * LayoutTests/http/tests/contentextensions/block-child-document-resource-type-expected.txt: Added. * LayoutTests/http/tests/contentextensions/block-child-document-resource-type.html: Added. * LayoutTests/http/tests/contentextensions/block-child-document-resource-type.html.json: Added. * LayoutTests/http/tests/contentextensions/block-top-document-resource-type-expected.txt: Added. * LayoutTests/http/tests/contentextensions/block-top-document-resource-type-with-child-document-expected.txt: Added. * LayoutTests/http/tests/contentextensions/block-top-document-resource-type-with-child-document.html: Added. * LayoutTests/http/tests/contentextensions/block-top-document-resource-type-with-child-document.html.json: Added. * LayoutTests/http/tests/contentextensions/block-top-document-resource-type.html: Added. * LayoutTests/http/tests/contentextensions/block-top-document-resource-type.html.json: Added. Introduce new layout tests to verify that the top-document and child-document resource types behave as expected. * Source/WebCore/contentextensions/ContentExtensionsBackend.cpp: (WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForLoad): Update the resourceType check to look for TopDocument or ChildDocument, rather than Document. * Source/WebCore/css/StyleSheetContents.cpp: (WebCore::StyleSheetContents::subresourcesAllowReuse const): Pass in whether or not the frame is the main frame. * Source/WebCore/loader/DocumentLoader.cpp: (WebCore::DocumentLoader::handleSubstituteDataLoadNow): Set the ResourceType to either TopDocument or ChildDocument, rather than Document. * Source/WebCore/loader/ResourceLoadInfo.cpp: (WebCore::ContentExtensions::toResourceType): Return an option set with either TopDocument or ChildDocument ResourceType if the cached resource type is a main resource. Also, update this method to take in a parameter as to whether or not the resource is the main frame, which is used to decide whether to return TopDocument or ChildDocument. (WebCore::ContentExtensions::readResourceType): Return an option set with both TopDocument and ChildDocument ResourceTypes if the content blocking rule specifies "document" resource type. Return TopDocument and ChildDocument for their resource type strings. (WebCore::ContentExtensions::resourceTypeToString): Return the resource type strings for the TopDocument and ChildDocument ResourceTypes. * Source/WebCore/loader/ResourceLoadInfo.h: Replace the Document ResourceType with TopDocument and ChildDocument, and update the byte code. * Source/WebCore/loader/ResourceMonitor.cpp: (WebCore::ResourceMonitor::setDocumentURL): Set the ResourceType to either TopDocument or ChildDocument, rather than Document. * Source/WebCore/loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::SubresourceLoader): Pass in whether or not the frame is the main frame. * Source/WebCore/loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): Pass in whether or not the frame is the main frame. * Source/WebCore/page/UserContentProvider.cpp: (WebCore::UserContentProvider::processContentRuleListsForLoad): Update the resourceType check to look for TopDocument or ChildDocument, rather than Document. * Source/WebKit/UIProcess/API/APIContentRuleListStore.h: Update the content rule list file version since we modified the byte code. * Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp: (TestWebKitAPI::mainDocumentRequest): (TestWebKitAPI::subResourceRequest): (TestWebKitAPI::requestInTopAndFrameURLs): (TestWebKitAPI::TEST_F(ContentExtensionTest, TopURL)): (TestWebKitAPI::TEST_F(ContentExtensionTest, LoadType)): (TestWebKitAPI::TEST_F(ContentExtensionTest, ResourceType)): (TestWebKitAPI::TEST_F(ContentExtensionTest, ResourceOrLoadTypeMatchingEverything)): (TestWebKitAPI::TEST_F(ContentExtensionTest, MatchesEverything)): (TestWebKitAPI::TEST_F(ContentExtensionTest, IfFrameURL)): (TestWebKitAPI::TEST_F(ContentExtensionTest, UnlessFrameURL)): Update the tests to use TopDocument and ChildDocument ResourceTypes, since Document was removed. Canonical link: https://commits.webkit.org/292482@main
08a644d to
d5d7442
Compare
|
Committed 292482@main (d5d7442): https://commits.webkit.org/292482@main Reviewed commits have been landed. Closing PR #42722 and removing active labels. |
d5d7442
08a644d
🛠 wpe🛠 win🧪 wpe-wk2🧪 win-tests🧪 ios-wk2🧪 api-mac🧪 api-wpe🧪 ios-wk2-wpt🧪 mac-wk1🛠 wpe-cairo🧪 api-ios🧪 mac-wk2🛠 gtk🧪 mac-AS-debug-wk2🧪 gtk-wk2🧪 mac-wk2-stress🧪 api-gtk🧪 vision-wk2🧪 mac-intel-wk2🛠 playstation🛠 mac-safer-cpp🛠 watch