1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-22 18:32:45 +01:00

Add more npm tests

Also, disable wasm tests, currently erroring with:

    WebAssembly.Memory(): could not allocate memory
This commit is contained in:
Raymond Hill 2021-10-04 12:47:12 -04:00
parent 5f8c179642
commit a76935b232
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 47 additions and 5 deletions

View File

@ -237,6 +237,10 @@ class StaticNetFilteringEngine {
return snfe.hasQuery(details);
}
isBlockImportant() {
return snfe.isBlockImportant();
}
toLogData() {
return snfe.toLogData();
}

View File

@ -30,7 +30,7 @@ import { createWorld } from 'esm-world';
import './_common.js';
describe('SNFE', () => {
for ( let wasm of [ false, true ] ) {
for ( let wasm of [ false/*, true*/ ] ) {
context(`${wasm ? 'Wasm on' : 'Wasm off'}`, () => {
let module = null;
let engine = null;
@ -239,15 +239,53 @@ describe('SNFE', () => {
engine = await module.StaticNetFilteringEngine.create();
});
it('should match block-important pure-hostname filter', async () => {
it('should match pure-hostname block filter', async () => {
await engine.useLists([
{ name: 'test', raw: '@@||example.com^\n||example.com^$important' },
{ name: 'test', raw: '||example.net^' },
]);
const r = engine.matchRequest({
originURL: 'https://www.example.com/',
type: 'image',
url: 'https://www.example.net/',
});
assert.strictEqual(r, 1);
});
it('should match pure-hostname exception filter', async () => {
await engine.useLists([
{ name: 'test', raw: '||example.net^\n@@||example.net^' },
]);
const r = engine.matchRequest({
originURL: 'https://www.example.com/',
type: 'image',
url: 'https://www.example.net/',
});
assert.strictEqual(r, 2);
});
it('should match pure-hostname block-important filter', async () => {
await engine.useLists([
{ name: 'test', raw: '@@||example.net^\n||example.net^$important' },
]);
const r = engine.matchRequest({
originURL: 'https://www.example.com/',
type: 'image',
url: 'https://www.example.net/',
});
assert.strictEqual(r, 1);
assert(engine.isBlockImportant());
});
it('should detect the filter is block-important', async () => {
await engine.useLists([
{ name: 'test', raw: '||example.net^$important' },
]);
engine.matchRequest({
originURL: 'https://www.example.com/',
type: 'main_frame',
url: 'https://www.example.com/',
type: 'image',
url: 'https://www.example.net/',
});
assert(engine.isBlockImportant());
});
});
});