1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-05 11:37:01 +02:00

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.
This commit is contained in:
Raymond Hill 2021-04-29 13:04:59 -04:00
parent bab6d611eb
commit a1241e0806
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -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;