Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2de894785a2f3bbcf02128b5e7d19e715313d791
      
https://github.com/WebKit/WebKit/commit/2de894785a2f3bbcf02128b5e7d19e715313d791
  Author: Elijah Sawyers <[email protected]>
  Date:   2025-04-23 (Wed, 23 Apr 2025)

  Changed paths:
    M Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
    M 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.mm
    M 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm

  Log Message:
  -----------
  declarativeNetRequest: 'allowAllRequests' doesn't work
https://bugs.webkit.org/show_bug.cgi?id=291872
rdar://72203692

Reviewed by Timothy Hatcher.

This patch fixes our implementation of allowAllRequests dNR rules.

Google's description of allowAllRequests is:

    Allow all requests within a frame hierarchy, including the frame request 
itself.
    
https://developer.chrome.com/docs/extensions/reference/api/declarativeNetRequest#type-RuleActionType

To do this, we have to create WebKit content blocking rules that are shaped
like:

{
  action: {
    type: ignore-previous-rules
  },
  trigger: {
    url-filter: .*

    if-frame-url: foo.com   // Based on the urlFilter, regexFilter, or
                            // requestDomains

    load-context: top-frame // or child-frame, just depending on resourceType in
                            // the dNR rule.
  }
}

All other rule conditions have to be thrown away; otherwise, we wouldn't have a
way to convert it into a valid WebKit content blocking rule.

* Source/WebCore/contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForLoad):
Only use the current document's URL if it's valid. I was seeing if-frame-url
rules fail due to an empty frame URL in the resource load info.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
Update the dNR translation version.

* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.mm:
(-[_WKWebExtensionDeclarativeNetRequestRule ruleInWebKitFormat]):
(-[_WKWebExtensionDeclarativeNetRequestRule 
_convertRulesWithModifiedCondition:webKitActionType:chromeActionType:]):
(-[_WKWebExtensionDeclarativeNetRequestRule 
_webKitRuleWithWebKitActionType:chromeActionType:condition:]):
Update the translation rules as described in the summary.

* 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest, 
RuleConversionWithAllowAllRequests)):
Wrote new tests to validate the fix.

Canonical link: https://commits.webkit.org/294041@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

Reply via email to