gecko/services/sync/tests/unit/head_first.js
2008-06-06 21:40:30 -07:00

42 lines
1.1 KiB
JavaScript

version(180);
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
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");
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;
}