Fix #1801 vm: Use 'sandbox' as global_prototype
authorelliottcable <me@ell.io>
Fri, 14 Oct 2011 07:42:18 +0000 (03:42 -0400)
committerisaacs <i@izs.me>
Wed, 19 Oct 2011 00:56:35 +0000 (17:56 -0700)
commit200df8641b43902adc73cce6b89d3e84a91dd3e6
treeaaa3c9b3e61da4b263538bf2ddba452d2456903b
parentd9bc8455cbda69df5c477f971176471cde45a5f6
Fix #1801 vm: Use 'sandbox' as global_prototype

Squashed commit:

(- re tests) Cleaning up the `Script` test suite.

For whatever reason, there were several duplicate test files related to `Script`
and the `'vm'` module. I removed these, and fixed a few other small issues.
(More fixes coming in subsequent commits.)

Squashes: 19e86045a0..1e3dcff4eb

(api fix:1801 new:1801) `'vm'` module uses sandbox as prototype

As described in GH-1801, the `'vm'` module was handling the `sandbox` object
provided by the API consumer in a particularly terrible and fragile fashion: it
was simply shallow-copying any enumerable properties from the sandbox onto the
global context before executing the code, and then eventually copying any values
on the global context back into the sandbox object *afterwards*.

This commit removes all of that implementation, and utilizes the passed sandbox
object as the *prototype of the context* instead. A bit of a hack, but a very
effective one.

This no longer allows for new variables created in the global context to be
placed into your sandbox after execution has completed, but that’s for the best
anyway, as it’s not very in line with the concept of a “box of passed-in
context.” I’m planning to further implement an interface for API consumers to
acquire the *actual global* from within the VM soon, thus allowing for
separation-of-concerns: providing data *to* the VM via the sandbox-prototype,
and exploring the internal environment of the VM itself.

// GitHub cruft: closes #1801

Squashes: 43b8e3c..209ed86
src/node_script.cc
test/simple/test-script-context.js
test/simple/test-script-new.js
test/simple/test-script-static-context.js [deleted file]
test/simple/test-script-static-new.js [deleted file]
test/simple/test-script-static-this.js [deleted file]
test/simple/test-script-this.js