isolated-vm
Advanced tools
Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "isolated-vm", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Access to multiple isolates", | ||
@@ -5,0 +5,0 @@ "main": "isolated-vm.js", |
@@ -48,6 +48,3 @@ [](https://www.npmjs.com/package/isolated-vm) | ||
If you are using Ubuntu please note that version 16 (Xenial) or greater is required. This project | ||
will *not* build using gcc 4.9. | ||
WHO IS USING ISOLATED-VM | ||
@@ -54,0 +51,0 @@ ------------------------ |
@@ -64,2 +64,4 @@ 'use strict'; | ||
// Test dead promise (This causes a memory leak! Don't do this!) | ||
// Disabled test because `timeout` is now paused when the isolate is not active. | ||
/* | ||
global.setSync('deadPromise', new ivm.Reference(function() { | ||
@@ -69,1 +71,2 @@ return new Promise(() => {}); | ||
isolate.compileScriptSync('deadPromise.applySyncPromise(undefined, [])').run(context, { timeout: 1 }).catch(() => 0); | ||
*/ |
'use strict'; | ||
let v8 = require('v8'); | ||
let ivm = require('isolated-vm'); | ||
const v8 = require('v8'); | ||
const ivm = require('isolated-vm'); | ||
const assert = require('assert'); | ||
@@ -91,1 +92,34 @@ // Get the error chain set up | ||
} | ||
// Try custom errors | ||
{ | ||
let isolate = new ivm.Isolate; | ||
let context = isolate.createContextSync(); | ||
let script = isolate.compileScriptSync(` | ||
class Hello extends Error { | ||
get name() { return 'Hello';} | ||
}; | ||
throw new Hello('message'); | ||
`); | ||
try { | ||
script.runSync(context); | ||
assert.fail('Did not throw'); | ||
} catch (err) { | ||
assert.equal(err.name, 'Hello'); | ||
assert.equal(err.message, 'message'); | ||
} | ||
} | ||
// Check errors with newlines in message | ||
{ | ||
let isolate = new ivm.Isolate; | ||
let context = isolate.createContextSync(); | ||
let script = isolate.compileScriptSync('throw new Error("HELLO\\nWORLD")'); | ||
try { | ||
script.runSync(context); | ||
assert.fail('Did not throw'); | ||
} catch (err) { | ||
assert.equal(err.stack.match(/HELLO/g).length, 1); | ||
assert.equal(err.stack.match(/WORLD/g).length, 1); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
415219
2213
606