Created
October 24, 2010 01:23
-
-
Save shimondoodkin/642943 to your computer and use it in GitHub Desktop.
demonstrates that the contexts are not referenced in runInNewContext when running in same context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//licensed public domain | |
var sandbox = { setTimeout: setTimeout, console:console}; | |
var myscript=0; | |
function run_scripts_in_same_context(text) | |
{ | |
process.binding('evals').Script.runInNewContext(text,sandbox,'myfile'+(myscript++)+'.js'); | |
} | |
run_scripts_in_same_context('var x="1"; function showx(){console.log("x="+x);} setTimeout(function(){showx();},100)'); | |
run_scripts_in_same_context('x="5"; showx();'); | |
console.log("the last x should be 5, if it is 1 so the contexts are not referenced"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
a follow up is here:
https://gist.github.com/752345