|
1 /* |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
4 */ |
|
5 |
|
6 // Check that nsIConsoleMessages are displayed in the Browser Console. |
|
7 // See bug 859756. |
|
8 |
|
9 const TEST_URI = "data:text/html;charset=utf8,<title>bug859756</title>\n" + |
|
10 "<p>hello world\n<p>nsIConsoleMessages ftw!"; |
|
11 |
|
12 function test() |
|
13 { |
|
14 const FILTER_PREF = "devtools.browserconsole.filter.jslog"; |
|
15 Services.prefs.setBoolPref(FILTER_PREF, true); |
|
16 |
|
17 registerCleanupFunction(() => { |
|
18 Services.prefs.clearUserPref(FILTER_PREF); |
|
19 }); |
|
20 |
|
21 Task.spawn(function*() { |
|
22 const {tab} = yield loadTab(TEST_URI); |
|
23 |
|
24 // Test for cached nsIConsoleMessages. |
|
25 Services.console.logStringMessage("test1 for bug859756"); |
|
26 |
|
27 info("open web console"); |
|
28 let hud = yield openConsole(tab); |
|
29 |
|
30 ok(hud, "web console opened"); |
|
31 Services.console.logStringMessage("do-not-show-me"); |
|
32 content.console.log("foobarz"); |
|
33 |
|
34 yield waitForMessages({ |
|
35 webconsole: hud, |
|
36 messages: [{ |
|
37 text: "foobarz", |
|
38 category: CATEGORY_WEBDEV, |
|
39 severity: SEVERITY_LOG, |
|
40 }], |
|
41 }); |
|
42 |
|
43 let text = hud.outputNode.textContent; |
|
44 is(text.indexOf("do-not-show-me"), -1, |
|
45 "nsIConsoleMessages are not displayed"); |
|
46 is(text.indexOf("test1 for bug859756"), -1, |
|
47 "nsIConsoleMessages are not displayed (confirmed)"); |
|
48 |
|
49 yield closeConsole(tab); |
|
50 |
|
51 info("web console closed"); |
|
52 hud = yield HUDService.toggleBrowserConsole(); |
|
53 ok(hud, "browser console opened"); |
|
54 |
|
55 Services.console.logStringMessage("test2 for bug859756"); |
|
56 |
|
57 let results = yield waitForMessages({ |
|
58 webconsole: hud, |
|
59 messages: [{ |
|
60 text: "test1 for bug859756", |
|
61 category: CATEGORY_JS, |
|
62 }, { |
|
63 text: "test2 for bug859756", |
|
64 category: CATEGORY_JS, |
|
65 }, { |
|
66 text: "do-not-show-me", |
|
67 category: CATEGORY_JS, |
|
68 }], |
|
69 }); |
|
70 |
|
71 let msg = [...results[2].matched][0]; |
|
72 ok(msg, "message element for do-not-show-me (nsIConsoleMessage)"); |
|
73 isnot(msg.textContent.indexOf("do-not-show"), -1, "element content is correct"); |
|
74 ok(!msg.classList.contains("filtered-by-type"), "element is not filtered"); |
|
75 |
|
76 hud.setFilterState("jslog", false); |
|
77 |
|
78 ok(msg.classList.contains("filtered-by-type"), "element is filtered"); |
|
79 }).then(finishTest); |
|
80 } |