Debuggers are an essential part of a software developer's toolkit, and as such, the
JavaScript Debugger has been a sanity-saver for me over the last few weeks. Having the ability to step through the code while it executes has helped me to better understand the
Alfresco Surf Platform and some of the intricacies of JavaScript execution.
Alfresco bundles the
Rhino Debugger with versions 2.1 and up. It can also be used with any application built on top of the Alfresco Surf Platform such as
Alfresco Share. To turn it on simply go to this URL, and click the "enable" button:
http://<host>:<port>//<application>/service/api/javascript/debugger
Note: Once the debugger is enabled, in order to shut down your application server, you must first disable the debugger or close its window.
The debugger has many of the features you come to expect: Set breakpoint, Remove breakpoint, Go, Step Over, Step Into, and Step Out.
The lower-left context panel gives you a nice view of all the variables defined in the script, however I find the interface to be a little flaky. In theory you can click on the arrows to expand complex objects and drill down to more specific attributes, but it doesn't always work. Instead, I find the "Evaluate" and "Watch" panes to be the most useful, because you can quickly drill down to the data you're interested in.
Evaluate gives a snapshot of the expression you're interested in, and keeps a history of the values you've looked at, whereas
Watch evaluates the expressions as you step through the application so you can see how the values change.
Try it out: