getMatchedRules does not seem to work

Hi.

For my Safari Web Extension, using getMatchedRules() from declarativeNetRequest does not seem to work. I've declared the permission for declarativeNetRequestFeedback in my manifest.json file and tried the activeTab permission too.

getMatchedRules() was added in a previous Safari release and was adjusted in Safari 16.4. I'm using Safari 16.5.

It only returns an empty array when it's called.

I know the rules are there and they're being applied from the static rules json, it's just that getMatchedRules() is not showing them for some reason.

I'm using: const rules = await browser.declarativeNetRequest.getMatchedRules(); But it only ever returns: {rulesMatchedInfo: []}

Can anyone tell me what I'm doing wrong please? The same code works fine in Chromium based browsers.

Thank you.

In iOS >= 16.4 (and iOS 17 beta) getMatchedRules returns only:

  • request.url,
  • tabId,
  • timeStamp

**instead of: **

  • rule.ruleId,
  • rule.ruleSetId,
  • tabId,
  • timeStamp

as in all the OTHER browsers.

So it returns something but doesn't return what is expected as specified in the documentation:

Fixed result of getMatchedRules() to match other browsers.

The declarativeNetRequest API is full of holes, despite Apple's insistence that they work in the documentation. Another example are responseHeaders/modifyHeaders that completely pack a Web site on Safari, while working perfectly on all other browsers.

Does your extension have permission to access the URLs that are being blocked?

Without those, Safari won't include the URLs of the blocked resources in the completion handler.

getMatchedRules does not seem to work
 
 
Q