Checks if any of the extension's declarativeNetRequest rules would match a hypothetical request. Only available while testing, as this is intended to be used during extension development. See Testing for details on how testing is enabled in each browser.


let result = await browser.declarativeNetRequest.testMatchOutcome(
    request,                // object
    options                 // optional object



The details of the request to test.

initiator Optional

A string. The initiator URL (if any) for the hypothetical request.

method Optional

A string. The standard (lower case) HTTP method of the hypothetical request. Defaults to "get" for HTTP requests and is ignored for non-HTTP requests.

tabId Optional

A number. The ID of the tab the hypothetical request takes place in. Does not need to correspond to a real tab ID. Default is -1, meaning that the request isn't related to a tab.


declarativeNetRequest.ResourceType. The resource type of the hypothetical request.


A string. The URL of the hypothetical request.

options Optional

Details of options for the request.

includeOtherExtensions Optional

A boolean. Whether matching rules from other extensions are included in matchedRules. When rules from other extensions match, the resulting matchedRule has an extensionId property. Defaults to false.

Return value

A Promise that fulfills with an object with these properties:


declarativeNetRequest.MatchedRule. Details of the rules (if any) that match the hypothetical request.

If no rules match, the matchedRules array is empty. If the request fails, the promise is rejected with an error message.


Browser compatibility

BCD tables only load in the browser