cross-safe-eval
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -0,4 +1,5 @@ | ||
var globalScope = global ? global : window // node.js and browser | ||
var globals = Object.getOwnPropertyNames(globalScope) | ||
module.exports = function makeSafeEval (include) { | ||
var globals = Object.getOwnPropertyNames(this) | ||
var clearGlobals = '' | ||
@@ -5,0 +6,0 @@ for (var i = 0, len = globals.length; i < len; i++) { |
{ | ||
"name": "cross-safe-eval", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Node.js and browser 8 lines implementation of a safe eval", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
13
test.js
@@ -14,3 +14,3 @@ var test = require('tape') | ||
t.plan(8) | ||
t.plan(10) | ||
@@ -34,2 +34,13 @@ var safeEval1 = makeSafeEval() | ||
var fn = function () { | ||
this.method = function () { | ||
var safeEval3 = makeSafeEval() | ||
t.equal(ignoreErrors(() => safeEval3('window')), undefined, 'should have no access to local this') | ||
t.equal(ignoreErrors(() => safeEval3('console')), undefined, 'should have no access to local this') | ||
} | ||
} | ||
a = new fn() | ||
a.method() | ||
}) |
5048
46