summaryrefslogtreecommitdiffstats
path: root/toolkit/modules/tests/xpcshell/test_ProfileAge.js
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/modules/tests/xpcshell/test_ProfileAge.js')
-rw-r--r--toolkit/modules/tests/xpcshell/test_ProfileAge.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/toolkit/modules/tests/xpcshell/test_ProfileAge.js b/toolkit/modules/tests/xpcshell/test_ProfileAge.js
index 9a659a5894..e717b0dcd0 100644
--- a/toolkit/modules/tests/xpcshell/test_ProfileAge.js
+++ b/toolkit/modules/tests/xpcshell/test_ProfileAge.js
@@ -38,6 +38,7 @@ add_task(
withDummyProfile(async profile => {
const CREATED_TIME = Date.now() - 2000;
const RESET_TIME = Date.now() - 1000;
+ const RECOVERY_TIME = Date.now() - 500;
await IOUtils.writeJSON(PathUtils.join(profile, "times.json"), {
created: CREATED_TIME,
@@ -66,12 +67,21 @@ add_task(
);
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."
);
@@ -118,3 +128,24 @@ add_task(
);
})
);
+
+add_task(
+ withDummyProfile(async profile => {
+ const RECOVERY_TIME = Date.now() - 1000;
+ const RECOVERY_TIME2 = Date.now() - 2000;
+
+ // 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."
+ );
+ })
+);