Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

xpcshell

This translation is incomplete. Please help translate this article from English.

xpcshell is an XPConnect-enabled JavaScript Shell. It is a console application that lets you run JavaScript code. Unlike the ordinary JS shell (js), xpcshell lets the scripts running in it access XPCOM functionality.

Prerequisites

You need your own build of Mozilla to use xpcshell.

Running xpcshell

./run-mozilla.sh ./xpcshell

xpcshell is almost always in the same directory as run-mozilla.sh.

$ locate run-mozilla.sh
/usr/lib/firefox-0.10.1/run-mozilla.sh
/usr/lib/thunderbird-0.9/run-mozilla.sh
/usr/local/mozilla/run-mozilla.sh
/opt/mozilla/run-mozilla.sh
/root/.Trash/mozilla/run-mozilla.sh

Just pick one, cd over there, and run-mozilla.sh xpcshell, if it's present. (However, it might not be there if you have a non-debug version of Firefox, Mozilla, Thunderbird, etc.)

$ cd /opt/mozilla
$ ./run-mozilla.sh ./xpcshell
js> 

Using the Latest Version of Javascript

At present, xpcshell doesn't use the latest version of JavaScript, so newer language features, such as the let statement introduced in JavaScript 1.7, are not available. To rectify this, run xpcshell with the -v 180 command-line option, which tells xpcshell to use JavaScript 1.8.

Example

You can input JavaScript, straight to Mozilla.

js> 5+7
12
js> print("Hello, world!")
Hello, world!
js>

See also

Document Tags and Contributors

 Contributors to this page: T0mmypro2001
 Last updated by: T0mmypro2001,