2008-06-18 11:54:24 -07:00
|
|
|
Cu.import("resource://weave/util.js");
|
|
|
|
|
2008-06-03 18:37:36 -07:00
|
|
|
function run_test() {
|
|
|
|
// The JS module we're testing, with all members exposed.
|
|
|
|
var passwords = loadInSandbox("resource://weave/engines/passwords.js");
|
|
|
|
|
|
|
|
// Fake nsILoginInfo object.
|
|
|
|
var fakeUser = {
|
|
|
|
hostname: "www.boogle.com",
|
|
|
|
formSubmitURL: "http://www.boogle.com/search",
|
|
|
|
httpRealm: "",
|
|
|
|
username: "",
|
|
|
|
password: "",
|
|
|
|
usernameField: "test_person",
|
|
|
|
passwordField: "test_password"
|
|
|
|
};
|
|
|
|
|
2008-06-18 11:54:24 -07:00
|
|
|
Utils.getLoginManager = function fake_getLoginManager() {
|
|
|
|
// Return a fake nsILoginManager object.
|
|
|
|
return {getAllLogins: function() { return [fakeUser]; }};
|
|
|
|
};
|
2008-06-03 18:37:36 -07:00
|
|
|
|
2008-06-18 14:12:24 -07:00
|
|
|
Utils.getProfileFile = function fake_getProfileFile(arg) {
|
|
|
|
return {exists: function() {return false;}};
|
|
|
|
};
|
|
|
|
|
2008-06-03 18:37:36 -07:00
|
|
|
// Ensure that _hashLoginInfo() works.
|
|
|
|
var fakeUserHash = passwords._hashLoginInfo(fakeUser);
|
|
|
|
do_check_eq(typeof fakeUserHash, 'string');
|
|
|
|
do_check_eq(fakeUserHash.length, 40);
|
|
|
|
|
|
|
|
// Ensure that PasswordSyncCore._itemExists() works.
|
|
|
|
var psc = new passwords.PasswordSyncCore();
|
|
|
|
do_check_false(psc._itemExists("invalid guid"));
|
|
|
|
do_check_true(psc._itemExists(fakeUserHash));
|
2008-06-18 14:12:24 -07:00
|
|
|
|
|
|
|
var engine = new passwords.PasswordEngine();
|
|
|
|
|
2008-06-03 18:37:36 -07:00
|
|
|
}
|