This project is read-only.

Augmenting the global scope (with setTimeout, etc)

May 8, 2011 at 12:21 AM

Hi All,

Firstly, great work on this framework, I am currently using Node + jsdom + nclosure to run my JS unit tests straight from visual studio.  However using Node is a huge pain on windows and integrating to an NUnit test is even more of a pain as its all done through Process.Start.  That is why I'm now looking at more .Net friendly options for this purpose (JavaScript.Net and IronJS).

However I am having a few problems, Firstly is a strange NullReferenceException in JavascriptContext.Run function which I cannot debug as I cannot build the JS.Net using VS2010.  This error only appears once I load the google closure libraries into the context.  Anyhow, I'm still trying to find a reproduceable snippet I can post in an issue, so lets leave this for now.

However something else I'm having an issue with is trying to register global functions, i.e. setTimeout, clearTimeout, etc.  I can create a "global" object and add these functions to this object and then I can do something like 'context.Run("var setTimeout = global.setTimeout;")' but this strikes me as ugly.  Is there a nicer way of doing this?  Also arent these functions already available in V8, why would I have to re-implement them, it sounds like a quick way to get into trouble with V8's lack of thread safety.

Again, thanks heaps for making this publicly available and under such a nice license. Good work.

Thanks in advance