Run request data tests with Wasm enabled too (#3829)

This commit is contained in:
Manish Jethani 2021-08-16 18:52:35 +05:30 committed by GitHub
parent 36377320ae
commit ffb4fe9b8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 8 deletions

View File

@ -59,12 +59,14 @@ describe('Request data', () => {
texttrack: 'other',
};
let enableWASM = null;
let engine = null;
before(async () => {
const { StaticNetFilteringEngine } = await import('../index.js');
const module = await import('../index.js');
enableWASM = module.enableWASM;
engine = await StaticNetFilteringEngine.create();
engine = await module.StaticNetFilteringEngine.create();
await engine.useLists([
read('./data/assets/ublock/badware.txt')
@ -92,14 +94,26 @@ describe('Request data', () => {
]);
});
for ( let i = 0; i < requests.length; i++ ) {
const { url, frameUrl, cpt } = requests[i];
const request = { url, originURL: frameUrl, type: typeMap[cpt] };
// False must go first:
// https://github.com/gorhill/uBlock/pull/3828#issuecomment-899470383
for ( let wasm of [ false, true ] ) {
context(`${wasm ? 'Wasm on' : 'Wasm off'}`, () => {
before(async () => {
if ( wasm ) {
assert(await enableWASM());
}
});
const expected = results[i];
for ( let i = 0; i < requests.length; i++ ) {
const { url, frameUrl, cpt } = requests[i];
const request = { url, originURL: frameUrl, type: typeMap[cpt] };
it(`should ${expected === 1 ? 'block' : 'allow'} ${request.type} URL ${request.url} from origin ${request.originURL}`, () => {
assert.equal(engine.matchRequest(request), expected);
const expected = results[i];
it(`should ${expected === 1 ? 'block' : 'allow'} ${request.type} URL ${request.url} from origin ${request.originURL}`, () => {
assert.equal(engine.matchRequest(request), expected);
});
}
});
}
});