Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Revert "removing copy-back-to-sandbox in vm"
Browse files Browse the repository at this point in the history
After a long discussion with @isaacs, we’ve decided to defer consideration of
API changes to ~0.7, and reduce this change to a relatively safe subset of
changes that don’t affect the API for immediate inclusion in 0.6.

The changes reverted in this commit will be coming back in 0.7, after a
discussion of the alternatives.

This reverts commit 2c1f5206bbb23bd34624acbcfb475dddcda0b883.
  • Loading branch information
ELLIOTTCABLE committed Oct 19, 2011
1 parent a568777 commit 209ed86
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/node_script.cc
Expand Up @@ -439,6 +439,11 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args) {
result = args.This();
}

if (context_flag == userContext || context_flag == newContext) {
// success! copy changes back onto the sandbox object.
CloneObject(args.This(), context->Global()->GetPrototype(), sandbox);
}

if (context_flag == newContext) {
// Clean up, clean up, everybody everywhere!
context->Exit();
Expand Down
2 changes: 1 addition & 1 deletion test/simple/test-script-context.js
Expand Up @@ -40,7 +40,7 @@ assert.equal('lala', context.thing);
common.debug('test updating context');
script = new Script('foo = 3;');
result = script.runInContext(context);
//assert.equal(3, context.foo); // TODO: REIMPLEMENT ME
assert.equal(3, context.foo);
assert.equal('lala', context.thing);

// Issue GH-1801
Expand Down
4 changes: 2 additions & 2 deletions test/simple/test-script-new.js
Expand Up @@ -69,8 +69,8 @@ foo = 2;
sandbox = { foo: 0, baz: 3 };
script = new Script(code);
var baz = script.runInNewContext(sandbox);
//assert.equal(1, context.foo); // TODO: REIMPLEMENT ME
//assert.equal(2, context.bar); // TODO: REIMPLEMENT ME
assert.equal(1, sandbox.foo);
assert.equal(2, sandbox.bar);
assert.equal(2, foo);

common.debug('call a function by reference');
Expand Down

0 comments on commit 209ed86

Please sign in to comment.