Closed
Bug 642108
Opened 13 years ago
Closed 13 years ago
JS errors from HUD in Error Console
Categories
(DevTools :: General, defect)
DevTools
General
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 5
People
(Reporter: wes, Assigned: rcampbell)
Details
(Whiteboard: [console-1])
Attachments
(1 file, 4 obsolete files)
9.73 KB,
patch
|
mossop
:
review+
|
Details | Diff | Splinter Review |
I regularly get many, many, of these errors: Error: hudRef is null Source File: resource:///modules/HUDService.jsm Line: 1213 ...which make looking for "real" errors in the Error Console really annoying. I suspect they happen when I use the Web Console, but am not sure. I'm on ff4-rc1.
Updated•13 years ago
|
Whiteboard: [console-1]
Assignee | ||
Comment 1•13 years ago
|
||
this is happening here: http://mxr.mozilla.org/mozilla-central/source/toolkit/components/console/hudservice/HUDService.jsm#1213 1206 // Prune the nodes. 1207 let messageNodes = aConsoleNode.querySelectorAll(".hud-msg-node"); 1208 let removeNodes = messageNodes.length - logLimit; 1209 for (let i = 0; i < removeNodes; i++) { 1210 if (messageNodes[i].classList.contains("webconsole-msg-cssparser")) { 1211 let desc = messageNodes[i].childNodes[2].textContent; 1212 let location = messageNodes[i].childNodes[4].getAttribute("title"); 1213 delete hudRef.cssNodes[desc + location]; 1214 } 1215 messageNodes[i].parentNode.removeChild(messageNodes[i]); 1216 } delete hudRef.cssNodes. Added from bug 611795. I expect you only see this if you've had the console open for awhile or you have a lot of history built up in the console? Are there any other associated errors you see with this or is it pretty-much filling the error console for you? We should be able to write a test-case for this.
Assignee | ||
Comment 2•13 years ago
|
||
taking this. unittest to follow.
Assignee: nobody → rcampbell
Status: NEW → ASSIGNED
Comment 3•13 years ago
|
||
In pruneConsoleOutputIfNecessary(): let hudRef = HUDService.getHudReferenceForOutputNode(aConsoleNode); which returns null and breaks all pruning. We have HUDService.getHudReferenceForOutputNode() which does: while (!node.classList.contains("hudbox-animated")) { if (node.parent) { node = node.parent; } else { return null; } } node.parent is always undefined. That should be node.parentNode. Also, I expect that the while condition needs an update - we cannot assume node.classList is available on all nodes ... it's definitely a possible failure point as well.
Assignee | ||
Comment 4•13 years ago
|
||
this method never really worked before. I removed the classList checking code and verified that we weren't calling getHudRefForOutputNode with child nodes of the output box. The comment doc even specifies that this needs to be an output box as delivered by getHeadsUpDisplay.
Attachment #520287 -
Flags: feedback?(mihai.sucan)
Assignee | ||
Comment 5•13 years ago
|
||
ftr, this needs one more test to verify pruning of repeated nodes works. I'll append that when I get to it.
Whiteboard: [console-1] → [console-1][has-patch][needs-test]
Comment 6•13 years ago
|
||
Comment on attachment 520287 [details] [diff] [review] getHudRefForOutputNode Fix The patch looked fine. Got to test it today. The patch doesn't fix the problem. hudRef is still null. getHudReferenceForOutputNode() is called for both the outputNode (which is a xul:richlistbox element that holds the messages) and for the consoleNode (which is a xul:vbox with class name .hud-box. I think you need to support both cases in the getHudReferenceForOutputNode() implementation. If not, then you must really make sure it's called only for vbox.hud-box. Currently that's not the case. In pruneConsoleOutputIfNecessary(): let hudRef = HUDService.getHudReferenceForOutputNode(aConsoleNode); aConsoleNode is a reference to the outputNode (the xul:richlistbox). Unfortunately, yes, it's very confusing. All the code has confusion over what is console node, hud box and output node. You must determine which is which based on the context and how it is used. Reported bug 643135 because we should cleanup the confusion. I have to give the patch f-.
Attachment #520287 -
Flags: feedback?(mihai.sucan) → feedback-
Assignee | ||
Comment 7•13 years ago
|
||
ugh. imo.
Assignee | ||
Comment 8•13 years ago
|
||
Attachment #520287 -
Attachment is obsolete: true
Attachment #520701 -
Flags: feedback?(mihai.sucan)
Assignee | ||
Comment 9•13 years ago
|
||
now checking cssNodes contents.
Attachment #520701 -
Attachment is obsolete: true
Attachment #520701 -
Flags: feedback?(mihai.sucan)
Attachment #520709 -
Flags: feedback?(mihai.sucan)
Comment 10•13 years ago
|
||
Comment on attachment 520709 [details] [diff] [review] cssPruning tests The patch looks fine. Comments: For the function pruneConsoleOutputIfNecessary(): - * The DOM node that holds the output of the console. + * The DOM node (richlistbox aka hudbox) that holds the output of the + * console. richlistbox is aka outputNode ... not hudbox. The HUD box is is the xul:vbox that holds the entire web console. See HeadsUpDisplay.makeHUDNodes(). For the getHudReferenceForOutputNode(): - * @param nsIDOMNode aNode - * an output node (as returned by getOutputNodeById()). + * @param nsIDOMNode aNode (currently either a richlistbox as returned by + * getOutputNodeById() or a vbox of class hudbox-animated). The getOutputNodeById() returns the xul:vbox, not the richlistbox. The xul:vbox has no hudbox-animated class. The xul:vbox always has the .hud-box class and sometimes it has the .animated class. + while (!node.id) { // starting from richlistbox, need to find hudbox + if (node.parentNode) { + node = node.parentNode; + } else { return null; } } That while looks almost fine, but it will break if we add an ID to any element within the tree of nodes. Why not check for the .hud-box class? or the "hud_" ID prefix? This loop is prone to errors. +const TEST_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-console.html"; I think you can use a data URI here. data:text/html,<p>test for bug 642108. + let hudId = HUDService.displaysIndex()[0]; + let hudBox = HUDService.getHeadsUpDisplay(hudId); + let hudRef = HUDService.getHudReferenceById(hudId); This is stuff that is going to be removed. I recommend: + let hudId = HUDService.getHudIdByWindow(content); + let hudRef = HUDService.getHudReferenceById(hudId); + let hudBox = hudRef.HUDBox; Also hudBox is unused in testCSSPruning(). You could just use getHudIdByWindow(), then getHudReferenceById() and pass the hudRef object to the other functions. No need to repeat stuff in the other functions. I am giving the patch f+ with the above comments addressed.
Attachment #520709 -
Flags: feedback?(mihai.sucan) → feedback+
Assignee | ||
Comment 11•13 years ago
|
||
updated patch with nits addressed.
Attachment #520709 -
Attachment is obsolete: true
Attachment #521634 -
Flags: review?
Assignee | ||
Updated•13 years ago
|
Attachment #521634 -
Flags: review? → review?(ddahl)
Assignee | ||
Updated•13 years ago
|
Whiteboard: [console-1][has-patch][needs-test] → [console-1][has-patch][in-review]
Comment 12•13 years ago
|
||
Comment on attachment 521634 [details] [diff] [review] pruneFix What is this test testing? anything other than the existence of a console UI? >new file mode 100644 >--- /dev/null >+++ b/toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_642108_refForOutputNode.js >@@ -0,0 +1,30 @@ >+/* vim:set ts=2 sw=2 sts=2 et: */ >+/* ***** BEGIN LICENSE BLOCK ***** >+ * Any copyright is dedicated to the Public Domain. >+ * http://creativecommons.org/publicdomain/zero/1.0/ >+ * >+ * ***** END LICENSE BLOCK ***** */ >+ >+// Tests that the Web Console limits the number of lines displayed according to >+// the user's preferences. >+ >+const TEST_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-console.html"; >+ >+function test() { >+ addTab(TEST_URI); >+ browser.addEventListener("DOMContentLoaded", testHudRef, >+ false); >+} >+ >+function testHudRef() { >+ browser.removeEventListener("DOMContentLoaded",testHudRef, false); >+ >+ openConsole(); >+ let hudId = HUDService.displaysIndex()[0]; >+ let hudBox = HUDService.getHeadsUpDisplay(hudId); >+ let hudRef = HUDService.getHudReferenceForOutputNode(hudBox); >+ >+ ok(hudRef, "We have a hudRef"); >+ >+ finishTest(); >+}
Assignee | ||
Comment 13•13 years ago
|
||
(In reply to comment #12) > Comment on attachment 521634 [details] [diff] [review] > pruneFix > > What is this test testing? anything other than the existence of a console UI? I found a bug in getHudReferenceForOutput node where the original implementation didn't properly walk up the chain and retrieve the correct top-level xul console node. I wrote this test to verify that it worked given a hudBox.
Comment 14•13 years ago
|
||
Comment on attachment 521634 [details] [diff] [review] pruneFix Nice - you have simplified some of this code even. + * ***** END LICENSE BLOCK ***** */ + +// Tests that the Web Console limits the number of lines displayed according to +// the user's preferences. + Maybe add a more descriptive comment to the second test ^^ r+ with additional review from a toolkit peer
Attachment #521634 -
Flags: review?(ddahl) → review+
Assignee | ||
Comment 15•13 years ago
|
||
above fix rebased onto current devtools repo and better-commented. Also! As a bonus, added additional tests to verify getHudReferenceForOutputNode works with both types of input. Asking for additional toolkit review, if the module owner thinks it's necessary.
Attachment #521634 -
Attachment is obsolete: true
Attachment #522424 -
Flags: review?(dtownsend)
Updated•13 years ago
|
Attachment #522424 -
Flags: review?(dtownsend) → review+
Assignee | ||
Comment 16•13 years ago
|
||
Comment on attachment 522424 [details] [diff] [review] [in-devtools] pruneFix2 checked into devtools: http://hg.mozilla.org/projects/devtools/rev/23b79a3b6959
Attachment #522424 -
Attachment description: pruneFix2 → [in-devtools] pruneFix2
Assignee | ||
Updated•13 years ago
|
Whiteboard: [console-1][has-patch][in-review] → [console-1][has-patch][in-devtools][needs-merge]
Assignee | ||
Updated•13 years ago
|
Whiteboard: [console-1][has-patch][in-devtools][needs-merge] → [console-1][merge-m-c]
Assignee | ||
Comment 17•13 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/23b79a3b6959
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Whiteboard: [console-1][merge-m-c] → [console-1]
Updated•13 years ago
|
Target Milestone: --- → Firefox 5
Updated•6 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•