add_task(async function test_timestamp_fixup() {
let now = Date.now() * 1000; // date in microseconds
Services.prefs.setBoolPref("network.cookie.fixup_on_db_load", true);
do_get_profile();
let dbFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
dbFile.append("cookies.sqlite");
let conn = Services.storage.openDatabase(dbFile);
initDB(conn, now);
if (AppConstants.platform != "android") {
Services.fog.initializeFOG();
}
Services.fog.testResetFOG();
// Now start the cookie service, and then check the fields in the table. // Get sessionCookies to wait for the initialization in cookie thread Assert.lessOrEqual(
Math.floor(Services.cookies.cookies[0].creationTime / 1000),
now
); Assert.ok(conn.schemaVersion >= 13);
Assert.equal(
await Glean.networking.cookieTimestampFixedCount.creationTime.testGetValue(),
1, "One fixup of creation time"
); Assert.equal(
await Glean.networking.cookieTimestampFixedCount.lastAccessed.testGetValue(),
1, "One fixup of lastAccessed"
);
{
let { values } =
await Glean.networking.cookieCreationFixupDiff.testGetValue();
info(JSON.stringify(values));
let keys = Object.keys(values).splice(-2, 2); Assert.equal(keys.length, 2, "There should be two entries in telemetry"); Assert.equal(values[keys[0]], 1, "First entry should have value 1"); Assert.equal(values[keys[1]], 0, "Second entry should have value 0"); const creationDiffInSeconds = CREATION_DIFF / USEC_PER_SEC; Assert.lessOrEqual(
parseInt(keys[0]),
creationDiffInSeconds, "The bucket should be smaller than time diff"
); Assert.lessOrEqual(
creationDiffInSeconds,
parseInt(keys[1]), "The next bucket should be larger than time diff"
);
}
{
let { values } =
await Glean.networking.cookieAccessFixupDiff.testGetValue();
info(JSON.stringify(values));
let keys = Object.keys(values).splice(-2, 2); Assert.equal(keys.length, 2, "There should be two entries in telemetry"); Assert.equal(values[keys[0]], 1, "First entry should have value 1"); Assert.equal(values[keys[1]], 0, "Second entry should have value 0");
info(now); const lastAccessedDiffInSeconds = LAST_ACCESSED_DIFF / USEC_PER_SEC; Assert.lessOrEqual(
parseInt(keys[0]),
lastAccessedDiffInSeconds, "The bucket should be smaller than time diff"
); Assert.lessOrEqual(
lastAccessedDiffInSeconds,
parseInt(keys[1]), "The next bucket should be larger than time diff"
);
}
conn.close();
});
Messung V0.5
¤ Dauer der Verarbeitung: 0.1 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.