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.
On this page
declarativeNetRequest.testMatchOutcome
Syntax
let result = await browser.declarativeNetRequest.testMatchOutcome(
request, // object
options // optional object
);
Parameters
-
request -
The details of the request to test.
initiatorOptional-
A
string. The initiator URL (if any) for the hypothetical request. methodOptional-
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. tabIdOptional-
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. -
type -
declarativeNetRequest.ResourceType. The resource type of the hypothetical request. -
url -
A
string. The URL of the hypothetical request.
optionsOptional-
Details of options for the request.
includeOtherExtensionsOptional-
A
boolean. Whether matching rules from other extensions are included inmatchedRules. When rules from other extensions match, the resultingmatchedRulehas anextensionIdproperty. Defaults tofalse.
Return value
A Promise that fulfills with an object with these properties:
-
matchedRules -
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.
Examples
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
testMatchOutcome |
103 | 103 | No | ? | 89 | No | ? | ? | No | ? | No | ? |
options |
No | No | No | ? | No | No | ? | ? | No | ? | No | ? |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/testMatchOutcome