Fallback context to same URL when documentUrl is missing.

This commit is contained in:
hackademix 2022-02-14 18:50:58 +01:00
parent 9c7fd70d57
commit cd30505fe1
1 changed files with 2 additions and 2 deletions

View File

@ -231,9 +231,9 @@
policyContext(contextualData) {
// contextualData (e.g. a request details object) must contain a tab, a tabId or a documentUrl
// (used as a fallback if tab's top URL cannot be retrieved, e.g. in service workers)
let {tab, tabId, documentUrl} = contextualData;
let {tab, tabId, documentUrl, url} = contextualData;
if (!tab) tab = tabId !== -1 && TabCache.get(tabId);
return tab && tab.url || documentUrl;
return tab && tab.url || documentUrl || url;
},
requestCan(request, capability) {
return !this.isEnforced(request.tabId) || this.policy.can(request.url, capability, this.policyContext(request));