mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-20 01:12:38 +01:00
Use createWorld() in request data tests (#3832)
This commit is contained in:
parent
75c386b4d9
commit
f020e5334c
7
platform/npm/package-lock.json
generated
7
platform/npm/package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@gorhill/ubo-core",
|
||||
"version": "0.1.8",
|
||||
"version": "0.1.9",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -526,8 +526,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"esm-world": {
|
||||
"version": "github:mjethani/esm-world#0e5a77a5c0cb22de28616bba9ed7247dee218fb3",
|
||||
"from": "github:mjethani/esm-world#0e5a77a5c0cb22de28616bba9ed7247dee218fb3",
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/esm-world/-/esm-world-0.1.1.tgz",
|
||||
"integrity": "sha512-BrUju/zoltW1L3MXWM3WZFpZddekSLnl0st7L//luZs3fbJ/o/3knWByewSic3RsMWCp3lGIh0GfA9WOEU8QxQ==",
|
||||
"dev": true
|
||||
},
|
||||
"espree": {
|
||||
|
@ -32,7 +32,7 @@
|
||||
"devDependencies": {
|
||||
"c8": "^7.8.0",
|
||||
"eslint": "^7.32.0",
|
||||
"esm-world": "github:mjethani/esm-world#0e5a77a5c0cb22de28616bba9ed7247dee218fb3",
|
||||
"esm-world": "0.1.1",
|
||||
"mocha": "^9.0.3",
|
||||
"scaling-palm-tree": "github:mjethani/scaling-palm-tree#15cf1ab37e038771e1ff8005edc46d95f176739f"
|
||||
}
|
||||
|
@ -32,7 +32,12 @@ import { promisify } from 'util';
|
||||
/******************************************************************************/
|
||||
|
||||
async function spawnMocha() {
|
||||
await promisify(spawn)('mocha', [ '--experimental-vm-modules', '--no-warnings', 'tests', '--reporter', 'progress' ], { stdio: [ 'inherit', 'inherit', 'inherit' ] });
|
||||
const files = [
|
||||
'tests/snfe.js',
|
||||
'tests/request-data.js',
|
||||
];
|
||||
|
||||
await promisify(spawn)('mocha', [ '--experimental-vm-modules', '--no-warnings', ...files, '--reporter', 'progress' ], { stdio: [ 'inherit', 'inherit', 'inherit' ] });
|
||||
}
|
||||
|
||||
async function main() {
|
||||
|
34
platform/npm/tests/_common.js
Normal file
34
platform/npm/tests/_common.js
Normal file
@ -0,0 +1,34 @@
|
||||
/*******************************************************************************
|
||||
|
||||
uBlock Origin - a browser extension to block requests.
|
||||
Copyright (C) 2014-present Raymond Hill
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import process from 'process';
|
||||
|
||||
process.on('warning', warning => {
|
||||
// Ignore warnings about experimental features like
|
||||
// --experimental-vm-modules
|
||||
if ( warning.name !== 'ExperimentalWarning' ) {
|
||||
console.warn(warning.stack);
|
||||
}
|
||||
});
|
@ -29,6 +29,10 @@ import { createRequire } from 'module';
|
||||
import { dirname, resolve } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
import { createWorld } from 'esm-world';
|
||||
|
||||
import './_common.js';
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
@ -59,14 +63,14 @@ describe('Request data', () => {
|
||||
texttrack: 'other',
|
||||
};
|
||||
|
||||
let enableWASM = null;
|
||||
for ( let wasm of [ false, true ] ) {
|
||||
context(`${wasm ? 'Wasm on' : 'Wasm off'}`, () => {
|
||||
let engine = null;
|
||||
|
||||
before(async () => {
|
||||
const module = await import('../index.js');
|
||||
enableWASM = module.enableWASM;
|
||||
const { StaticNetFilteringEngine, enableWASM } = await createWorld('./index.js', { globals: global });
|
||||
|
||||
engine = await module.StaticNetFilteringEngine.create();
|
||||
engine = await StaticNetFilteringEngine.create();
|
||||
|
||||
await engine.useLists([
|
||||
read('./data/assets/ublock/badware.txt')
|
||||
@ -92,13 +96,7 @@ describe('Request data', () => {
|
||||
read('./data/assets/thirdparties/urlhaus-filter/urlhaus-filter-online.txt')
|
||||
.then(raw => ({ name: 'urlhaus', raw })),
|
||||
]);
|
||||
});
|
||||
|
||||
// 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());
|
||||
}
|
||||
|
@ -24,17 +24,10 @@
|
||||
/******************************************************************************/
|
||||
|
||||
import { strict as assert } from 'assert';
|
||||
import process from 'process';
|
||||
|
||||
import { createWorld } from 'esm-world';
|
||||
|
||||
process.on('warning', warning => {
|
||||
// Ignore warnings about experimental features like
|
||||
// --experimental-vm-modules
|
||||
if ( warning.name !== 'ExperimentalWarning' ) {
|
||||
console.warn(warning.stack);
|
||||
}
|
||||
});
|
||||
import './_common.js';
|
||||
|
||||
let engine = null;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user