Another common task during Share extension development is to be able to debug out-of-the-box and custom JavaScript files.
This is quite easy to do with Firebug:
- Load the web page that refers to the JavaScript file.
- In the script list select the JavaScript file so the source for it is displayed.
- Set breakpoints in the JavaScript code (by clicking to the left of the line number)
-
Refresh the web page so the debugger stops at first breakpoint
The following is an example of how to debug the file-upload.js file that is used by Share to check if Flash is installed or not, and then uses either the FlashUpload or HtmlUpload component:
In this case the file-upload.js file with the checksum name was selected from the script list. Then a breakpoint was set in the show: function FU_show(config) method. To start debugging we just needed to click on the Upload button in the toolbar. To step over a line use F10, to step into use F11, and to continue to next breakpoint use F8.
An important thing we can see here is that the actual Uploader component used is the DNDUpload (Drag-and-Drop) component, and not the FlashUpload that we might think. So it is important to debug into the source and see what is really going on.