slimerjs icon indicating copy to clipboard operation
slimerjs copied to clipboard

Support of remote debugger

Open laurentj opened this issue 11 years ago • 10 comments

PhantomJS has these options

--remote-debugger-port=number
--remote-debugger-autorun=[yes|no]

They allow to debug a script with web developer tools of Google Chrome / Safari.

We should have similar features, working with developer tools of Firefox.

laurentj avatar May 07 '13 08:05 laurentj

:+1:

simonweil avatar Feb 22 '14 21:02 simonweil

Since slimerjs is basically a xulrunner application, it should be easy to remotely debug it. I have tried to do it according to the instructions under https://developer.mozilla.org/en-US/docs/Mozilla/Projects/XULRunner/Debugging_XULRunner_applications

I have tried it under Windows 7. To do this, I first unzipped the omni.ja file into the slimerjs installation directory. Then, following the abovementioned instructions, I added the code to start the DebuggerServer to the file chrome\slimerjs\content\slimerjs.js and the debugging preferences to the file defaults\preferences\prefs.js. This always enables remote debugging, so no additional startup parameters are needed.

When I start slimerjs from the command line, I can see with netstat, that the xulrunner process indeed listens on port 6000. When I then try to connect to port 6000 from the firefox debugger, it loads and loads and eventually it gets a timeout.

As a counter- test I created a trivial "Hello World"- like xul application and was able to remotely debug it on port 6000, so I can exclude any network misconfiguration problems. When I try to connect to the "Hello World"- application, it shows a popup box saying "do you want to allow remote debugging of this program?". When I confirm, the program appears in the debugger.

On the other hand, such a popup box does not appear when I try to connect to the abovementioned slimerjs application modified for remote debugging. So, my question is: does anything in slimerjs prevent such popup boxes from appearing? Or any other ideas?

awinizki avatar Aug 27 '14 09:08 awinizki

Probably because Slimerjs catch all popup for webpage callbacks.

Try by setting this pref to false: devtools.debugger.prompt-connection.

Even it works, it will not be enough. It will be ok to debug SlimerJS itself, but not the script (let's say example.js) given to SlimerJS. First because it is external to SlimerJS code, so it will not be listed into the debugger. Second because the example.js is executed immediately, so we won't have time to set a break point for example.

For the first issue, I guess we have to "configure" the debugger server, by developping an "actor" which will give a list of scripts containing example.js and all others JS/CoffeeScript that are in the same directory (and probably sub-directory).

For the second issue, when there is the --remote-debugger parameter, we could display a button to launch the execution of example.js instead of executing it directly.

I see also an other issue : if we execute step by step a script, and we want to "enter" in a script loaded by require(), if we do nothing, the debugger will enter in the code of require() first. This will not be very friendly as the code may be complex. We should be able to enter directly into the loaded script. So we should find a way to tell to the debugger "do not enter into native function of slimerjs" and "if the function is require, enter directly into the script xxxx.js".

However, I don't know enough how the debugger and its actors work to tell how to fix all of these issues.

laurentj avatar Aug 27 '14 10:08 laurentj

I just tried to set devtools.debugger.prompt-connection to false and it solves my problem!

My script is listed in the debugger and I can debug it normally. In my script I start the webserver and I want to debug the callbacks that process the requests. Of course, I am unable to debug the code that is executed before the server is started, but the callbacks are perfectly debuggable and that is all I want.

Thank you for the advice!

awinizki avatar Aug 27 '14 11:08 awinizki

Btw., to address your two issues:

to solve the first one, the developer has to write, only for development purposes, a script that displays a window with a button that on click starts the "real" script. Then it should be all debuggable. In production environment only the "real" script will be started.

As for the second one: this is a general xulrunner problem and is not specific to slimerjs, so we do not need to solve it here.

awinizki avatar Aug 27 '14 11:08 awinizki

it solves my problem!

Cool!

My script is listed in the debugger and I can debug it normally.

I think it is listed because it has been loaded and executed.

this is a general xulrunner problem

Are you sure? perhaps we could specify some things to the debugger server object, could we?

laurentj avatar Aug 27 '14 11:08 laurentj

:+1:

simonzack avatar Feb 14 '15 13:02 simonzack

I followed instructions provided by @awinizki to enable remote debugging for SlimerJS. I can see a port open on my machine. But when I try to connect from Firefox debugger I get the error message "Unexpected error." I am using Firefox Developer Edition 45.

How can I proceed to look into the issue? My aim is to inspect DOM objects in page using web developer tools' inspector.

xolve avatar Jan 01 '16 13:01 xolve

@xolve This seems to be a limitation of Gecko 44 and up. See issue https://github.com/laurentj/slimerjs/issues/510.

Jip-Hop avatar Jul 26 '16 11:07 Jip-Hop

Debugger server cannot be used anymore in XUL app :-/ https://bugzilla.mozilla.org/show_bug.cgi?id=1244163

laurentj avatar Sep 13 '16 14:09 laurentj