summaryrefslogtreecommitdiffstats
path: root/services/sync/tests/unit/test_errorhandler_filelog.js
diff options
context:
space:
mode:
Diffstat (limited to 'services/sync/tests/unit/test_errorhandler_filelog.js')
-rw-r--r--services/sync/tests/unit/test_errorhandler_filelog.js83
1 files changed, 18 insertions, 65 deletions
diff --git a/services/sync/tests/unit/test_errorhandler_filelog.js b/services/sync/tests/unit/test_errorhandler_filelog.js
index 993a478fd..0ce82b170 100644
--- a/services/sync/tests/unit/test_errorhandler_filelog.js
+++ b/services/sync/tests/unit/test_errorhandler_filelog.js
@@ -21,7 +21,7 @@ const DELAY_BUFFER = 500; // Buffer for timers on different OS platforms.
const PROLONGED_ERROR_DURATION =
(Svc.Prefs.get('errorhandler.networkFailureReportTimeout') * 2) * 1000;
-var errorHandler = Service.errorHandler;
+let errorHandler = Service.errorHandler;
function setLastSync(lastSyncValue) {
Svc.Prefs.set("lastSync", (new Date(Date.now() - lastSyncValue)).toString());
@@ -35,8 +35,6 @@ function run_test() {
Log.repository.getLogger("Sync.SyncScheduler").level = Log.Level.Trace;
Log.repository.getLogger("Sync.ErrorHandler").level = Log.Level.Trace;
- validate_all_future_pings();
-
run_next_test();
}
@@ -47,22 +45,20 @@ add_test(function test_noOutput() {
// Clear log output from startup.
Svc.Prefs.set("log.appender.file.logOnSuccess", false);
Svc.Obs.notify("weave:service:sync:finish");
- Svc.Obs.add("weave:service:reset-file-log", function onResetFileLogOuter() {
- Svc.Obs.remove("weave:service:reset-file-log", onResetFileLogOuter);
- // Clear again without having issued any output.
- Svc.Prefs.set("log.appender.file.logOnSuccess", true);
- Svc.Obs.add("weave:service:reset-file-log", function onResetFileLogInner() {
- Svc.Obs.remove("weave:service:reset-file-log", onResetFileLogInner);
+ // Clear again without having issued any output.
+ Svc.Prefs.set("log.appender.file.logOnSuccess", true);
- errorHandler._logManager._fileAppender.level = Log.Level.Trace;
- Svc.Prefs.resetBranch("");
- run_next_test();
- });
+ Svc.Obs.add("weave:service:reset-file-log", function onResetFileLog() {
+ Svc.Obs.remove("weave:service:reset-file-log", onResetFileLog);
- // Fake a successful sync.
- Svc.Obs.notify("weave:service:sync:finish");
+ errorHandler._logManager._fileAppender.level = Log.Level.Trace;
+ Svc.Prefs.resetBranch("");
+ run_next_test();
});
+
+ // Fake a successful sync.
+ Svc.Obs.notify("weave:service:sync:finish");
});
add_test(function test_logOnSuccess_false() {
@@ -85,14 +81,16 @@ add_test(function test_logOnSuccess_false() {
});
function readFile(file, callback) {
- NetUtil.asyncFetch({
- uri: NetUtil.newURI(file),
- loadUsingSystemPrincipal: true
- }, function (inputStream, statusCode, request) {
+ NetUtil.asyncFetch2(file, function (inputStream, statusCode, request) {
let data = NetUtil.readInputStreamToString(inputStream,
inputStream.available());
callback(statusCode, data);
- });
+ },
+ null, // aLoadingNode
+ Services.scriptSecurityManager.getSystemPrincipal(),
+ null, // aTriggeringPrincipal
+ Ci.nsILoadInfo.SEC_NORMAL,
+ Ci.nsIContentPolicy.TYPE_OTHER);
}
add_test(function test_logOnSuccess_true() {
@@ -269,51 +267,6 @@ add_test(function test_login_error_logOnError_true() {
Svc.Obs.notify("weave:service:login:error");
});
-
-add_test(function test_errorLog_dumpAddons() {
- Svc.Prefs.set("log.appender.file.logOnError", true);
-
- let log = Log.repository.getLogger("Sync.Test.FileLog");
-
- // We need to wait until the log cleanup started by this test is complete
- // or the next test will fail as it is ongoing.
- Svc.Obs.add("services-tests:common:log-manager:cleanup-logs", function onCleanupLogs() {
- Svc.Obs.remove("services-tests:common:log-manager:cleanup-logs", onCleanupLogs);
- run_next_test();
- });
-
- Svc.Obs.add("weave:service:reset-file-log", function onResetFileLog() {
- Svc.Obs.remove("weave:service:reset-file-log", onResetFileLog);
-
- let entries = logsdir.directoryEntries;
- do_check_true(entries.hasMoreElements());
- let logfile = entries.getNext().QueryInterface(Ci.nsILocalFile);
- do_check_eq(logfile.leafName.slice(-4), ".txt");
- do_check_true(logfile.leafName.startsWith("error-sync-"), logfile.leafName);
- do_check_false(entries.hasMoreElements());
-
- // Ensure we logged some addon list (which is probably empty)
- readFile(logfile, function (error, data) {
- do_check_true(Components.isSuccessCode(error));
- do_check_neq(data.indexOf("Addons installed"), -1);
-
- // Clean up.
- try {
- logfile.remove(false);
- } catch(ex) {
- dump("Couldn't delete file: " + ex + "\n");
- // Stupid Windows box.
- }
-
- Svc.Prefs.resetBranch("");
- });
- });
-
- // Fake an unsuccessful sync due to prolonged failure.
- setLastSync(PROLONGED_ERROR_DURATION);
- Svc.Obs.notify("weave:service:sync:error");
-});
-
// Check that error log files are deleted above an age threshold.
add_test(function test_logErrorCleanup_age() {
_("Beginning test_logErrorCleanup_age.");