Using the JavaScript Debugger API in a Jetpack add-on

72 views
Skip to first unread message

David Bruant

unread,
Jun 5, 2013, 9:28:09 PM6/5/13
to mozilla-la...@googlegroups.com
Hi,

I've been trying to use the JavaScript Debugger API [1] from a Jetpack
add-on and failed.
From add-on context, I don't think I have access to the global to pass
argument to the Debugger constructor.
As content script, I get the following error:
"Error: Permission denied to access property 'utils'"
when trying
Components.utils.import("resource://gre/modules/jsdebugger.jsm");

Is there a way to use the Debugger API in a Jetpack add-on? I'm trying
to package a script that makes useful stack traces [2].

Thanks,

David

[1]
https://developer.mozilla.org/en-US/docs/SpiderMonkey/JS_Debugger_API_Guide
[2] https://github.com/DavidBruant/usefulStackTrace

Dietrich Ayala

unread,
Jun 5, 2013, 11:04:38 PM6/5/13
to mozilla-la...@googlegroups.com
Can't tell for sure if this is your problem without a code sample, but
you need to something like the following to get access to
Components.utils in Jetpack add-ons:

const {Cu} = require('chrome')

See for more info:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/chrome.html
> --
> You received this message because you are subscribed to the Google Groups
> "mozilla-labs-jetpack" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mozilla-labs-jet...@googlegroups.com.
> To post to this group, send email to mozilla-la...@googlegroups.com.
> Visit this group at
> http://groups.google.com/group/mozilla-labs-jetpack?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

David Bruant

unread,
Jun 6, 2013, 1:37:37 AM6/6/13
to mozilla-la...@googlegroups.com, Dietrich Ayala
Le 05/06/2013 20:04, Dietrich Ayala a �crit :
> Can't tell for sure if this is your problem without a code sample, but
> you need to something like the following to get access to
> Components.utils in Jetpack add-ons:
>
> const {Cu} = require('chrome')
>
> See for more info:
> https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/chrome.html
Oh yes, I was missing that, thanks!
But that's insufficient. Or it's sufficient, but not in the right place.
"require" and Chrome privileges are available only in the add-on
process. But I wish to "apply" the debugger to the content global.
In the script I run from Chrome-enabled scratchpad, I wrote:
var win = gBrowser.selectedBrowser.contentWindow;
var dbg = new Debugger(win);

And I'm under the impression that Jetpack doesn't provide access to
gBrowser.selectedBrowser. Maybe the whole process isolation thing. But
in my case, I need to be plugged directly to the content global.

If I recall correctly, the Debugger API adds its stack frames to the
stack of the content effectively running "on top of" content, so it
requires some intimacy between the content and the Debugger API. For
that reason, I feel the Debugger API needs to be available in the
content process.


It seems counter-intention to ask for the content window to be available
in the add-on process. However, would it be possible to make the
Debugger API available in the content part of addons?
Maybe after an opt-in to pagemod? Or as an undocumented feature? :-)

pageMod.PageMod({
include: "*",
superPower: {
debugger: true
}
contentScript: "/*some code using Debugger*/"
});

I realize this goes a bit against the intention of separating
privileges, but I can't find a better idea to make have the Debugger API
work with Jetpack.

Thanks,

David

Dietrich Ayala

unread,
Jun 6, 2013, 1:46:39 AM6/6/13
to mozilla-la...@googlegroups.com
IIRC there was a thread on here earlier today about accessing content
windows, actually.

On Wed, Jun 5, 2013 at 10:37 PM, David Bruant <brua...@gmail.com> wrote:

David Bruant

unread,
Jun 6, 2013, 2:08:58 AM6/6/13
to mozilla-la...@googlegroups.com, Dietrich Ayala
Le 05/06/2013 22:46, Dietrich Ayala a �crit :
> IIRC there was a thread on here earlier today about accessing content
> windows, actually.
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah!
That works indeed! Thanks for the indication and thanks to ZER0 for the
high-level-tab -> low-level-tab function!

So perfect!!!

Thanks !

David
Reply all
Reply to author
Forward
0 new messages