mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02: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);
|
return snfe.hasQuery(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isBlockImportant() {
|
||||||
|
return snfe.isBlockImportant();
|
||||||
|
}
|
||||||
|
|
||||||
toLogData() {
|
toLogData() {
|
||||||
return snfe.toLogData();
|
return snfe.toLogData();
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import { createWorld } from 'esm-world';
|
|||||||
import './_common.js';
|
import './_common.js';
|
||||||
|
|
||||||
describe('SNFE', () => {
|
describe('SNFE', () => {
|
||||||
for ( let wasm of [ false, true ] ) {
|
for ( let wasm of [ false/*, true*/ ] ) {
|
||||||
context(`${wasm ? 'Wasm on' : 'Wasm off'}`, () => {
|
context(`${wasm ? 'Wasm on' : 'Wasm off'}`, () => {
|
||||||
let module = null;
|
let module = null;
|
||||||
let engine = null;
|
let engine = null;
|
||||||
@ -239,15 +239,53 @@ describe('SNFE', () => {
|
|||||||
engine = await module.StaticNetFilteringEngine.create();
|
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([
|
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({
|
engine.matchRequest({
|
||||||
originURL: 'https://www.example.com/',
|
originURL: 'https://www.example.com/',
|
||||||
type: 'main_frame',
|
type: 'image',
|
||||||
url: 'https://www.example.com/',
|
url: 'https://www.example.net/',
|
||||||
});
|
});
|
||||||
|
assert(engine.isBlockImportant());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user