2008-04-30 13:01:17 -07:00
|
|
|
version(180);
|
|
|
|
|
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cr = Components.results;
|
2008-06-16 14:06:05 -07:00
|
|
|
const Cu = Components.utils;
|
2008-04-30 13:01:17 -07:00
|
|
|
|
|
|
|
let ds = Cc["@mozilla.org/file/directory_service;1"]
|
|
|
|
.getService(Ci.nsIProperties);
|
|
|
|
|
|
|
|
let provider = {
|
|
|
|
getFile: function(prop, persistent) {
|
|
|
|
persistent.value = true;
|
|
|
|
if (prop == "ExtPrefDL") {
|
|
|
|
return [ds.get("CurProcD", Ci.nsIFile)];
|
|
|
|
}
|
|
|
|
throw Cr.NS_ERROR_FAILURE;
|
|
|
|
},
|
|
|
|
QueryInterface: function(iid) {
|
|
|
|
if (iid.equals(Ci.nsIDirectoryServiceProvider) ||
|
|
|
|
iid.equals(Ci.nsISupports)) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
ds.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider);
|
|
|
|
|
|
|
|
do_bind_resource(do_get_file("modules"), "weave");
|
2008-06-06 21:40:30 -07:00
|
|
|
|
|
|
|
function loadInSandbox(aUri) {
|
|
|
|
var sandbox = Components.utils.Sandbox(this);
|
|
|
|
var request = Components.
|
|
|
|
classes["@mozilla.org/xmlextras/xmlhttprequest;1"].
|
|
|
|
createInstance();
|
|
|
|
|
|
|
|
request.open("GET", aUri, false);
|
|
|
|
request.send(null);
|
|
|
|
Components.utils.evalInSandbox(request.responseText, sandbox);
|
|
|
|
|
|
|
|
return sandbox;
|
|
|
|
}
|
2008-06-09 20:51:23 -07:00
|
|
|
|
2008-06-16 16:22:00 -07:00
|
|
|
function initTestLogging() {
|
2008-06-09 20:51:23 -07:00
|
|
|
Cu.import("resource://weave/log4moz.js");
|
|
|
|
|
2008-06-16 16:22:00 -07:00
|
|
|
function LogStats() {
|
|
|
|
this.errorsLogged = 0;
|
|
|
|
}
|
|
|
|
LogStats.prototype = {
|
2008-06-09 20:51:23 -07:00
|
|
|
format: function BF_format(message) {
|
|
|
|
if (message.level == Log4Moz.Level.Error)
|
2008-06-16 16:22:00 -07:00
|
|
|
this.errorsLogged += 1;
|
2008-06-09 20:51:23 -07:00
|
|
|
return message.loggerName + "\t" + message.levelDesc + "\t" +
|
|
|
|
message.message + "\n";
|
|
|
|
}
|
|
|
|
};
|
2008-06-16 16:22:00 -07:00
|
|
|
LogStats.prototype.__proto__ = new Log4Moz.Formatter();
|
2008-06-09 20:51:23 -07:00
|
|
|
|
|
|
|
var log = Log4Moz.Service.rootLogger;
|
2008-06-16 16:22:00 -07:00
|
|
|
var logStats = new LogStats();
|
|
|
|
var appender = new Log4Moz.DumpAppender(logStats);
|
2008-06-09 20:51:23 -07:00
|
|
|
log.level = Log4Moz.Level.Debug;
|
|
|
|
appender.level = Log4Moz.Level.Debug;
|
|
|
|
log.addAppender(appender);
|
|
|
|
|
2008-06-16 16:22:00 -07:00
|
|
|
return logStats;
|
|
|
|
}
|
|
|
|
|
|
|
|
function makeAsyncTestRunner(generator) {
|
|
|
|
Cu.import("resource://weave/async.js");
|
|
|
|
|
|
|
|
var logStats = initTestLogging();
|
|
|
|
|
2008-06-09 20:51:23 -07:00
|
|
|
function run_test() {
|
|
|
|
do_test_pending();
|
|
|
|
|
|
|
|
let onComplete = function() {
|
2008-06-16 16:22:00 -07:00
|
|
|
if (logStats.errorsLogged)
|
2008-06-09 20:51:23 -07:00
|
|
|
do_throw("Errors were logged.");
|
|
|
|
else
|
|
|
|
do_test_finished();
|
|
|
|
};
|
|
|
|
|
|
|
|
Async.run({}, generator, onComplete);
|
|
|
|
}
|
|
|
|
|
|
|
|
return run_test;
|
|
|
|
}
|