// Creates a unique profile directory to use for a test. function withDummyProfile(task) { return async () => {
let profile = PathUtils.join(gProfD.path, "" + ID++);
await IOUtils.makeDirectory(profile);
await task(profile);
await IOUtils.remove(profile, { recursive: true });
};
}
add_task(
withDummyProfile(async profile => {
let times = await ProfileAge(profile); Assert.ok(
(await times.created) > 0, "We can't really say what this will be, just assume if it is a number it's ok."
); Assert.equal(
await times.reset,
undefined, "Reset time is undefined in a new profile"
); Assert.ok(
(await times.firstUse) <= Date.now(), "Should have initialised a first use time."
);
})
);
let times = await ProfileAge(profile); Assert.equal(
await times.created,
CREATED_TIME, "Should have seen the right profile time."
); Assert.equal(
await times.firstUse,
undefined, "Should be no first use time."
);
let times2 = await ProfileAge(profile); Assert.equal(times, times2, "Should have got the same instance.");
let promise = times.recordProfileReset(RESET_TIME); Assert.equal(
await times2.reset,
RESET_TIME, "Should have seen the right reset time in the second instance immediately."
);
await promise;
let recoveryPromise = times.recordRecoveredFromBackup(RECOVERY_TIME); Assert.equal(
await times2.recoveredFromBackup,
RECOVERY_TIME, "Should have seen the right backup recovery time in the second instance immediately."
);
await recoveryPromise;
let results = await IOUtils.readJSON(PathUtils.join(profile, "times.json")); Assert.deepEqual(
results,
{
created: CREATED_TIME,
reset: RESET_TIME,
recoveredFromBackup: RECOVERY_TIME,
}, "Should have seen the right results."
);
})
);
// The last call to recordProfileReset should always win.
let times = await ProfileAge(profile);
await Promise.all([
times.recordProfileReset(RESET_TIME),
times.recordProfileReset(RESET_TIME2),
]);
let results = await IOUtils.readJSON(PathUtils.join(profile, "times.json")); delete results.firstUse; Assert.deepEqual(
results,
{
reset: RESET_TIME2,
}, "Should have seen the right results."
);
})
);
// The last call to recordRecoveredFromBackup should always win.
let times = await ProfileAge(profile);
await Promise.all([
times.recordRecoveredFromBackup(RECOVERY_TIME),
times.recordRecoveredFromBackup(RECOVERY_TIME2),
]);
let results = await IOUtils.readJSON(PathUtils.join(profile, "times.json")); Assert.equal(
results.recoveredFromBackup,
RECOVERY_TIME2, "Should have seen the right results."
);
})
);
Messung V0.5
¤ Dauer der Verarbeitung: 0.10 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 und die Messung sind noch experimentell.