How to block a webrequest in chrome webextension after onHeadersReceived without "ERR_BLOCKED_BY_CLIENT"

486 Views Asked by At

I try to port my Firefox extension to Chrome but the way of working of webrequestonHeadersReceived doesn't seem to be the same.

When I use:

chrome.webRequest.onHeadersReceived.addListener(analyse,{urls: ["http://*/*", "https://*/*"]},["blocking", "responseHeaders"]);

the function analyse is correctly called and I can analyse the response headers and if the function return "cancel: true", on Firefox the page doesn't update and it is perfect but in Chrome, the page is updating and display the famous message

"Requests to server have been blocked by an extension"

The goal of my extension is to manage some type of downloadable file. But where in Firefox, if you click on download, the page doesn't move and I can display a panel who let you choose what to do, in Chrome even if my panel is correctly displayed, the main page is updated with this error message and I am forced to click on "back" to retrieve the original page.

Furthermore, in Firefox, when a request is blocked one time, it does not try to get again the request, while in Chrome, the page which displays the error message try to get a new the request.

0

There are 0 best solutions below