vm: add isContext; prevent double-contextifying
authorDomenic Denicola <domenic@domenicdenicola.com>
Sat, 24 Aug 2013 19:45:02 +0000 (15:45 -0400)
committerBen Noordhuis <info@bnoordhuis.nl>
Wed, 28 Aug 2013 10:11:09 +0000 (12:11 +0200)
commit9c110d80276282c0f8c63bd4c6973f28e57c9eb5
tree58660a14f29f29cb9c9852001d2b83147da6d477
parenta3bf3d10ef4b373870c6bb475f8fd5b6ede953cc
vm: add isContext; prevent double-contextifying

Previously, calling `vm.createContext(o)` repeatedly on the same `o`
would cause new C++ `ContextifyContext`s to be created and stored on
`o`, while the previous resident went off into leaked-memory limbo.
Now, repeatedly trying to contextify a sandbox will do nothing after
the first time.

To detect this, an independently-useful `vm.isContext(sandbox)` export
was added.
lib/vm.js
src/node_contextify.cc
test/simple/test-vm-create-context-arg.js
test/simple/test-vm-is-context.js [new file with mode: 0644]