Firebug使用之三--Script Panel
The main purpose of the script panel is to debug JavaScript code. Therefore the script panel integrates a powerful debugging tool based on features like different kinds of breakpoints, step-by-step execution of scripts, a display for the variable stack, watch expressions and more.
Contents [hide] 1Options Menu2Panel Toolbar 2.1Break On Next2.2Script Type Menu2.3Script Location Menu2.4Execution Control Buttons 3Breakpoints 3.1Setting breakpoints3.2Types3.3Conditions3.4Automatic Breakpoints 4Variable Tooltips5Side Panels 5.1Watch5.2Stack5.3Breakpoints 6Search7See also [edit]Options MenuThis menu is reachable via the little arrow in the panel tab () or by right-clicking on on the panel tab (sinceFirebug 1.9).
extensions.firebug.script.enableSites
Enables the Script Panel Show chrome sources extensions.firebug.service.showAllSourceFiles
Toggles the display of program and add-on internal sources. Note that Firebug will still not activate for chrome URLs unless you also setservice.filterSystemURLs
to false (seeFirebug Preferences).
extensions.firebug.service.trackThrowCatch
Toggles tracking of throw/catch blocks Show Break Notifications extensions.firebug.showBreakNotification
Toggles the display of break notifications For more info about tweaks available in Firebug please see thefull list of preferences.
[edit]Panel Toolbar [edit]Break On NextTheBreak On Nextbutton () gives you the possiblity to stop the script at the next executed command. This can be a user action, a timeout or anything else that causes script execution. As soon as you click on the button, it is armed. When any script execution occurs now, the debugger will halt the script and you can step through it.
There are several otherBreak On ...features available at the other panels.
[edit]Script Type MenuThe Script Type Menu filters the Script Location Menu by different types of scripts. Thereby three different kinds of scripts are distinguished:
You have the option to just show static scripts, static + eval scripts, static + event script or all types of scripts.
[edit]Script Location MenuAll scripts filtered by the type(s) selected in the Script Type Menu will be shown inside this menu. Any characters you type on the keyboard while the list of files is open will filter the list to make it easier to find files. By selecting one of the scripts it will be shown inside the Main Panel.
If you right-click on the file list, you'll get options for opening the script in a separate browser tab, copying its location to the clipboard, or opening it inside theDOM Panel.
[edit]Execution Control ButtonsThe execution buttons are enabled as soon as the debugger is stopped. There are four buttons, which can be used for debugging:
Shift
+F8
Reruns the current call stack (seeHonza's blog postfor more info) Continue F8
Continues script execution until the next breakpoint or the execution ends Step Into F11
Jumps into the body of executed functions, so you can debug them Step over F10
Executes functions, but doesn't jump into them, instead moves to the next line of the same scope Step out Shift
+F11
Executes the rest of the current function and jumps back to it's caller test
[edit]BreakpointsBreakpoints in Firebug are used to debug JavaScript code. They will stop script execution at a specific point and give you control over script execution.
[edit]Setting breakpointsThe Breakpoint Column allows you to set breakpoints. By clicking on it a breakpoint is set for the line. Clicking it again removes the breakpoint again.
[edit]TypesYou can set breakpoints to stop script execution as soon as it reaches them for debugging purposes. Currently you can manually create five different types of breakpoints:
For manually set breakpoints you also have the possibility to set conditions, at which they trigger. Doing so opens the Breakpoint Condition Editor:
These conditions can be very complex, but most of the time you'll want to limit breaking to specific variable values. An example for this could be having a counter and you want to stop execution when the counter reaches a specific value. Another situation would be to stop execution when a specific variable is defined resp. undefined.
[edit]Automatic BreakpointsFurthermore the script execution can be stopped via the different implementedBreak On ...features of each panel, which doesn't require explicitly setting of breakpoints.
[edit]Variable TooltipsWhen the debugger halted the script, you are able to get information about the script variables by hovering them. A popup will appear showing the current value of the hovered variable.
[edit]Side PanelsThe Side Panels of the Script Panel offer different useful information and functionality about the executed scripts.
[edit]WatchTheWatch Side Paneloffers the possibility to enter watch expressions allowing to follow changes of variable values while debugging.
[edit]StackTheStack Side Panelcontains information about the call stack trace for the currently debugged function.
[edit]BreakpointsTheBreakpoints Side Panellists the defined breakpoints and gives the possibility to toggle their activation plus additional options for changing the behavior of the breakpoints.
[edit]SearchThe text input box in the upper right corner searches the source code. When you click in to the box, an auxiliary panel allows you to pick search direction, single or multiple files, and case sensitivity. The text has special case code to support:
Go to Line:The symbol # followed by a number will incrementally move the line number,Case by Case:If the case sensitivity setting is not used, then an all lower case word will mean case-insensitive search, but a mixedCase word will cause case sensitive matches. [edit]See also Script DebuggingJsd(JavaScript interface for debugging Javascript)声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。