Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b222c16121ee83743e34c9fb60f221bff3a63639
      
https://github.com/WebKit/WebKit/commit/b222c16121ee83743e34c9fb60f221bff3a63639
  Author: Elijah Sawyers <esawy...@apple.com>
  Date:   2025-08-29 (Fri, 29 Aug 2025)

  Changed paths:
    M Source/WebCore/contentextensions/ContentExtensionActions.h
    M Source/WebCore/contentextensions/ContentExtensionParser.cpp
    M Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
    M Source/WebCore/contentextensions/ContentRuleListMatchedRule.h
    M Source/WebCore/loader/ResourceLoadInfo.cpp
    M Source/WebCore/loader/ResourceLoadInfo.h
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/UIProcess/API/APIContentRuleListStore.h
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm
    M 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.h
    M 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.mm
    M 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.h
    M 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.mm
    M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
    M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm
    M Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp
    M 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm

  Log Message:
  -----------
  dNR: include the rest of the parameters on the MatchedRuleInfoDebug object
https://bugs.webkit.org/show_bug.cgi?id=297881
rdar://157880177

Reviewed by Brian Weinstein.

This patch makes the necessary changes to include the rest of the information 
on the MatchedRuleInfo
object that's passed to the onRuleMatchedDebug listeners.

Most of the request properties could easily be set with the information that is 
already available in
ContentExtensionsBackend::processContentRuleListsForLoad. However, we are 
missing the rulesetId
property of the rule object, and it's not readily available because compiled 
content rule lists do
not track which ruleset a rule belongs to. This patch updates the 
ReportIdentifierAction to inherit
from ActionWithStringMetadata so that we can serialize its ruleset identifier 
too in addition to the
rule identifier.

For cleaner code, we've chosen to serialize the ruleset identifier repeatedly 
because most popular
dNR web extensions appear to choose fairly short strings for the IDs. If this 
proves to consume too
much memory in the future, we can update the strings to be serialized once and 
store an index to it
in the ReportIdentifierAction.

The identifiers of static rulesets are set in the manifest. Session and dynamic 
rules have the
identifier, "_session" and "_dynamic," respectively.

For information about the properties that we've added, take a look at:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/onRuleMatchedDebug#listener

It's worth noting that we aren't including the parentDocumentId right now 
because there is some work
to be done to support it with site isolation turned on. That work is tracked 
with: rdar://159289161

Added a new tests and updated existing tests to validate this fix.

* Source/WebCore/contentextensions/ContentExtensionActions.h:
(WebCore::ContentExtensions::ReportIdentifierAction::ReportIdentifierAction):
(WebCore::ContentExtensions::ReportIdentifierAction::isolatedCopy const):
(WebCore::ContentExtensions::ReportIdentifierAction::isolatedCopy):
(WebCore::ContentExtensions::ReportIdentifierAction::serialize const):
(WebCore::ContentExtensions::ReportIdentifierAction::deserialize):
(WebCore::ContentExtensions::ReportIdentifierAction::serializedLength):
* Source/WebCore/contentextensions/ContentExtensionParser.cpp:
(WebCore::ContentExtensions::loadRuleIdentifier):
* Source/WebCore/contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForLoad):
* Source/WebCore/contentextensions/ContentRuleListMatchedRule.h:
(WebCore::ContentRuleListMatchedRule::ContentRuleListMatchedRule):
* Source/WebCore/loader/ResourceLoadInfo.cpp:
(WebCore::ContentExtensions::resourceTypeToStringForMatchedRule):
* Source/WebCore/loader/ResourceLoadInfo.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::compileDeclarativeNetRequestRules):
(WebKit::WebExtensionContext::loadDeclarativeNetRequestRules):
(WebKit::WebExtensionContext::handleContentRuleListMatchedRule):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm:
(WebKit::WebExtensionController::handleContentRuleListMatchedRule):
* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.h:
* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.mm:
(-[_WKWebExtensionDeclarativeNetRequestRule 
_webKitRuleWithWebKitActionType:chromeActionType:condition:]):
* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.h:
* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.mm:
(WebKit::for):
(+[_WKWebExtensionDeclarativeNetRequestTranslator 
jsonObjectsFromData:errorStrings:]):
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm:
(WebKit::toWebAPI):
(WebKit::WebExtensionAPIDeclarativeNetRequest::updateDynamicRules):
(WebKit::WebExtensionAPIDeclarativeNetRequest::updateSessionRules):
* Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
(TestWebKitAPI::TEST_F(ContentExtensionTest, ReportIdentifierAction)):

Canonical link: https://commits.webkit.org/299333@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to