michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Check that nsIConsoleMessages are displayed in the Browser Console. michael@0: // See bug 859756. michael@0: michael@0: const TEST_URI = "data:text/html;charset=utf8,bug859756\n" + michael@0: "

hello world\n

nsIConsoleMessages ftw!"; michael@0: michael@0: function test() michael@0: { michael@0: const FILTER_PREF = "devtools.browserconsole.filter.jslog"; michael@0: Services.prefs.setBoolPref(FILTER_PREF, true); michael@0: michael@0: registerCleanupFunction(() => { michael@0: Services.prefs.clearUserPref(FILTER_PREF); michael@0: }); michael@0: michael@0: Task.spawn(function*() { michael@0: const {tab} = yield loadTab(TEST_URI); michael@0: michael@0: // Test for cached nsIConsoleMessages. michael@0: Services.console.logStringMessage("test1 for bug859756"); michael@0: michael@0: info("open web console"); michael@0: let hud = yield openConsole(tab); michael@0: michael@0: ok(hud, "web console opened"); michael@0: Services.console.logStringMessage("do-not-show-me"); michael@0: content.console.log("foobarz"); michael@0: michael@0: yield waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [{ michael@0: text: "foobarz", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_LOG, michael@0: }], michael@0: }); michael@0: michael@0: let text = hud.outputNode.textContent; michael@0: is(text.indexOf("do-not-show-me"), -1, michael@0: "nsIConsoleMessages are not displayed"); michael@0: is(text.indexOf("test1 for bug859756"), -1, michael@0: "nsIConsoleMessages are not displayed (confirmed)"); michael@0: michael@0: yield closeConsole(tab); michael@0: michael@0: info("web console closed"); michael@0: hud = yield HUDService.toggleBrowserConsole(); michael@0: ok(hud, "browser console opened"); michael@0: michael@0: Services.console.logStringMessage("test2 for bug859756"); michael@0: michael@0: let results = yield waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [{ michael@0: text: "test1 for bug859756", michael@0: category: CATEGORY_JS, michael@0: }, { michael@0: text: "test2 for bug859756", michael@0: category: CATEGORY_JS, michael@0: }, { michael@0: text: "do-not-show-me", michael@0: category: CATEGORY_JS, michael@0: }], michael@0: }); michael@0: michael@0: let msg = [...results[2].matched][0]; michael@0: ok(msg, "message element for do-not-show-me (nsIConsoleMessage)"); michael@0: isnot(msg.textContent.indexOf("do-not-show"), -1, "element content is correct"); michael@0: ok(!msg.classList.contains("filtered-by-type"), "element is not filtered"); michael@0: michael@0: hud.setFilterState("jslog", false); michael@0: michael@0: ok(msg.classList.contains("filtered-by-type"), "element is filtered"); michael@0: }).then(finishTest); michael@0: }