From e037f0a5604fff200113a577dba579b1d7e3fe38 Mon Sep 17 00:00:00 2001 From: Sam Macbeth Date: Fri, 11 Oct 2019 15:53:57 +0200 Subject: [PATCH] fix: Improve extraHeaders feature detection (#787) On Firefox forks the runtime.isFirefox detection was failing because the browser name was not 'Firefox'. This lead to an error when registering webRequest listeners as the extraHeaders option is not needed, preventing the extension from loading. There is an extension API that can be used to detect support for this option: OnBeforeSendHeadersOptions. This fix updates the feature detection check to explicitly look for this API. We also check to for the presence of OnBeforeSendHeadersOptions as it does not exist on Edge. --- add-on/src/lib/ipfs-companion.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add-on/src/lib/ipfs-companion.js b/add-on/src/lib/ipfs-companion.js index ffc6f455b..074db5d05 100644 --- a/add-on/src/lib/ipfs-companion.js +++ b/add-on/src/lib/ipfs-companion.js @@ -97,7 +97,7 @@ module.exports = async function init () { function registerListeners () { const onBeforeSendInfoSpec = ['blocking', 'requestHeaders'] - if (!runtime.isFirefox) { + if (browser.webRequest.OnBeforeSendHeadersOptions && 'EXTRA_HEADERS' in browser.webRequest.OnBeforeSendHeadersOptions) { // Chrome 72+ requires 'extraHeaders' for access to Referer header (used in cors whitelisting of webui) onBeforeSendInfoSpec.push('extraHeaders') }