Surfin' Safari

Web Inspector Updates

Posted by Joseph Pecoraro on Tuesday, November 3rd, 2009 at 7:13 pm

A number of exciting new features have been added to the Web Inspector since our last update. Today we would like to highlight some of those features! This post is also available in Japanese (日本語), thanks to Keishi Hattori (服部慶士).

If you would like to play with most of these features you will need to be running a recent WebKit Nightly. Once downloaded make sure that you enable the Web Inspector by checking “Show Develop menu in menu bar” under the Advanced tab in the Preferences.

Enabling the Inspector in Preferences

Editing Element Attributes and Style Properties #

Editing Element Attributes and Style Properties has been made even simpler and more developer friendly. The interfaces for editing attributes and properties now support tabbing to allow you to move between items, and create new items with ease.

Besides tabbing you can also add a new attributes to a node.  Start by hovering over the node in the Element’s Tree Hierarchy and after a polite wait a clickable template for a new attribute will appear.

Edit Element Attributes

Related Bug Reports: Add Element Attributes, Tabbing, and Improved UI.

Creating and Modifying CSS Rules and Selectors #

A powerful new feature in the Web Inspector allows you create new or modify existing CSS Rules and Selectors. We expect both developers and designers will find this very useful when experimenting with new ideas or tweaking existing designs.

The interface for working with selectors starts with a new Gear Menu in the Styles Sidebar Pane. Select “New Style Rule” and a new section will be created for you, pre-populated with an intelligent selector from the selection in the Elements Tree Hierarchy. Editing selectors is activated by double-clicking. Once again, tabbing will allow you to navigate between selectors and their properties.

When editing selectors there is visual feedback when you create or modify a selector that does not affect the selected node in the Elements Tree Hierarchy. This indicator helps detect errors when making changes.

Create and Modify CSS Selectors

One more tweak to the Styles Pane is that there is always a section for the selected node’s style attribute. This allows you to easily add style information to the node as you usually would via the Styles Pane instead of editing or creating a “style” attribute. This section is nearly always on top due to how CSS specificity works.

Related Bug Reports: Selectors Support and Move to Gear Menu.

CSS Color Representations #

Colors in the Styles Pane can be shown in any of their possible representations. For simple colors this includes short hex, full hex, rgb, hsl, and potentially a nickname. For advanced colors this includes rgba and hsla. For example the color “white” can be represented as: #FFF, #FFFFFF, rgb(255, 255, 255), hsl(0, 100%, 100%), and white.

You can use the Styles Pane’s Gear Menu to set your preferred representation. However, if you want to cycle through an individual color’s different representations you can do so by clicking on its associated color swatch.

Mutiple Color Representations

Related Bug Reports: Color Representations, Preference and Gear Menu, and UI Improvement.

DOM Storage #

The Storage Panel (formerly the Databases Panel) now allows you to monitor DOM Storage areas like localStorage and sessionStorage in a familiar datagrid. The DOM Storage datagrid displays live updates so monitoring changes is possible without manually refreshing the view.

Also, the familiar creation and editing techniques apply to the datagrid. To add a new key/value pair just double-click in any open area, or double-click an existing item to start editing. Tabbing works as you would expect.

Observing DOM Storage Key/Value Pairs

Related Bug Reports: DOM Storage Support, Live Updates, Create New Items, and Tabbing.

Keyboard Shortcuts #

Keyboard shortcuts are always desired by developers. They can be hard to discover, so here is a complete list and here are the ones that were added recently:

  • Switch PanelsCommand-[ and Command-] on a Mac or Control-[ and Control-] on other platforms.
  • Delete a Node in the Tree Hierarchy — either Delete or Backspace keys will do the trick.
  • Quick Edits in the Tree Hierarchy — Hitting Enter or Return on a Node in the Tree enters the editing mode for that type of Node. For a Text Node you will start editing the content. For Element Nodes you start editing the first attribute, or, for convenience, a new attribute will be added for you.

The Scripts Debugger was updated to support some popular keyboard shortcuts:

  • ContinueF8 or Command-/ on a Mac or Control-/ on other platforms.
  • Step OverF10 or Command-’ on a Mac or Control-’ on other platforms.
  • Step IntoF11 or Command-; on a Mac or Control-; on other platforms.
  • Step OutShift-F11 or Shift-Command-; on a Mac or Shift-Control-; on other platforms.
  • Next Call FrameControl-. on all platforms.
  • Previous Call FrameControl-, on all platforms.
  • Evaluate Selection When on a BreakpointShift-Command-E on a Mac or Shift-Control-E on other platforms.

Related Bug Reports: Switch PanelsDelete Node, Quick Edit, General Debugger Shortcuts and Evaluate Selection.

Cookies #

Viewing Cookie information is now possible under the Storage Panel. Supported platforms show all of the cookies and their hidden information for all domains accessed on the inspected page. Cookie information includes the name, value, path, expiration date, http only flag, and secure (https) flag. Supported platforms may also delete cookies.

If your platform doesn’t have full support you aren’t left in the dark. You will still be able to see the keys and values of the cookies that are accessible via JavaScript on the inspected page.

Inspect Hidden Cookie Information

Related Bug Reports: Initial Support, Hidden Data 1 and 2, Cookies for Sub-Resources, and UI Improvements

Event Listeners #

A new Sidebar Pane has been added to the Elements Panel which displays the registered Event Listeners for the selected node.  The Event Listeners that are shown for the selected node are in the exact order that they are fired through the Capturing and Bubbling phases.  This provides developers with the most accurate and useful information possible.

The user interface shows the registered Event Listeners separated by type. If a node has both “onclick” and “onmouseover” listeners then they will naturally appear in different sections. You can also set your filter preference using the Gear Menu. You can choose to see only the listeners registered on the selected node, or the entire event flow.

Inspect Registered Event Listeners

We are actively looking for UI improvements in this area. So if you have some ideas or feedback please feel free to let us know on this bug report!

Related Bug Reports: Event Listeners.

Syntax Highlighting #

Syntax highlighting enhances readability, makes debugging code easier, and looks really awesome. The Web Inspector now includes syntax highlighting for JSON and CSS.

CSS Syntax Highlighting

CSS Syntax Highlighting even works on the more complex “at-rules” such as @import, @media and @font-face. In addition to supporting the syntax highlighting in the Resources Panel, inline scripts and styles in the Elements Tree Hierarchy are syntax highlighted!

Inline JavaScript and CSS Syntax Highlighting

Related Bug Reports: JSON Highlighting, CSS Highlighting, and Inline Highlighting.

Breakpoints and Watch Expressions #

The Script Debugger continues to become more powerful and more useful.  We already mentioned the keyboard shortcuts above, but there are plenty of other enhancements.

There is a new Breakpoints Sidebar Pane that allows you to easily monitor and work with your breakpoints across all files without the hassle of searching for them.  Each sidebar entry shows the source line and contains a checkbox that allows you to directly enable or disable the breakpoint. Clicking on the entry will jump you directly to the highlighted line in the source file. Finally, deleting a breakpoint has been made easier by clicking the “blue tag” breakpoint indicator.  The tag will cycle through its three states of active, inactive, and removed.

A powerful feature added to the debugger is Conditional Breakpoints. Once you have a breakpoint set, right click on the “blue tag” breakpoint indicator and you will get a popup asking for a conditional statement for that breakpoint. Simply provide an expression and the breakpoint will only pause from then on only if the condition is true.

Breakpoints and other Debugging Improvements

Another new feature in the Debugger is Watch Expressions.  In this new Sidebar Pane you can add any number of expressions that evaluate in the global scope normally but in the local scope when paused in the debugger. Once added you get the full Object Properties tree view of the values of each expression.  These watch expressions automatically refresh when the debugger pauses. They are also persist across page loads.

Watched Expressions in Action

Related Bug Reports: Breakpoints Sidebar PaneWatch Expressions, Evaluate on Breakpoint, Conditional Breakpoints, and Delete Breakpoints.

Debugging AJAX #

An extremely valuable feature for developers working with AJAX is the ability to view the exact parameters and payload sent on XMLHttpRequests.

In the individual resource view there are new sections for viewing submitted Form Data, Query String Parameters, and Request Payloads when appropriate. You can toggle viewing the information in its unencoded (default) and encoded forms with a double-click.

There is also new section named HTTP Information which contains the Request Method (GET, POST, etc.) and the Status Code (200, 404, etc.). Additionally, it adds a colored dot next to the requested URL to show the status (green for success, orange for redirect, and red for error).

View Submitted Form Data and HTTP Information

Related Bug Reports: HTTP Status Code and Data, Parameters, and Payload

Resources and Console Scope Bars #

In order to filter through the Resources or Console messages the Web Inspector now sports some familiar Scope Bars. This has proven to be very useful in the Resources Panel for easily viewing all resources of a particular type.

Quick Filtering Scope Bars for Resources Types and Console Message Types

Related Bug Reports: Resources Scope Bar and Console Scope Bars.

Resources Timeline #

The Web Inspector now specifically shows in the timeline when the DOMContentLoaded and Load events fire. This helps clarify the time it takes for pages to load and helps you improve your websites load times.

DOMContent Ready Event and Page's Load Event Indicators

Related Bug Reports: Show Load Lines

Resources Interactivity #

A couple new features allow you to more directly access individual resources from within the Web Inspector. Instead of copying their URL and opening a new tab manually you can now double-click the Resource in the sidebar to open it directly in a new window. Or, you can drag and drop the resource using HTML5 drag and drop events!

Related Bug Reports: Open Resource Directly and Drag and Drop.

Console Improvements #

Properties in the Web Inspector’s Console are now sorted in a much more natural and useful way. By sorting keys alphanumerically Arrays with greater then 10 elements are much easier to work with.

Alphanumeric Sorting

Another tweak is that collections such as NodeLists and HTMLCollections are now displayed like Arrays.  This meaning that their contents are shown directly in the console, no longer requiring any extra boilerplate.

More Descriptive Nodelists

Related Bug Reports: Sorting and NodeLists.

Firebug Command API Improvements #

More improvements have been made to support more of the Firebug Command Line API. The Web Inspector now supports the inspect() function, which can take an Element, Database, or Storage area and automatically jumps to the appropriate Panel with information. Also, the $0-$4 variables contain the current and previous selected nodes from the Elements Tree Hierarchy.

These command line APIs are usable inside the Web Inspector’s Console. To make working with these APIs even easier, they now show up in the Console’s autocompletion.

Related Bug Reports: $# Variables, inspect() Function, and Autocompletion.

How You Can Contribute #

Many of these new features were added by members of the Open Source Community. We would like to encourage you to contribute as well! Since the Web Inspector itself is mostly HTML, JavaScript, and CSS that means that you already have the skills you need to join in! Interested? Play around right now by inspecting the inspector itself!

Work on the Web Inspector using the Web Inspector!

If you’re interested in contributing and have any questions please stop by the #webkit-inspector IRC channel! As an encouragement to developers, included at the end of each section above are the core bug reports that were involved in bringing each of these features to life.

Finally, if you have ideas for new features, any improvements, or if you’ve stumbled across a bug then please don’t hesitate to create a bug report. This link has pre-populated most of the fields so that you only need to fill out the Summary and Description. As always you should do a quick search through the existing inspector bugs first.

15 Responses to “Web Inspector Updates”

  1. Joseph Pecoraro Says:

    A big thanks to Timothy Hatcher, Pavel Feldman, Anthony Ricaud, Brian Weinstein, Keishi Hattori, Patrick Mueller, Yury Semikhatsky, Yael and everyone else that has been working on the Inspector. Keep up the great work!

  2. kommen Says:

    Thanks for the nice writeup! As I’m using the WebKit nightlies I can say I really enjoy working with the Inspector and have dropped Firebug long a go for development purposes, as the experience is way better than current Firebug versions. Good work guys!

  3. Trackback from Human::Stefan():

    Web Inspector gets an update…

    Great set of new and updated features for Web Inspector. Read all about it in the Surfin’ Safari Blog.
    ……

  4. Rik Says:

    Clap clap clap to everyone. Let’s make it even better.

  5. POWRSURG Says:

    Doubtful, but does this mean WebKit does a better job with getComputedStyle? Perhaps no longer resulting in a page reflow? I have an application that requires a ton of element insertions followed by getComputedStyle calls and this results in very high CPU utilization to the point where WebKit browsers are effectively unusable. Normally I wouldn’t bring it up as I recognize that it is slightly off topic, but I thought that changes like this to the Web Inspector might only be possible if issues with getting elements style were cleared up.

    Just based on the screenshots I have to ask, are these features available for all operating systems, or just on the Mac?

  6. Adam Roben Says:

    Nice work everyone! It’s really impressive how quickly the Web Inspector has been advancing in recent months.

  7. bartszyszka Says:

    This is great! My only problem with the Inspector right now is the way margins/padding/borders get handled by it. It’s not as easy to see what’s the margin, what’s the padding, what’s the border as it is in Firebug (where those those are three different colors with not extra outlines). And for someone who cares about measuring things to the pixel the outlines around them are confusing (is the width of the margin what’s inside the outline or including it? which shade of light blue is the padding and which shade is the element and which shade is the margin?).

  8. Trackback from Tiffany B. Brown:

    WebKit gets Web Inspector Updates…

    Yesterday the folks at Surfin’ Safari announced several new and/or improved features to its Web Inspector. Web Inspector is a debugging tool similar to Firebug and Page Speed or YSlow. These updates will be be available in the next version of Sa…

  9. Adam Roben Says:

    @POWRSURG: Yes, these features work on all operating systems. The only exception is that some platforms might not show the “hidden information” for cookies, as mentioned in the post. Because the Web Inspector is mostly written in HTML, JavaScript, and CSS, all platforms benefit from improvements to it!

  10. Mark Rowe Says:

    I’ll restate it here since some commenters appear to have missed it in the original post:

    Finally, if you have ideas for new features, any improvements, or if you’ve stumbled across a bug then please don’t hesitate to create a bug report.

  11. simianpirate Says:

    I am very impressed with the additions and changes made to this already excellent tool.

    I do have a question if someone could answer it for me.

    I really like the background of that last image. Where can I find that?

  12. richcon Says:

    Awesome work!

  13. Bret Says:

    Desktop/wallpaper:

    http://www.vladstudio.com/wallpaper/?wheresmilesareborn_2009

  14. simianpirate Says:

    @Bret Thank you for pointing me to it… I should have known it was a Vlad Studio work!

  15. tvdeyen Says:

    You had me with eventListeners Inspector. 1000 Up for this!

    When can we expect Apple to merge this in to Safari?
    I hope very soon