On 4/8/10 11:56 PM, Honza (Jan Odvarko) wrote:
I wanted to try out XPathResult logging so I installed this, but I'm
working on a Greasemonkey script, and it appears that
console.log(object) doesn't make the [object Object] click able, and
console.dir doesn't work at all in Greasemonkey scripts. Is that on
purpose? Both worked in 1.5.3 with the same Greasemonkey script
(although of course without the enhanced XPathResult display). I'm using
Firefox 3.6.3 and Greasemonkey 0.8.20100408.6.
I have installed Firefox 3.6.3 + Firebug 1.6a9 + Greasemonkey
0.8.20100408.6.
and tried following test case:
http://getfirebug.com/tests/content/console/api/log-xpathresult.html
Sorry, I wasn't very clear. console.log and console.dir fail only when called from a Greasemonkey user script, they work fine (and the XPathResult display is nice, thanks!) from regular pages. So the URL above works as expected. Here's a test case for the failure in a user script:

1. Copy the text between the dashed lines below and save it in a file called test.user.js:

------------------------------ cut here ------------------------------
// ==UserScript==
// @name    Testing for Firebug 1.6a9
// @namespace    http://getfirebug.com
// @description Test console.log and console.dir from a Greasemonkey script
// @include    http://getfirebug.com/*
// ==/UserScript==

var o = {'a': 23, 'b': 42};

console.log('o (via log):', o);
console.log('o (via dir):');
console.dir(o);

var r = document.evaluate('//h2', document.body, null,
    XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);

console.log('r (via log):', r);
console.log('r (via dir):');
console.dir(r);
------------------------------ cut here ------------------------------

2. Open test.user.js in Firefox. Greasemonkey should intercept the open and offer to install the user script. After the countdown click Install. That installs a user script that's run anytime a URL is visited starting with http://getfirebug.com/ (there's nothing special about that URL, I just needed some URL, and we're all familiar with that one :-)).

3. Visit getfirebug.com. If Firebug wasn't on for that page, turn it on, then go to the Console tab and reload the page.

4. The Greasemonkey script should log some stuff. With Firebug 1.5.3 I get:

o (via log): Object { a=23, more...}
o (via dir):
                
        
a
        23
        
b
        42

r (via log): XPathResult {}
r (via dir):
                
        
ANY_TYPE
        0
        
ANY_UNORDERED_NODE_TYPE
        8
        
BOOLEAN_TYPE
        3
        
FIRST_ORDERED_NODE_TYPE
        9
        
NUMBER_TYPE
        1
        
ORDERED_NODE_ITERATOR_TYPE
        5
        
ORDERED_NODE_SNAPSHOT_TYPE
        7
        
STRING_TYPE
        2
        
UNORDERED_NODE_ITERATOR_TYPE
        4
        
UNORDERED_NODE_SNAPSHOT_TYPE
        6
        
booleanValue
        7
        
get invalidIteratorState
        false
        
numberValue
        7
        
resultType
        7
        
singleNodeValue
        7
        
snapshotLength
        8
        
stringValue
        7
        
iterateNext
        iterateNext()
        
snapshotItem
        snapshotItem()


(I hope that pasted ok). It's all static text except for "Object { a=23, more...}" and "XPathResult {}", both of which are links that can be clicked to display the item in the DOM tab.

5. Install 1.6a9 and visit getfirebug.com again. Now I get:

http://getfirebug.com/Testing for Firebug 1.6a9: o (via log):
[object Object]
http://getfirebug.com/Testing for Firebug 1.6a9: o (via dir):
http://getfirebug.com/Testing for Firebug 1.6a9: r (via log):
[object XPCNativeWrapper [object XPathResult]]
http://getfirebug.com/Testing for Firebug 1.6a9: r (via dir):

Now it's *all* static text, neither "[object Object]" nor "[object XPCNativeWrapper [object XPathResult]]" are clickable, and note that there's no dir output. Also, why are the lines wrapped? My Firefox window is about 3 times wider than the longest line on the console, it shouldn't have had to wrap the lines.

Let me know if you need more information.

Thanks,
Brian

--
You received this message because you are subscribed to the Google Groups 
"Firebug" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/firebug?hl=en.

Reply via email to