vm-browserify icon indicating copy to clipboard operation
vm-browserify copied to clipboard

Shouldn't dispose of iframe after run

Open amasad opened this issue 11 years ago • 3 comments
trafficstars

In node vm:

var c = vm.createContext({});
vm.runInContext('Array.foo = 1', c);
assert(1 === vm.runInContext('Array.foo'));

And that's not the case in this module because it disposes of iframe (real context) after each run.

amasad avatar Dec 27 '13 23:12 amasad

Interesting. Closer inspection of node's context objects reveals that upon running something in a context the context object receives its own (non-enumerable) copy of every global, which is not identical with the current global.

I think the problem is that vm-browserify only copies properties which were already on the context before the eval or were introduced by the eval'd code.

pluma avatar Jan 20 '14 17:01 pluma

It seems very hard to match the exact behavior on both so I wrote a more simplified module: context-eval

amasad avatar Jan 20 '14 19:01 amasad

it seems that the iframe disposal also prevents you from running async code inside a context, which breaks some stuff I wanted to do

tcql avatar Mar 17 '15 23:03 tcql