How to watch variables in the Firefox Scratchpad?

991 views Asked by At

I use Scratchpad in Firefox to run scripts against web pages and it works fine.

Is there any way to debug and watch variables during execution?

2

There are 2 answers

0
Alex Angas On BEST ANSWER

Right now it's not possible to view code entered into the Scratchpad using the Debugger pane of the Firefox Developer Tools. It just shows up in the sources like Scratchpad/1 with content:

Error loading source:
loadSourceError

This will be fixed in bugs 816988 and 813087 so go and vote for those.

What you can do is:

  1. Add a debugger; statement to the line in your Scratchpad code where you want to break. It will still be possible to view variable values, scope, etc...

  2. Interact with the Debugger object directly. Here is a video that explains getting started with that (note you can now set the option "Enable chrome and add-on debugging" in Developer Tool settings instead of going to about:config). You will also want to review the API.

0
monk-time On

The issue mentioned in Alex's reply was fixed in Firefox 47 (see bug 1252077), you can now use debugger; statements in your Scratchpad code or set breakpoints directly in the Debugger. The Scratchpad script's source should appear there after you have run the script at least once. Make sure you have Dev Tools open.

It's a bit awkward though since Scratchpad scripts don't update in the Debugger window after they were modified in the Scratchpad, you need to refresh the page you're on first or use ExecuteReload and Run in the Scratchpad.