Bug 49048 - Web Inspector: Feature Request: links from console to elements/scripts
Summary: Web Inspector: Feature Request: links from console to elements/scripts
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Enhancement
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-04 19:01 PDT by Xianzhu Wang
Modified: 2010-11-07 23:40 PST (History)
11 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xianzhu Wang 2010-11-04 19:01:00 PDT
I think the following features would be helpful for developers:

1. When an element is displayed in the console, clicking or double-clicking the element or any descendant will focus the same element in Elements panel (and the element becomes $0); if current panel is not Elements panel, will switch to it.

2. When a string like "script_file:line_number:column_number" is displayed as a link in the console, clicking the link will bring up the Scripts panel and select the script_file and move the cursor to the line and column. (For now, it only brings up the Resources panel and won't focus the file and line.) This would be useful for developer to inspect the related code when some script logs some stack trace in the console.
Comment 1 Joseph Pecoraro 2010-11-04 19:22:07 PDT
For (1) you can use the "inspect" function to make that element the selected element in the Elements Tree Hierarchy. For example, from any panel you can type "inspect(document.body)" to jump to the Elements Panel with the body element selected. You can pass in any element, database, or storage object.
Comment 2 Pavel Feldman 2010-11-05 07:26:45 PDT
Committing to http://svn.webkit.org/repository/webkit/trunk ...
	M	WebCore/ChangeLog
	M	WebCore/inspector/front-end/ConsoleView.js
	M	WebCore/inspector/front-end/NetworkPanel.js
	M	WebCore/inspector/front-end/StoragePanel.js
	M	WebCore/inspector/front-end/inspector.js
Committed r71413

inspect() should cover (1)
linkify line number landed as a drive-by of r71413
Comment 3 Xianzhu Wang 2010-11-07 18:29:34 PST
Thanks Pavel for your timely fix.

However, I'd still argue (1). I think making elements in the console link to Elements panel could be useful. A scenario might be that a developer uses console.log to print an element with page script (where inspect() is not accessible), and then inspects them in the console. The developer could achieve this in another way, but different developers might have different habits in debugging. 

Another benefit of (1) is that an extension can interact with the inspector in this way without using the inspector extension API. For example, a compatibility detection extension finds a problematic element and print it with console.log(), then the user can inspect the element to find more details.
Comment 4 Pavel Feldman 2010-11-07 23:13:55 PST
(In reply to comment #3)
> Thanks Pavel for your timely fix.
> 
> However, I'd still argue (1). I think making elements in the console link to Elements panel could be useful. A scenario might be that a developer uses console.log to print an element with page script (where inspect() is not accessible), and then inspects them in the console. The developer could achieve this in another way, but different developers might have different habits in debugging. 
> 
> Another benefit of (1) is that an extension can interact with the inspector in this way without using the inspector extension API. For example, a compatibility detection extension finds a problematic element and print it with console.log(), then the user can inspect the element to find more details.

Today, if you use console.dirxml or console.dir, you get the element dumped into the console. We can provide a "Reveal in Elements Panel" context menu item on such elements. Would that cover your scenario?
Comment 5 Xianzhu Wang 2010-11-07 23:40:09 PST
(In reply to comment #4)
> Today, if you use console.dirxml or console.dir, you get the element dumped into the console. We can provide a "Reveal in Elements Panel" context menu item on such elements. Would that cover your scenario?

Yes. Thanks Pavel!