Nov 8, 2010 10:35 PM
I asked in the IDEA forum if it's possible to debug Firefox Extensions (http://devnet.jetbrains.net/thread/291548). I haven't received an answer there, but I believe the current answer is you can't. I verified this by looking through the current JetBrains firefox connector extension code and seeing that it ignores chrome files.
But, I decided not to take no for an answer :). After a bit of work I have hacked the EAP connector so it will support debugging extensions. I'm hoping these changes can be added to the EAP, and I have attached the patch file, the implemention details below. I have also created a youtrack feature request at http://youtrack.jetbrains.net/issue/WI-3915 to add this functionality to the EAP.
If other folks want to try it out you can use the attached js files to add the functionalty to the jetbrains connector. The jetbrains connector is the addon that WebStorm adds when you first debug firefox. To turn on extension debugging download scripts.js and util.js and use them to replace the ones in <profile path>/extensions\firstname.lastname@example.org\chrome\chromeFiles\content. These files are for the JetBrains Connector 0.3.1 that comes with WebStorm EAP WS-98.271, I'll update here if a new version comes along and needs changes.
Once you have replaced the files and restarted Firefox, WebStorm will be able to see and debug js files Firefox extensions. Just open the js file and set the breakpoint like you normally do. Extension files will also be visible in the debugger scripts tab. You will not see or be able to debug files that are in jars, you need unjar them if you want to debug.
Implementation Details (hopefully so the nice folks at JetBrains can add this to WebStorm permanently):
While it took me a while to figure things out, the actual changes are pretty straightforward:
I updated the function not ignore chrome files if they can be mapped to a local file. In my version this is turned on my deault using the constant IGNORE_SYSTEM_FILES, but I suggest it should be an option in WebStorm debugger settings that defaults to false. I also continue to ignore files that WebStorm can't debug (including files in jars).
New function that returns the local file URL for a Chrome URL.
utils.js/crs and ios
I use these to access Firefox interfaces, but they should probably be moved to services.js like the rest of the services you access. I left them here just to keep the changes in the same place.
Happily you already had this hook to deal with converting Firefox file:// urls to file:/// urls for the WebStorm IDE. I just updated it to also convert chrome:// urls to file:/// urls as well. Everywhere else inside the connector original chrome:// url is used.
- scripts.js (5.9 K)
- utils.js (4.9 K)
- jetBrainsConnector031.dgrAddChromeSupport.patch.zip (1.9 K)