Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: d5d74427397d8dec2e03456dae6ea4de50060d53
https://github.com/WebKit/WebKit/commit/d5d74427397d8dec2e03456dae6ea4de50060d53
Author: Elijah Sawyers <[email protected]>
Date: 2025-03-21 (Fri, 21 Mar 2025)
Changed paths:
A
LayoutTests/http/tests/contentextensions/block-child-document-resource-type-expected.txt
A
LayoutTests/http/tests/contentextensions/block-child-document-resource-type.html
A
LayoutTests/http/tests/contentextensions/block-child-document-resource-type.html.json
A
LayoutTests/http/tests/contentextensions/block-top-document-resource-type-expected.txt
A
LayoutTests/http/tests/contentextensions/block-top-document-resource-type-with-child-document-expected.txt
A
LayoutTests/http/tests/contentextensions/block-top-document-resource-type-with-child-document.html
A
LayoutTests/http/tests/contentextensions/block-top-document-resource-type-with-child-document.html.json
A
LayoutTests/http/tests/contentextensions/block-top-document-resource-type.html
A
LayoutTests/http/tests/contentextensions/block-top-document-resource-type.html.json
M Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
M Source/WebCore/css/StyleSheetContents.cpp
M Source/WebCore/loader/DocumentLoader.cpp
M Source/WebCore/loader/ResourceLoadInfo.cpp
M Source/WebCore/loader/ResourceLoadInfo.h
M Source/WebCore/loader/ResourceMonitor.cpp
M Source/WebCore/loader/SubresourceLoader.cpp
M Source/WebCore/loader/cache/CachedResourceLoader.cpp
M Source/WebCore/page/UserContentProvider.cpp
M Source/WebKit/UIProcess/API/APIContentRuleListStore.h
M Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp
Log Message:
-----------
Introduce top-document and child-document content blocking resource types
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
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