// Don't flush to disk in the middle of an event listener! // This causes test hangs on WinXP.
reconciler._shouldPersist = false;
await resetReconciler();
});
// This is a basic sanity test for the unit test itself. If this breaks, the // add-ons API likely changed upstream.
add_task(async function test_addon_install() {
_("Ensure basic add-on APIs work as expected.");
_("Ensure getChangedIDs() has the appropriate behavior.");
_("Ensure getChangedIDs() returns an empty object by default.");
let changes = await engine.getChangedIDs(); Assert.equal("object", typeof changes); Assert.equal(0, Object.keys(changes).length);
_("Ensure tracker changes are populated.");
let now = new Date();
let changeTime = now.getTime() / 1000;
let guid1 = Utils.makeGUID();
await tracker.addChangedID(guid1, changeTime);
add_task(async function test_disabled_install_semantics() {
_("Ensure that syncing a disabled add-on preserves proper state.");
// This is essentially a test for bug 712542, which snuck into the original // add-on sync drop. It ensures that when an add-on is installed that the // disabled state and incoming syncGUID is preserved, even on the next sync. const USER = "foo"; const PASSWORD = "password";
let server = new SyncServer();
server.start();
await SyncTestingInfrastructure(server, USER, PASSWORD);
// Insert an existing record into the server.
let id = Utils.makeGUID();
let now = Date.now() / 1000;
let record = encryptPayload({
id,
applicationID: Services.appinfo.ID,
addonID: ADDON_ID,
enabled: false,
deleted: false,
source: "amo",
});
let wbo = new ServerWBO(id, record, now - 2);
server.insertWBO(USER, "addons", wbo);
_("Performing sync of add-ons engine.");
await engine._sync();
// At this point the non-restartless extension should be staged for install.
// Don't need this server any more.
await promiseStopServer(amoServer);
// We ensure the reconciler has recorded the proper ID and enabled state.
let addon = reconciler.getAddonStateFromSyncGUID(id); Assert.notEqual(null, addon); Assert.equal(false, addon.enabled);
// We fake an app restart and perform another sync, just to make sure things // are sane.
await AddonTestUtils.promiseRestartManager();
let collection = server.getCollection(USER, "addons");
engine.lastModified = collection.timestamp;
await engine._sync();
// The client should not upload a new record. The old record should be // retained and unmodified. Assert.equal(1, collection.count());
let payload = collection.payloads()[0]; Assert.notEqual(null, collection.wbo(id)); Assert.equal(ADDON_ID, payload.addonID); Assert.ok(!payload.enabled);
await promiseStopServer(server);
});
add_test(function cleanup() { // There's an xpcom-shutdown hook for this, but let's give this a shot.
reconciler.stopListening();
run_next_test();
});
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.