Bug 1330227 - Tighten up mtime checking test_update.js. r=rhelmer, a=test-only
authorAndrew Swan <aswan@mozilla.com>
Mon, 12 Jun 2017 14:27:01 -0700
changeset 413952 5158df62b3a98f530c7f8e27c70223aab8d0f90b
parent 413951 73fabbde6b19ab8ca8bf6fbce154880c4c22a72d
child 413953 02caa113457b2780c13bf0d7c26cb739558b5f5b
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhelmer, test-only
bugs1330227
milestone55.0
Bug 1330227 - Tighten up mtime checking test_update.js. r=rhelmer, a=test-only MozReview-Commit-ID: Lk88rlRawZm
toolkit/mozapps/extensions/test/xpcshell/test_update.js
--- 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();
       });
     }));
   };