aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-04-28 16:21:06 -0300
committerSebastian <sebasjm@gmail.com>2022-04-28 16:21:06 -0300
commit980d3f5b2b866d7aafef038bfa015f3e6f1048ca (patch)
treef66342d5a7d70f74d0f2ff0d74cc1f2eab5c49c5 /packages/taler-wallet-webextension
parent508f5d2ea7a0c83eeb35bfae08a514c7e23fd884 (diff)
do not save current header before being added into the browser listener
Diffstat (limited to 'packages/taler-wallet-webextension')
-rw-r--r--packages/taler-wallet-webextension/src/platform/chrome.ts15
1 files changed, 9 insertions, 6 deletions
diff --git a/packages/taler-wallet-webextension/src/platform/chrome.ts b/packages/taler-wallet-webextension/src/platform/chrome.ts
index e4ebfbae5..be7dd40f9 100644
--- a/packages/taler-wallet-webextension/src/platform/chrome.ts
+++ b/packages/taler-wallet-webextension/src/platform/chrome.ts
@@ -326,7 +326,6 @@ function registerTalerHeaderListener(callback: (tabId: number, url: string) => v
return;
}
const prevHeaderListener = currentHeaderListener;
- currentHeaderListener = headerListener;
getPermissionsApi().containsHostPermissions().then(result => {
//if there is a handler already, remove it
@@ -338,11 +337,15 @@ function registerTalerHeaderListener(callback: (tabId: number, url: string) => v
}
//if the result was positive, add the headerListener
if (result) {
- chrome?.webRequest?.onHeadersReceived?.addListener(
- headerListener,
- { urls: ["<all_urls>"] },
- ["responseHeaders"],
- );
+ const listener: chrome.webRequest.WebResponseHeadersEvent | undefined = chrome?.webRequest?.onHeadersReceived;
+ if (listener) {
+ listener.addListener(
+ headerListener,
+ { urls: ["<all_urls>"] },
+ ["responseHeaders"],
+ );
+ currentHeaderListener = headerListener;
+ }
}
//notify the browser about this change, this operation is expensive
chrome?.webRequest?.handlerBehaviorChanged(() => {