Fired when a web request is about to be made, to give the extension an opportunity to proxy it.
This event is closely modeled on the events defined in the webRequest API. Like those events, its addListener() function takes three arguments:
- the listener that is called when the event is fired.
- a
RequestFilterobject controlling which requests cause the event to fire. - an array of strings to control other aspects of the event's behavior.
The event is fired before any of the webRequest events for the same request.
When the event is fired, the listener is called with an object containing information about the request. The listener returns a proxy.ProxyInfo object representing a proxy to use (or an array of proxy.ProxyInfo objects, enabling the browser to fail over if a proxy is unreachable).
To use proxy.onRequest, an extension must have the "proxy" API permission and the host permission for the URLs of the requests that it intercepts, which means that the match patterns in the filter argument must be a subset of the extension's host permissions.