WebExtensions: "request origin" info in WebRequest

I’m developer of the RequestPolicy Continued add-on and would like to know if it can work as is with WebExtensions.

RequestPolicy implements a content policy in order to allow or deny requests. It heavily depends on the aRequestOrigin parameter of the shouldLoad() function. The parameter is needed to decide wheter to allow or deny a request. As far as I can tell there’s no such parameter in the WebRequest API; please add it, so that the Add-on can still be supported in future.

1 Like

@billm might know if this is something we plan to implement or if there’s an equivalent API.

@billm could you please take a look?

Sorry for the delay. There’s no direct analog to requestOrigin. However, you’ll be able to get some information from the tabId and frameId fields. You can use the webNavigation API to watch as frames are created and see their URLs.

One problem here is with about:blank documents that were opened via window.open. However, I think the webNavigation.onCreatedNavigationTarget event should allow you to link back to the URL that opened the window.

I realize this isn’t ideal. I’m not sure why Chrome doesn’t have an easier way to get this information. In the future we may add a field that directly tells you the request origin.

2 Likes

Thanks for the info @billm. So it should be possible to get the request origin from webNavigation, at least for most of the requests. However, I’d really appreciate a field for the request origin; should I create a bug report?

That would be great! Thanks.

See Bug 1242871.