This project has moved and is read-only. For the latest updates, please go here.

envjs or jsdom support

Jun 21, 2012 at 12:18 PM
Edited Jun 21, 2012 at 12:39 PM

Hi I just had a quick go trying to get envjs to work (as you probably know, it's a js implementation of a browser). I had a nutty plan to create an HTML+JS MVC view engine (I've managed to make a JS only view engine using jurassic).

Envjs apparently is only tested against Rhino JS so I was expecting some errors along the lines of CommonJs modules that aren't implemented.

Anyway, I opened up LinqPad, and downloaded env.js and nugetted in jurassic, and ran 


void Main()
  var engine = new Jurassic.ScriptEngine(); 


I changed line 6778 from:

set body(){console.log('set body');/**in firefox this is a benevolent do nothing*/},


set body(v){console.log('set body');/**in firefox this is a benevolent do nothing*/},

in order to avoid a syntax error (but a weird one, as other setters are defined without a single argument). Then I re-ran it and got an error:

TypeError: 'b.__lookupGetter__' is not a function
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()

Which is some non standard thing: which exists in Rhino. At this point I realised I was out of my depth.

Do you think you will ever be able to work on making envjs work on Jurassic? It would provide all kinds of things for .NET that aren't currently available (e.g. managed code web browser, my lovely view engine). 

If not don't worry, thanks so much for the project!



edit: I have now seen from that jsdom support would probably be enough for my view engine. I'm investigating that now.


edit 2: I think I'm out of my depth here. From other posts on this forum it sounds like work needs to be done to get require.js to work, and that's just a dependency of jsdom!

Jun 26, 2012 at 12:33 PM

I'm hesitant to support require because it's non-standard.  ECMAScript 6 does have a way of importing modules, but it's quite different.  In the long run the standardized version is almost certain to win out, so there's very little chance I'll implement require, sorry.

Jun 26, 2012 at 1:08 PM
Edited Jun 26, 2012 at 2:19 PM

require should be fairly easy to implement in js/c# though, shouldn't it? Just do open file->eval? (have never looked at it, just guessing).


As in; built on top of Jurassic, not in Jurassic.

Jun 27, 2012 at 3:48 PM

I am not affiliated with Jurassic, but...

BTW, concerning __lookupGetter__ and __lookupSetter__, etc. you can still use features like these if you use ...

- Object.getOwnPropertyDescriptor

- Object.defineProperty

Where can I find your MVC view code? I'd be interested in checking it out. :)

Jun 27, 2012 at 4:34 PM
Edited Jun 27, 2012 at 4:35 PM
It's really just a starting point, and I think a bit useless unless you can get a DOM implementation working. Go wild!

Jun 28, 2012 at 12:46 AM
Edited Jun 28, 2012 at 12:49 AM

Just FYI, I just added "require()" and "exports" support to JuraScript (which wraps Jurassic with COM support, an installer, a console, etc.). If you are still implementing jsdom, you will need this unless you alter the script. I plan on having a release with this functionality shortly.

I will say, I think using the ECMAScript 6 standard would be the best thing to do, but it was a simple feature to add.