michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: Cu.import("resource://services-sync/service.js"); michael@0: Cu.import("resource://services-sync/util.js"); michael@0: michael@0: function run_test() { michael@0: let debug = []; michael@0: let info = []; michael@0: michael@0: function augmentLogger(old) { michael@0: let d = old.debug; michael@0: let i = old.info; michael@0: old.debug = function(m) { debug.push(m); d.call(old, m); } michael@0: old.info = function(m) { info.push(m); i.call(old, m); } michael@0: return old; michael@0: } michael@0: michael@0: Log.repository.rootLogger.addAppender(new Log.DumpAppender()); michael@0: michael@0: augmentLogger(Service._log); michael@0: michael@0: // Avoid daily ping michael@0: Svc.Prefs.set("lastPing", Math.floor(Date.now() / 1000)); michael@0: michael@0: _("Check that sync will log appropriately if already in 'progress'."); michael@0: Service._locked = true; michael@0: Service.sync(); michael@0: Service._locked = false; michael@0: michael@0: do_check_eq(debug[debug.length - 2], michael@0: "Exception: Could not acquire lock. Label: \"service.js: login\". No traceback available"); michael@0: do_check_eq(info[info.length - 1], michael@0: "Cannot start sync: already syncing?"); michael@0: } michael@0: