add_task(async function test_syncID() {
_("SyncEngine.syncID corresponds to preference");
await SyncTestingInfrastructure(server);
let engine = await makeSteamEngine(); try { // Ensure pristine environment Assert.equal(
Svc.PrefBranch.getPrefType("steam.syncID"),
Ci.nsIPrefBranch.PREF_INVALID
); Assert.equal(await engine.getSyncID(), "");
// Performing the first get on the attribute will generate a new GUID. Assert.equal(await engine.resetLocalSyncID(), "fake-guid-00"); Assert.equal(Svc.PrefBranch.getStringPref("steam.syncID"), "fake-guid-00");
Svc.PrefBranch.setStringPref("steam.syncID", Utils.makeGUID()); Assert.equal(Svc.PrefBranch.getStringPref("steam.syncID"), "fake-guid-01"); Assert.equal(await engine.getSyncID(), "fake-guid-01");
} finally { for (const pref of Svc.PrefBranch.getChildList("")) {
Svc.PrefBranch.clearUserPref(pref);
}
}
});
add_task(async function test_lastSync() {
_("SyncEngine.lastSync corresponds to preferences");
await SyncTestingInfrastructure(server);
let engine = await makeSteamEngine(); try { // Ensure pristine environment Assert.equal(
Svc.PrefBranch.getPrefType("steam.lastSync"),
Ci.nsIPrefBranch.PREF_INVALID
); Assert.equal(await engine.getLastSync(), 0);
// Floats are properly stored as floats and synced with the preference
await engine.setLastSync(123.45); Assert.equal(await engine.getLastSync(), 123.45); Assert.equal(Svc.PrefBranch.getStringPref("steam.lastSync"), "123.45");
// Write file to disk
engine.toFetch = this.toFetch; Assert.equal(engine.toFetch, this.toFetch);
},
check(engine) { // toFetch is written asynchronously
assertSetsEqual(engine.toFetch, this.toFetch);
},
});
await testSteamEngineStorage({
toFetch: guidSetOfSize(4),
toFetch2: guidSetOfSize(5),
setup(engine) { // Make sure it work for consecutive writes before the callback is executed.
engine.toFetch = this.toFetch; Assert.equal(engine.toFetch, this.toFetch);
// Write file to disk
engine.previousFailed = this.previousFailed; Assert.equal(engine.previousFailed, this.previousFailed);
},
check(engine) { // previousFailed is written asynchronously
assertSetsEqual(engine.previousFailed, this.previousFailed);
},
});
await testSteamEngineStorage({
previousFailed: guidSetOfSize(4),
previousFailed2: guidSetOfSize(5),
setup(engine) { // Make sure it work for consecutive writes before the callback is executed.
engine.previousFailed = this.previousFailed; Assert.equal(engine.previousFailed, this.previousFailed);
add_task(async function test_wipeServer() {
_("SyncEngine.wipeServer deletes server data and resets the client.");
let engine = await makeSteamEngine();
const PAYLOAD = 42;
let steamCollection = new ServerWBO("steam", PAYLOAD);
let steamServer = httpd_setup({ "/1.1/foo/storage/steam": steamCollection.handler(),
});
await SyncTestingInfrastructure(steamServer);
do_test_pending();
try { // Some data to reset.
await engine.setLastSync(123.45);
engine.toFetch = guidSetOfSize(3);
_("Wipe server data and reset client.");
await engine.wipeServer(); Assert.equal(steamCollection.payload, undefined); Assert.equal(await engine.getLastSync(), 0); Assert.equal(engine.toFetch.size, 0);
} finally {
steamServer.stop(do_test_finished); for (const pref of Svc.PrefBranch.getChildList("")) {
Svc.PrefBranch.clearUserPref(pref);
}
}
});
add_task(async function finish() {
await promiseStopServer(server);
});
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.