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