I’m developing an extension that, among other things, must set browserAction
subject to the following constraints:
- manipulations are done at the tab-level (i.e. not globally)
- they are done based on
main_frame
requests, in a 1:1 way - they require information only available in
onHeadersReceived
.
However, calling any browserAction.set*
function from within an onHeadersReceived
listener only applies for a split-instant; the icon is, apparently, reset by the browser at the end of the request.
I’ve “monkey-patched” it for now by applying the browserAction details within a setTimeout
of 250ms (which seems to yield precisely the desired behavior); but this is a very kludgy and wrong workaround.
So, I ask: what is the “proper” way to call browserAction.set*
with a tabId
from [code logically originating within] an onHeadersReceived
listener? I assume it’d have something to do with something like, perhaps, setting up a Promise to resolve on the request’s completion, but I’m stumped from reading the documentation.