Closed Bug 1621675 Opened 4 years ago Closed 1 year ago

console.log for DOM nodes sends unhelpful information to stdout

Categories

(DevTools :: Console, enhancement, P3)

enhancement

Tracking

(firefox112 fixed)

RESOLVED FIXED
112 Branch
Tracking Status
firefox112 --- fixed

People

(Reporter: mossop, Assigned: Gijs)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

A lot of what used to be XBL elements are now custom elements, normally subclasses of MozElementBase. If you pass one of these to console.log you get decent output in the browser console, but in stdout you get quite unhelpful things like ({}) or ({renderedOnce:true, _inheritedElements:{'.menu-iconic-text':{_lastFormattedAccessKey:null, isRunningDelayedConnectedCallback:false}, '.menu-text':null, '.menu-iconic-highlightable-text':{_lastFormattedAccessKey:null, isRunningDelayedConnectedCallback:false}, '.menu-iconic-left':{}}, initializedAttributeInheritance:true}).

It would be quite useful to output something more sensible in this case. Something like <element attr1="..." attr2="..." ... /> would be fairly clear.

This appears to be a more general problem with DOM nodes. I double checked console.log(document.body) in the browser console and see console.log: ({}) in stdout. Seeing a stringified version of the output in the console UI as you suggest seems sensible.

Summary: console.log for one of our XUL custom elements outputs unhelpful information to stdout → console.log for DOM nodes sends unhelpful information to stdout

This is only visible with chrome code by default. You could reproduce with messages coming from content with --setpref devtools.console.stdout.content=true.

Priority: -- → P3
Severity: normal → S3

I would really like to see this fixed. As I said in bug 1813485, I'm willing to do the work if someone can point me to where the dump/stringification stuff for this lives.

See Also: → 1813485

(In reply to :Gijs (he/him) from comment #3)

I would really like to see this fixed. As I said in bug 1813485, I'm willing to do the work if someone can point me to where the dump/stringification stuff for this lives.

I'm not sure about this, but it may happen from https://searchfox.org/mozilla-central/source/dom/console/Console.cpp#2671-2740 ?

Assignee: nobody → gijskruitbosch+bugs
Status: NEW → ASSIGNED
Blocks: 1820804
Pushed by gijskruitbosch@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/46b47ef1af37
improve console method's dump logging for DOM elements, r=nchevobbe,smaug
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 112 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: