зеркало из https://github.com/mozilla/pjs.git
Bug 589162 - CSS filtering on the console does not work r=sdwilsh a=betaN+
This commit is contained in:
Родитель
cc96b89e3a
Коммит
af87cdc51e
|
@ -4688,8 +4688,12 @@ LogMessage.prototype = {
|
|||
|
||||
this.messageNode.appendChild(messageTxtNode);
|
||||
|
||||
var klass = "hud-msg-node hud-" + this.level;
|
||||
this.messageNode.setAttribute("class", klass);
|
||||
this.messageNode.classList.add("hud-msg-node");
|
||||
this.messageNode.classList.add("hud-" + this.level);
|
||||
|
||||
if (this.activityObject.category == "CSS Parser") {
|
||||
this.messageNode.classList.add("hud-cssparser");
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ _BROWSER_TEST_FILES = \
|
|||
browser_webconsole_netlogging.js \
|
||||
browser_webconsole_bug_583816_tab_focus.js \
|
||||
browser_webconsole_bug_594477_clickable_output.js \
|
||||
browser_webconsole_bug_589162_css_filter.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/* 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/
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mihai Șucan <mihai.sucan@gmail.com>
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const TEST_URI = "data:text/html,<div style='font-size:3em;" +
|
||||
"foobarCssParser:baz'>test CSS parser filter</div>"
|
||||
|
||||
function onContentLoaded()
|
||||
{
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
let HUD = HUDService.getDisplayByURISpec(content.location.href);
|
||||
let hudId = HUD.getAttribute("id");
|
||||
let filterBox = HUD.querySelector(".hud-filter-box");
|
||||
let outputNode = HUD.querySelector(".hud-output-node");
|
||||
|
||||
let warningFound = "the unknown CSS property warning is displayed";
|
||||
let warningNotFound = "could not find the unknown CSS property warning";
|
||||
|
||||
testLogEntry(outputNode, "foobarCssParser",
|
||||
{ success: warningFound, err: warningNotFound }, true);
|
||||
|
||||
HUDService.setFilterState(hudId, "cssparser", false);
|
||||
|
||||
warningNotFound = "the unknown CSS property warning is not displayed, " +
|
||||
"after filtering";
|
||||
warningFound = "the unknown CSS property warning is still displayed, " +
|
||||
"after filtering";
|
||||
|
||||
testLogEntry(outputNode, "foobarCssParser",
|
||||
{ success: warningNotFound, err: warningFound }, true, true);
|
||||
|
||||
finishTest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit test for bug 589162:
|
||||
* CSS filtering on the console does not work
|
||||
*/
|
||||
function test()
|
||||
{
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
openConsole();
|
||||
browser.addEventListener("load", onContentLoaded, true);
|
||||
content.location.reload();
|
||||
}, true);
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* David Dahl <ddahl@mozilla.com>
|
||||
* Mihai Șucan <mihai.sucan@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -69,14 +70,50 @@ function addTab(aURL)
|
|||
browser = gBrowser.getBrowserForTab(tab);
|
||||
}
|
||||
|
||||
function testLogEntry(aOutputNode, aMatchString, aSuccessErrObj)
|
||||
/**
|
||||
* Check if a log entry exists in the HUD output node.
|
||||
*
|
||||
* @param {Element} aOutputNode
|
||||
* the HUD output node.
|
||||
* @param {string} aMatchString
|
||||
* the string you want to check if it exists in the output node.
|
||||
* @param {boolean} [aOnlyVisible=false]
|
||||
* find only messages that are visible, not hidden by the filter.
|
||||
* @param {boolean} [aFailIfFound=false]
|
||||
* fail the test if the string is found in the output node.
|
||||
*/
|
||||
function testLogEntry(aOutputNode, aMatchString, aSuccessErrObj, aOnlyVisible,
|
||||
aFailIfFound)
|
||||
{
|
||||
var message = aOutputNode.textContent.indexOf(aMatchString);
|
||||
let found = true;
|
||||
let notfound = false;
|
||||
let foundMsg = aSuccessErrObj.success;
|
||||
let notfoundMsg = aSuccessErrObj.err;
|
||||
|
||||
if (aFailIfFound) {
|
||||
found = false;
|
||||
notfound = true;
|
||||
foundMsg = aSuccessErrObj.err;
|
||||
notfoundMsg = aSuccessErrObj.success;
|
||||
}
|
||||
|
||||
let selector = ".hud-group > *";
|
||||
|
||||
// Skip entries that are hidden by the filter.
|
||||
if (aOnlyVisible) {
|
||||
selector += ":not(.hud-filtered-by-type)";
|
||||
}
|
||||
|
||||
let msgs = aOutputNode.querySelectorAll(selector);
|
||||
for (let i = 0, n = msgs.length; i < n; i++) {
|
||||
let message = msgs[i].textContent.indexOf(aMatchString);
|
||||
if (message > -1) {
|
||||
ok(true, aSuccessErrObj.success);
|
||||
ok(found, foundMsg);
|
||||
return;
|
||||
}
|
||||
ok(false, aSuccessErrObj.err);
|
||||
}
|
||||
|
||||
ok(notfound, notfoundMsg);
|
||||
}
|
||||
|
||||
function openConsole()
|
||||
|
|
Загрузка…
Ссылка в новой задаче