diff options
author | Sebastian <sebasjm@gmail.com> | 2022-04-28 16:21:06 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-04-28 16:21:06 -0300 |
commit | 980d3f5b2b866d7aafef038bfa015f3e6f1048ca (patch) | |
tree | f66342d5a7d70f74d0f2ff0d74cc1f2eab5c49c5 /packages/taler-wallet-webextension/src/platform/chrome.ts | |
parent | 508f5d2ea7a0c83eeb35bfae08a514c7e23fd884 (diff) | |
download | wallet-core-980d3f5b2b866d7aafef038bfa015f3e6f1048ca.tar.xz |
do not save current header before being added into the browser listener
Diffstat (limited to 'packages/taler-wallet-webextension/src/platform/chrome.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/platform/chrome.ts | 15 |
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(() => { |