From a1817b49d02dc5b0fd7067dd434e15e19a594433 Mon Sep 17 00:00:00 2001 From: Patrik Simek Date: Mon, 5 Apr 2021 22:11:32 +0200 Subject: [PATCH] Fix tests --- test/vm.js | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/test/vm.js b/test/vm.js index f6f2bf1..487f6a8 100644 --- a/test/vm.js +++ b/test/vm.js @@ -888,29 +888,31 @@ describe('VM', () => { `), /e is not a function/); }); - it('Dynamic import attack', (done) => { - process.once('unhandledRejection', (reason) => { - assert.strictEqual(reason.message, 'process is not defined'); - done(); - }); + if (NODE_VERSION >= 10) { + it('Dynamic import attack', (done) => { + process.once('unhandledRejection', (reason) => { + assert.strictEqual(reason.message, 'process is not defined'); + done(); + }); - const vm2 = new VM(); + const vm2 = new VM(); - vm2.run(` - (async () => { - try { - await import('oops!'); - } catch (ex) { - // ex is an instance of NodeError which is not proxied; - const process = ex.constructor.constructor('return process')(); - const require = process.mainModule.require; - const child_process = require('child_process'); - const output = child_process.execSync('id'); - process.stdout.write(output); - } - })(); - `); - }); + vm2.run(` + (async () => { + try { + await import('oops!'); + } catch (ex) { + // ex is an instance of NodeError which is not proxied; + const process = ex.constructor.constructor('return process')(); + const require = process.mainModule.require; + const child_process = require('child_process'); + const output = child_process.execSync('id'); + process.stdout.write(output); + } + })(); + `); + }); + }; after(() => { vm = null;