wrappedJSObject

Wednesday, February 8. 2006

If you implement an XPConnect interface in Javascript (e.g. nsITreeView if you don't want to use RDF to display data in a tree), you might need to access properties or methods inside your javascript object which are not part of the interface.

This can be easily achieved using a special object property.


Continue reading "wrappedJSObject"

Bridging Worlds

Friday, February 3. 2006

Let's say you have massive amounts of Javascript.

Let's say you want to make the logic contained therein available to another language.

How would you go about that?

What we chose was compiling Omar Kilani's php-js extension which makes Mozilla's Javascript engine available as PHP extension.

This was totally sufficient in our case to extend existing testing procedures around the Javascript code. Developers can now run "make test" on the development server which will cause Javascript code to be tested. Thus we have incorporated something which was originally manual client-side testing into a completely automated test system.

Additionally, we will be able to avoid writing the same business logic in two languages. Instead, common parts can be written in JS and executed from another scripting language.

There are also modules for Perl and Python which embed the SpiderMonkey JS engine. Feel free to post links to other bindings.

Connecting the Gnu to the Fox

Thursday, February 2. 2006

For some time now various packages have been available to directly evaluate JS code written in Emacs in Mozilla -- without any reloading.

The newest approach is from Massimiliano Mirra called MozRepl. It promises to break us free from the write/save/restart/test cycle. What it currently does is this: You load/write a piece of Javascript code in Emacs, copy it into a Emacs buffer, send this buffer to the so-called JS shell server on the Mozilla end where the JS code is evaluated in a specific Mozilla window.

Further resources include:

JS Shell Server
Intro to JS Shell Server

Now, what from I can tell this just evaluates a piece of JS in some arbitrary Mozilla window. You cannot edit a specific JS source file in a running XUL application just yet. Now, would not that be cool? We really need a remote debugging protocol for Mozilla which includes manipulating JS objects and thus functions. I'd love to hear your comments on why this has not happened yet.