From 2a130704e3660f8ddb12c64cfd1d3297d7682890 Mon Sep 17 00:00:00 2001 From: Manish Jethani Date: Wed, 18 Aug 2021 16:58:23 +0530 Subject: [PATCH] Add check-leaks make target (#3837) --- Makefile | 3 +++ platform/npm/package.json | 3 ++- platform/npm/tests/leaks.js | 30 ++++++++++++++++++++++++++++++ platform/npm/tests/wasm.js | 2 ++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 platform/npm/tests/leaks.js diff --git a/Makefile b/Makefile index 149a1573d..08aa75eaa 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,9 @@ test: npm test-full-battery: npm cd dist/build/uBlock0.npm && npm run test-full-battery +check-leaks: npm + cd dist/build/uBlock0.npm && npm run check-leaks + dist/build/uBlock0.dig: tools/make-nodejs.sh $(sources) $(platform) $(assets) tools/make-dig.sh diff --git a/platform/npm/package.json b/platform/npm/package.json index f38743893..106bcaf0c 100644 --- a/platform/npm/package.json +++ b/platform/npm/package.json @@ -8,7 +8,8 @@ "build": "node build.js", "lint": "eslint js/ *.js tests/*.js", "test": "c8 --include=index.js --include=js/**/*.js node test.js --mocha", - "test-full-battery": "c8 --include=index.js --include=js/**/*.js node test.js --mocha --full-battery" + "test-full-battery": "c8 --include=index.js --include=js/**/*.js node test.js --mocha --full-battery", + "check-leaks": "mocha --check-leaks tests/leaks.js" }, "repository": { "type": "git", diff --git a/platform/npm/tests/leaks.js b/platform/npm/tests/leaks.js new file mode 100644 index 000000000..1963c14a7 --- /dev/null +++ b/platform/npm/tests/leaks.js @@ -0,0 +1,30 @@ +/******************************************************************************* + + 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'; + +/******************************************************************************/ + +describe('Leaks', () => { + it('should not leak', async () => { + await import('../index.js'); + }); +}); diff --git a/platform/npm/tests/wasm.js b/platform/npm/tests/wasm.js index 3bd449e99..3a4eb6333 100644 --- a/platform/npm/tests/wasm.js +++ b/platform/npm/tests/wasm.js @@ -19,6 +19,8 @@ Home: https://github.com/gorhill/uBlock */ +/* globals WebAssembly */ + 'use strict'; /******************************************************************************/