mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
45d3f90cf3
Engines now maintain a reference to the service they belong to. This allows them to obtain references to other engine instances belonging to that service and that service only. Stores and trackers now maintain a reference to the engine they belong to. Engine managers now maintain a reference back to a service. The clients singleton has been removed. It now exists as an instance variable on Service. Parts of ClientsEngine do behave as singletons (e.g. commands). This will be addressed in future refactoring.
62 lines
2.3 KiB
JavaScript
62 lines
2.3 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
Cu.import("resource://services-sync/engines/passwords.js");
|
|
Cu.import("resource://services-sync/service.js");
|
|
Cu.import("resource://services-sync/util.js");
|
|
|
|
function run_test() {
|
|
initTestLogging("Trace");
|
|
Log4Moz.repository.getLogger("Sync.Engine.Passwords").level = Log4Moz.Level.Trace;
|
|
Log4Moz.repository.getLogger("Sync.Store.Passwords").level = Log4Moz.Level.Trace;
|
|
|
|
const BOGUS_GUID_A = "zzzzzzzzzzzz";
|
|
const BOGUS_GUID_B = "yyyyyyyyyyyy";
|
|
let recordA = {id: BOGUS_GUID_A,
|
|
hostname: "http://foo.bar.com",
|
|
formSubmitURL: "http://foo.bar.com/baz",
|
|
httpRealm: "secure",
|
|
username: "john",
|
|
password: "smith",
|
|
usernameField: "username",
|
|
passwordField: "password"};
|
|
let recordB = {id: BOGUS_GUID_B,
|
|
hostname: "http://foo.baz.com",
|
|
formSubmitURL: "http://foo.baz.com/baz",
|
|
username: "john",
|
|
password: "smith",
|
|
usernameField: "username",
|
|
passwordField: "password"};
|
|
|
|
let engine = Service.engineManager.get("passwords");
|
|
let store = engine._store;
|
|
function applyEnsureNoFailures(records) {
|
|
do_check_eq(store.applyIncomingBatch(records).length, 0);
|
|
}
|
|
|
|
try {
|
|
applyEnsureNoFailures([recordA, recordB]);
|
|
|
|
// Only the good record makes it to Services.logins.
|
|
let badCount = {};
|
|
let goodCount = {};
|
|
let badLogins = Services.logins.findLogins(badCount, recordA.hostname,
|
|
recordA.formSubmitURL,
|
|
recordA.httpRealm);
|
|
let goodLogins = Services.logins.findLogins(goodCount, recordB.hostname,
|
|
recordB.formSubmitURL, null);
|
|
|
|
_("Bad: " + JSON.stringify(badLogins));
|
|
_("Good: " + JSON.stringify(goodLogins));
|
|
_("Count: " + badCount.value + ", " + goodCount.value);
|
|
|
|
do_check_eq(goodCount.value, 1);
|
|
do_check_eq(badCount.value, 0);
|
|
|
|
do_check_true(!!store.getAllIDs()[BOGUS_GUID_B]);
|
|
do_check_true(!store.getAllIDs()[BOGUS_GUID_A]);
|
|
} finally {
|
|
store.wipe();
|
|
}
|
|
}
|