diff --git a/packages/adblocker/src/engine/engine.ts b/packages/adblocker/src/engine/engine.ts index 25f9f6b281..299a6264ea 100644 --- a/packages/adblocker/src/engine/engine.ts +++ b/packages/adblocker/src/engine/engine.ts @@ -290,7 +290,9 @@ export default class FilterEngine extends EventEmitter { const configKeysMustMatch: ConfigKey[] = (Object.keys(config) as (keyof Config)[]).filter( function (key): key is ConfigKey { return ( - typeof config[key] === 'boolean' && !compatibleConfigKeys.includes(key as ConfigKey) + typeof config[key] === 'boolean' && + !compatibleConfigKeys.includes(key as ConfigKey) && + !Object.hasOwnProperty.call(overrideConfig, key) ); }, ); diff --git a/packages/adblocker/test/engine/engine.test.ts b/packages/adblocker/test/engine/engine.test.ts index ab25272e6b..e52fe38d3a 100644 --- a/packages/adblocker/test/engine/engine.test.ts +++ b/packages/adblocker/test/engine/engine.test.ts @@ -2023,6 +2023,28 @@ foo.com###selector }); }); + context.only('valides configs', () => { + it('throws with different configs', () => { + const engine1 = FilterEngine.empty({ loadCosmeticFilters: true }); + const engine2 = FilterEngine.empty({ loadCosmeticFilters: false }); + expect(() => FilterEngine.merge([engine1, engine2])).to.throw( + `config "loadCosmeticFilters" of all merged engines must be the same`, + ); + }); + + it('does not check overridden configs', () => { + const engine1 = FilterEngine.empty({ enableCompression: true }); + const engine2 = FilterEngine.empty({ enableCompression: false }); + let engine: FilterEngine; + expect(() => { + engine = FilterEngine.merge([engine1, engine2], { + overrideConfig: { enableCompression: false }, + }); + }).not.to.throw(); + expect(engine!.config).to.have.property('enableCompression').that.equal(false); + }); + }); + context('with resources', () => { it('throws with different checksums', () => { const engine1 = FilterEngine.empty();