From a1241e08066c56431ac06eb0cb20aba9e0b50518 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 29 Apr 2021 13:04:59 -0400 Subject: [PATCH] Don't use `self` to access `vAPI` in content script Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1571 Testing through `self` breaks the injection of `contentscript-extra.js` in Firefox 66.0 and earlier. --- platform/chromium/vapi-client.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/chromium/vapi-client.js b/platform/chromium/vapi-client.js index 1dc42277d..1b585fd64 100644 --- a/platform/chromium/vapi-client.js +++ b/platform/chromium/vapi-client.js @@ -230,14 +230,16 @@ vAPI.messaging = { }, // Dynamically extend capabilities. + // + // https://github.com/uBlockOrigin/uBlock-issues/issues/1571 + // Don't use `self` to access `vAPI`. extend: function() { if ( this.extended === undefined ) { this.extended = vAPI.messaging.send('vapi', { what: 'extendClient' - }).then(( ) => { - return self.vAPI instanceof Object && - this.extensions.length !== 0; - }).catch(( ) => { + }).then(( ) => + typeof vAPI === 'object' && this.extensions.length !== 0 + ).catch(( ) => { }); } return this.extended;