michael@0: michael@0: "use strict"; michael@0: michael@0: Cu.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: Cu.import('resource://gre/modules/Services.jsm'); michael@0: Cu.import('resource://gre/modules/identity/LogUtils.jsm'); michael@0: michael@0: function toggle_debug() { michael@0: do_test_pending(); michael@0: michael@0: function Wrapper() { michael@0: this.init(); michael@0: } michael@0: Wrapper.prototype = { michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, Ci.nsIObserver]), michael@0: michael@0: observe: function observe(aSubject, aTopic, aData) { michael@0: if (aTopic === "nsPref:changed") { michael@0: // race condition? michael@0: do_check_eq(Logger._debug, true); michael@0: do_test_finished(); michael@0: run_next_test(); michael@0: } michael@0: }, michael@0: michael@0: init: function() { michael@0: Services.prefs.addObserver('toolkit.identity.debug', this, false); michael@0: } michael@0: }; michael@0: michael@0: var wrapper = new Wrapper(); michael@0: Services.prefs.setBoolPref('toolkit.identity.debug', true); michael@0: } michael@0: michael@0: // test that things don't break michael@0: michael@0: function logAlias(...args) { michael@0: Logger.log.apply(Logger, ["log alias"].concat(args)); michael@0: } michael@0: function reportErrorAlias(...args) { michael@0: Logger.reportError.apply(Logger, ["report error alias"].concat(args)); michael@0: } michael@0: michael@0: function test_log() { michael@0: Logger.log("log test", "I like pie"); michael@0: do_test_finished(); michael@0: run_next_test(); michael@0: } michael@0: michael@0: function test_reportError() { michael@0: Logger.reportError("log test", "We are out of pies!!!"); michael@0: do_test_finished(); michael@0: run_next_test(); michael@0: } michael@0: michael@0: function test_wrappers() { michael@0: logAlias("I like potatoes"); michael@0: do_test_finished(); michael@0: reportErrorAlias("Too much red bull"); michael@0: } michael@0: michael@0: let TESTS = [ michael@0: // XXX fix me michael@0: // toggle_debug, michael@0: test_log, michael@0: test_reportError, michael@0: test_wrappers, michael@0: ]; michael@0: michael@0: TESTS.forEach(add_test); michael@0: michael@0: function run_test() { michael@0: run_next_test(); michael@0: }