Question

I'm embedding Mozilla's SpiderMonkey in my application and would like to use its new Debugger API introduced in v1.8.6. From the documentation, I understand that this API is not available to 'content code' but only to trusted so-called 'chrome code'. Now I have gone through a number of resources trying to understand how to execute 'chrome code', without much success. My guess is that the trusted script should be execute with JS_EvaluateScriptForPrincipals, but then I cannot understand how to use JSPrincipals...

Any help appreciated, thanks!

Was it helpful?

Solution

For a SpiderMonkey engine embedding, there are no such concepts. The idea of "chrome" and "content" is only legitimate in the browser, where "chrome" is privileged (like the Firefox UI / addons) and "content" is untrusted (like a web page).

When you embed the JS engine you just have access to JavaScript, the language, with its typical built in classes and language features. When you build the shell and run it, you can just type "Debugger" and you'll see the debugger object is present. This happens whenever you create a new global in the SpiderMonkey engine.

$ ./js
js> Debugger
function Debugger() {[native code]}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top