GetFirebug logo

Dynamic and Graphical
Web Page Breakpoints

WWW2010, April 26-30, 2010
Raleigh, North Carolina

John J. Barton, IBM Almaden Research Center
Jan Odvárko, Mozilla Corp.

getfirebug.com

Note these slides are also demos if you open Firebug 1.5+ and reload

Web Page Debugging

Firebug: Firefox Extension

Click the icon to open Firebug UI.

Javascript breakpoint debugger integrated with UI inspector

New Kinds of Breakpoints

Breakpoints: Quintessential feature of debuggers

  1. Find the line of source you want to investigate
  2. Set a breakpoint
  3. Run the program
  4. Debugger halts execution, you poke around

Setting Breakpoints

Real systems are hard to debug

Conventional breakpoints require comprehensive code understanding

Contribution
implementation of dynamic and user-interface-event breakpoints in a production debugger

Dynamic Javascript Breakpoints

  • Widely used by JS frameworks
    • e.g. eval() in dojo
  • No identifiers for eval() buffers
    • Breakpoints require unique buffer ids

Implementations

  1. Hack in identifiers with //@ src=URL at the end of buffers, or
  2. Compute MD5 hash of buffers to identify them.

Detailed implementation depends on non-standard javascript debug APIs

Generated Filename

Dynamic Javascript with Generated Filename

  1. Load the duck and cat functions by AJAX
  2. Open the Firebug Script Panel and select evaluated script, then set a breakpoint on line 10
  3. Call the Duck and Cat functions
  4. You should halt in the debugger on a breakpoint in dynamically created source code

Graphical Breakpoints

Problem

Solution

Two examples, XHR and HTML

Network Event breakpoints

  • AJAX applications wide spread
  • Firebug Net panel shows requests, response
  • Which JS function caused the request?

Implementation

  1. Intercept request start calls,
  2. Compare XHR URLs to XHR breakpoints
  3. Halt Javascript and open debugger on match.

Break On Network Event

  1. Select the Firebug Net Panel
  2. Click the Break on XHR button ()
  3. Execute XHR:
  4. Firebug will break on the XHR event

Conditional Network Breakpoints

UI Modification Breakpoints

  • Dynamic UI construction
    • Break on addition/removal of elements
  • Dynamic UI modification
    • Break on attribute modification

    Implementation

    1. DOM Mutation Event handlers (standard)
    2. Halt Javascript and open debugger

    Breakpoints on HTML Events

    1. Use HTML Inspector to find this element
    2. Right click on the element and pick Break On Attribute Change menu item.
    3. Click this button

    Breakpoints on Cookies

    Extensible Breakpoints

    • Cookies panel
    • Manage Cookies & Permissons
    • Break On Next Cookie Change
    • Conditional Breakpoints

    Related Work

    Summary & Links. Questions?

  • Dynamic and Graphical Breakpoints for Web debugging
    • For large user interface systems on the Web
  • Deployed in Firebug 1.5