mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 642108 - JS errors from HUD in Error Console; f=mihai.sucan r=ddahl,dtownsend
This commit is contained in:
parent
e73bf20e13
commit
006f725f21
@ -1183,7 +1183,8 @@ NetworkPanel.prototype =
|
||||
* present.
|
||||
*
|
||||
* @param nsIDOMNode aConsoleNode
|
||||
* The DOM node that holds the output of the console.
|
||||
* The DOM node (richlistbox aka outputNode) that holds the output of the
|
||||
* console.
|
||||
* @return number
|
||||
* The current user-selected log limit.
|
||||
*/
|
||||
@ -1209,7 +1210,10 @@ function pruneConsoleOutputIfNecessary(aConsoleNode)
|
||||
for (let i = 0; i < removeNodes; i++) {
|
||||
if (messageNodes[i].classList.contains("webconsole-msg-cssparser")) {
|
||||
let desc = messageNodes[i].childNodes[2].textContent;
|
||||
let location = messageNodes[i].childNodes[4].getAttribute("title");
|
||||
let location = "";
|
||||
if (messageNodes[i].childNodes[4]) {
|
||||
location = messageNodes[i].childNodes[4].getAttribute("title");
|
||||
}
|
||||
delete hudRef.cssNodes[desc + location];
|
||||
}
|
||||
messageNodes[i].parentNode.removeChild(messageNodes[i]);
|
||||
@ -1857,23 +1861,22 @@ HUD_SERVICE.prototype =
|
||||
/**
|
||||
* Returns the hudReference for a given output node.
|
||||
*
|
||||
* @param nsIDOMNode aNode
|
||||
* an output node (as returned by getOutputNodeById()).
|
||||
* @param nsIDOMNode aNode (currently either a xul:vbox as returned by
|
||||
* getOutputNodeById() or a richlistbox).
|
||||
* @returns a HUD | null
|
||||
*/
|
||||
getHudReferenceForOutputNode: function HS_getHudReferenceForOutputNode(aNode)
|
||||
{
|
||||
let node = aNode;
|
||||
while (!node.classList.contains("hudbox-animated")) {
|
||||
if (node.parent) {
|
||||
node = node.parent;
|
||||
}
|
||||
else {
|
||||
// starting from richlistbox, need to find hudbox
|
||||
while (!node.id && !node.classList.contains("hud-box")) {
|
||||
if (node.parentNode) {
|
||||
node = node.parentNode;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
let id = node.id;
|
||||
return id in this.hudReferences ? this.hudReferences[id] : null;
|
||||
return this.getHudReferenceById(node.id);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1989,7 +1992,7 @@ HUD_SERVICE.prototype =
|
||||
* Get OutputNode by Id
|
||||
*
|
||||
* @param string aId
|
||||
* @returns nsIDOMNode
|
||||
* @returns nsIDOMNode (richlistbox)
|
||||
*/
|
||||
getConsoleOutputNode: function HS_getConsoleOutputNode(aId)
|
||||
{
|
||||
@ -5301,7 +5304,8 @@ ConsoleUtils = {
|
||||
return false;
|
||||
},
|
||||
|
||||
/** * Filters a node appropriately, then sends it to the output, regrouping and
|
||||
/**
|
||||
* Filters a node appropriately, then sends it to the output, regrouping and
|
||||
* pruning output as necessary.
|
||||
*
|
||||
* @param nsIDOMNode aNode
|
||||
@ -5311,7 +5315,6 @@ ConsoleUtils = {
|
||||
*/
|
||||
outputMessageNode: function ConsoleUtils_outputMessageNode(aNode, aHUDId) {
|
||||
ConsoleUtils.filterMessageNode(aNode, aHUDId);
|
||||
|
||||
let outputNode = HUDService.hudReferences[aHUDId].outputNode;
|
||||
|
||||
let scrolledToBottom = ConsoleUtils.isOutputScrolledToBottom(outputNode);
|
||||
|
@ -129,6 +129,8 @@ _BROWSER_TEST_FILES = \
|
||||
browser_webconsole_bug_618311_close_panels.js \
|
||||
browser_webconsole_bug_618311_private_browsing.js \
|
||||
browser_webconsole_bug_632347_iterators_generators.js \
|
||||
browser_webconsole_bug_642108_refForOutputNode.js \
|
||||
browser_webconsole_bug_642108_pruneTest.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
|
@ -0,0 +1,74 @@
|
||||
/* 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 = "data:text/html,<p>test for bug 642108.";
|
||||
const LOG_LIMIT = 20;
|
||||
const CATEGORY_CSS = 1;
|
||||
const SEVERITY_WARNING = 1;
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("DOMContentLoaded", testCSSPruning, false);
|
||||
}
|
||||
|
||||
function populateConsoleRepeats(aHudRef) {
|
||||
let hud = aHudRef.HUDBox;
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
let node = ConsoleUtils.createMessageNode(hud.ownerDocument,
|
||||
CATEGORY_CSS,
|
||||
SEVERITY_WARNING,
|
||||
"css log x");
|
||||
ConsoleUtils.outputMessageNode(node, aHudRef.hudId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function populateConsole(aHudRef) {
|
||||
let hud = aHudRef.HUDBox;
|
||||
|
||||
for (i = 0; i < LOG_LIMIT + 5; i++) {
|
||||
let node = ConsoleUtils.createMessageNode(hud.ownerDocument,
|
||||
CATEGORY_CSS,
|
||||
SEVERITY_WARNING,
|
||||
"css log " + i);
|
||||
ConsoleUtils.outputMessageNode(node, aHudRef.hudId);
|
||||
}
|
||||
}
|
||||
|
||||
function testCSSPruning() {
|
||||
let prefBranch = Services.prefs.getBranch("devtools.hud.");
|
||||
prefBranch.setIntPref("loglimit", LOG_LIMIT);
|
||||
|
||||
browser.removeEventListener("DOMContentLoaded",testCSSPruning, false);
|
||||
|
||||
openConsole();
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
let hudRef = HUDService.getHudReferenceById(hudId);
|
||||
|
||||
populateConsoleRepeats(hudRef);
|
||||
ok(hudRef.cssNodes["css log x"], "repeated nodes in cssNodes");
|
||||
|
||||
populateConsole(hudRef);
|
||||
|
||||
is(countMessageNodes(), LOG_LIMIT, "number of nodes is LOG_LIMIT");
|
||||
ok(!hudRef.cssNodes["css log x"], "repeated nodes pruned from cssNodes");
|
||||
|
||||
prefBranch.clearUserPref("loglimit");
|
||||
prefBranch = null;
|
||||
|
||||
finishTest();
|
||||
}
|
||||
|
||||
function countMessageNodes() {
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
let hudBox = HUDService.getHeadsUpDisplay(hudId);
|
||||
return hudBox.querySelectorAll(".hud-msg-node").length;
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/* 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 getHudReferenceForOutputNode returns a reference when passed
|
||||
// a hudBox (xul:vbox) or an output box (richlistbox).
|
||||
|
||||
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");
|
||||
|
||||
let outBox = HUDService.getOutputNodeById(hudId);
|
||||
let hudRef2 = HUDService.getHudReferenceForOutputNode(outBox);
|
||||
|
||||
ok(hudRef2, "We have the second hudRef");
|
||||
is(hudRef, hudRef2, "The two hudRefs are identical");
|
||||
|
||||
finishTest();
|
||||
}
|
Loading…
Reference in New Issue
Block a user