When a tabs.onUpdated
event is triggered by e.g. the FORWARD or BACK buttons, I can’t figure out how to access that (cached) request’s securityInfo
.
Clearly, this information exists, as (e.g.) the HTTPS Lock in the URL bar always shows the cert chain associated with the current request, even a cached one.
But, how can an extension access this information?
I’m completely OK to do the caching myself, but I can’t figure out what request’s cached information to display when the user uses the navigation buttons!
Workaround for now: cache the securityInfo objects myself, indexing off the ordered-pair: (tabId
,requestUrl
)
This should handle most [all?] cases correctly:
const x=new Object();
browser.webRequest.onHeadersReceived.addListener(async details=>{
if(!(details.tabId in x)) x[details.tabId]=new Object();
x[details.tabId][details.url]=await browser.webRequest.getSecurityInfo(details.requestId);
});
browser.tabs.onUpdated.addListener((tabId,changeInfo,tabInfo)=>{
let securityInfo=x[tabId][tabInfo.url];
doStuffWith(tabId,securityInfo);
},{properties:["status"]});
browser.tabs.onRemoved.addListener(tabId=>{
delete x[tabId]; //TODO: handle re-opened tabs and windows?
});