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 hidden or 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"); |
a follow up is here:
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it is a bug and a future because it does exactly what it says. it does "run in a new context"
I have not found a solution for this for jsdom.
But solved it for myself by simply combining the scripts together.
but mysteriously when I also combined the jquery in it did not worked so I left it as a separate file
http://github.com/shimondoodkin/nodejs-waze/blob/master/index.js