Bug 1330227 Tighten up mtime checking test_update.js
MozReview-Commit-ID: Lk88rlRawZm
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_update.js
@@ -227,32 +227,36 @@ for (let test of testParams) {
do_check_neq(olda1, null);
do_check_eq(olda1.version, "1.0");
do_check_true(isExtensionInAddonsList(profileDir, olda1.id));
shutdownManager();
await promiseStartupManager();
+ // Grab the current time so we can check the mtime of the add-on below
+ // without worrying too much about how long other tests take.
+ let startupTime = Date.now();
+
do_check_true(isExtensionInAddonsList(profileDir, "addon1@tests.mozilla.org"));
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
do_check_neq(a1, null);
do_check_eq(a1.version, "2.0");
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_eq(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE);
do_check_eq(a1.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml");
do_check_true(a1.foreignInstall);
do_check_neq(a1.syncGUID, null);
do_check_eq(originalSyncGUID, a1.syncGUID);
// Make sure that the extension lastModifiedTime was updated.
let testURI = a1.getResourceURI(TEST_UNPACKED ? "install.rdf" : "");
let testFile = testURI.QueryInterface(Components.interfaces.nsIFileURL).file;
- let difference = testFile.lastModifiedTime - Date.now();
+ let difference = testFile.lastModifiedTime - startupTime;
do_check_true(Math.abs(difference) < MAX_TIME_DIFFERENCE);
a1.uninstall();
run_next_test();
});
}));
};