Summary: | Inspector should support Firebug's magic $0 variable to access inspected node | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Adam Roben (:aroben) <aroben> | ||||||||||||
Component: | Web Inspector (Deprecated) | Assignee: | Nobody <webkit-unassigned> | ||||||||||||
Status: | RESOLVED FIXED | ||||||||||||||
Severity: | Enhancement | CC: | abarth, emacemac7, joepeck, mjs, rik, timothy | ||||||||||||
Priority: | P2 | Keywords: | InRadar | ||||||||||||
Version: | 528+ (Nightly build) | ||||||||||||||
Hardware: | All | ||||||||||||||
OS: | All | ||||||||||||||
Bug Depends on: | |||||||||||||||
Bug Blocks: | 14355 | ||||||||||||||
Attachments: |
|
Description
Adam Roben (:aroben)
2008-03-17 21:02:18 PDT
Thats a shame that Firebug uses $1. I was considering doing the gdb $n to refer to previous console results. More people might be familiar with Firebug's concept though. *** Bug 19390 has been marked as a duplicate of this bug. *** $1 isn't available in Firebug 1.2b2. I don't know if it's a bug or if they abandoned it. By the way, I've asked other web developers, nobody knew this shortcut. Maybe you could agreed with Firebug developers on a more standard way to do this. According to this old documentation, I think $0 is the inspected node. http://www.joehewitt.com/software/firebug/docs.php Created attachment 22794 [details]
not working patch
$0 seems to receive the appropriate object, but the security seems to block usage. For example, calling "$0" seems OK, but calling "$0.innerHTML" returns undefined. I tried doing wrapCallback on the node but that doesn't work either.
Maybe this could have a less obscure name, like console.selectedNode or something. With autocomplete the typing is not a big deal and it is more memorable and less likely to conflict than $0. (In reply to comment #7) > Maybe this could have a less obscure name, like console.selectedNode or > something. Putting it on the console object may not be ideal, since it's unlikely we want web pages to have access to this variable. Created attachment 33221 [details]
Implements $0, $1, $n
I've finally figured this out.
JSInspectorCallbackWrapper wraps the return value with JSInspectorCallbackWrapper::wrapOutgoingValue. It wraps it as a JSInspectorCallbackWrapper, which blocks getProperty, setProperty, deleteProperty, construct, hasInstance, and getPropertyNames.
I think this is overkill for objects from the "inspected window" but a necessary security measure for objects from the "inspector".
$0 - Variable containing the most recently inspected object .
$1 - Variable containing the next most recently inspected object .
$n(n) - Returns the nth most recently inspected object that has been inspected.
Created attachment 33223 [details]
set history limit to 5
The history limit seems to be 5 in firebug.
Comment on attachment 33223 [details] set history limit to 5 > + profileEnd: function() { return console.profileEnd.apply(console, arguments) }, \ > + _inspectedNodes: [], \ > + _addInspectedNode: function(node) { \ The indentation is one space off for _inspectedNodes. + var _inspectedNodes = _inspectorCommandLineAPI._inspectedNodes; \ The local variable should not have an underscore prefix. > + $n: function(n) { return _inspectorCommandLineAPI._inspectedNodes[n] } \ Firebug really adds a $n function? Not just $0, $1, $2, $3 and $4? > Firebug really adds a $n function? Not just $0, $1, $2, $3 and $4? Yah, documentation on this is rather hidden. Its at the bottom of Joe Hewitt's site: http://joehewitt.com/software/firebug/docs.php Created attachment 33237 [details]
Syntax fixes
$n is pointless. It's only in their old outdated documentation anyway. (The assert* commands seems to have been deprecated)
I vote to ditch it.
Lets ditch $n. Created attachment 33238 [details]
No more $n
Committing to http://svn.webkit.org/repository/webkit/trunk ... M WebCore/ChangeLog M WebCore/inspector/front-end/Console.js M WebCore/inspector/front-end/ElementsPanel.js Committed r46338 M WebCore/ChangeLog M WebCore/inspector/front-end/ElementsPanel.js M WebCore/inspector/front-end/Console.js r46338 = 4e1d680f3088d0cdd0b49c04acba4a47421cc311 (trunk) No changes between current HEAD and refs/remotes/trunk Resetting to the latest refs/remotes/trunk http://trac.webkit.org/changeset/46338 |