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:
parent
5f8c179642
commit
a76935b232
@ -237,6 +237,10 @@ class StaticNetFilteringEngine {
|
||||
return snfe.hasQuery(details);
|
||||
}
|
||||
|
||||
isBlockImportant() {
|
||||
return snfe.isBlockImportant();
|
||||
}
|
||||
|
||||
toLogData() {
|
||||
return snfe.toLogData();
|
||||
}
|
||||
|
@ -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());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user