Safari extension MV3, MacBook Pro with Ventura 13.3.1, Safari 16.4 and Xcode 14.3
Although the “webkit features in Safari 16.4” claims to support requestDomains
condition, any attempt to load a ruleset containing that condition fails.
The extension’s manifest declares the permissions and the ruleset to use:
"permissions": [ "declarativeNetRequestWithHostAccess", "declarativeNetRequestFeedback" ],
"declarative_net_request": { "rule_resources": [ { "id": "ADS", "enabled": false, "path": "rules/adstest.json" } ] }
This is the ruleset used for tests:
[ { "id": 1, "priority": 1, "action": { "type": "block" }, "condition": { "requestDomains": ["testpages.kzar.co.uk"] } } ]
The ruleset is enabled by the service worker with this function:
function EnableDNRRules() {
return new Promise( (resolve, reject) => {
browser.declarativeNetRequest.updateEnabledRulesets(
{ enableRulesetIds: [ 'ADS' ] }, () => {
console.log("LAST ERROR",browser.runtime.lastError)
resolve(true);
console.log("dNR rules enabled");
});
});
}
The result in last error is: “Failed to apply rules” and rule is not used at all.
If I enable the ruleset directly in manifest, and not using the function to load the ruleset, the rule is simply not applied (so not loaded at all).
In Chrome and Firefox the same code/ruleset works fine, but not in Safari 16.4, although the docs say it works.
Using different condition (e.g. urlFilter) works fine in Safari too.
The expected behavior is to have requestDomains working too, as per 16.4 documentation.