How to watch variables in the Firefox Scratchpad?

左心房为你撑大大i 提交于 2019-12-07 07:56:51

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/18364124/how-to-watch-variables-in-the-firefox-scratchpad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!