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 | "use strict"; |
michael@0 | 3 | |
michael@0 | 4 | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 5 | Cu.import('resource://gre/modules/Services.jsm'); |
michael@0 | 6 | Cu.import('resource://gre/modules/identity/LogUtils.jsm'); |
michael@0 | 7 | |
michael@0 | 8 | function toggle_debug() { |
michael@0 | 9 | do_test_pending(); |
michael@0 | 10 | |
michael@0 | 11 | function Wrapper() { |
michael@0 | 12 | this.init(); |
michael@0 | 13 | } |
michael@0 | 14 | Wrapper.prototype = { |
michael@0 | 15 | QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, Ci.nsIObserver]), |
michael@0 | 16 | |
michael@0 | 17 | observe: function observe(aSubject, aTopic, aData) { |
michael@0 | 18 | if (aTopic === "nsPref:changed") { |
michael@0 | 19 | // race condition? |
michael@0 | 20 | do_check_eq(Logger._debug, true); |
michael@0 | 21 | do_test_finished(); |
michael@0 | 22 | run_next_test(); |
michael@0 | 23 | } |
michael@0 | 24 | }, |
michael@0 | 25 | |
michael@0 | 26 | init: function() { |
michael@0 | 27 | Services.prefs.addObserver('toolkit.identity.debug', this, false); |
michael@0 | 28 | } |
michael@0 | 29 | }; |
michael@0 | 30 | |
michael@0 | 31 | var wrapper = new Wrapper(); |
michael@0 | 32 | Services.prefs.setBoolPref('toolkit.identity.debug', true); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | // test that things don't break |
michael@0 | 36 | |
michael@0 | 37 | function logAlias(...args) { |
michael@0 | 38 | Logger.log.apply(Logger, ["log alias"].concat(args)); |
michael@0 | 39 | } |
michael@0 | 40 | function reportErrorAlias(...args) { |
michael@0 | 41 | Logger.reportError.apply(Logger, ["report error alias"].concat(args)); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | function test_log() { |
michael@0 | 45 | Logger.log("log test", "I like pie"); |
michael@0 | 46 | do_test_finished(); |
michael@0 | 47 | run_next_test(); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | function test_reportError() { |
michael@0 | 51 | Logger.reportError("log test", "We are out of pies!!!"); |
michael@0 | 52 | do_test_finished(); |
michael@0 | 53 | run_next_test(); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | function test_wrappers() { |
michael@0 | 57 | logAlias("I like potatoes"); |
michael@0 | 58 | do_test_finished(); |
michael@0 | 59 | reportErrorAlias("Too much red bull"); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | let TESTS = [ |
michael@0 | 63 | // XXX fix me |
michael@0 | 64 | // toggle_debug, |
michael@0 | 65 | test_log, |
michael@0 | 66 | test_reportError, |
michael@0 | 67 | test_wrappers, |
michael@0 | 68 | ]; |
michael@0 | 69 | |
michael@0 | 70 | TESTS.forEach(add_test); |
michael@0 | 71 | |
michael@0 | 72 | function run_test() { |
michael@0 | 73 | run_next_test(); |
michael@0 | 74 | } |