Backing out incorrectly landed patch from bug 611178. a=backout
authorDave Townsend <dtownsend@oxymoronical.com>
Tue, 08 Mar 2011 09:56:58 -0800
changeset 63356 53f4bee0bc1192c9a0d95fe72ba7f7675a28f47b
parent 63355 acdd32f121999b26e0554cfdef5f01c59ed4c269
child 63357 19021b7524f2cbacfa15b131a633ca96d0b04d2a
push idunknown
push userunknown
push dateunknown
reviewersbackout
bugs611178
milestone2.0b13pre
Backing out incorrectly landed patch from bug 611178. a=backout
toolkit/mozapps/extensions/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/test_install.js
--- a/toolkit/mozapps/extensions/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/XPIProvider.jsm
@@ -2265,17 +2265,17 @@ var XPIProvider = {
         else
           WARN("Could not uninstall invalid item from locked install location");
         return false;
       }
 
       // Update the AddonInternal properties.
       newAddon._installLocation = aInstallLocation;
       newAddon.visible = !(newAddon.id in visibleAddons);
-      newAddon.installDate = Date.now();
+      newAddon.installDate = aAddonState.mtime;
       newAddon.updateDate = aAddonState.mtime;
 
       // If there is migration data then apply it.
       if (aMigrateData) {
         // A theme's disabled state is determined by the selected theme
         // preference which is read in loadManifestFromRDF
         if (newAddon.type != "theme")
           newAddon.userDisabled = aMigrateData.userDisabled;
@@ -5890,17 +5890,17 @@ AddonInstall.prototype = {
         this.addon._installLocation = this.installLocation;
         this.addon.updateDate = recursiveLastModifiedTime(file);
         this.addon.visible = true;
         if (isUpgrade) {
           XPIDatabase.updateAddonMetadata(this.existingAddon, this.addon,
                                           file.persistentDescriptor);
         }
         else {
-          this.addon.installDate = Date.now();
+          this.addon.installDate = this.addon.updateDate;
           this.addon.active = (this.addon.visible && !this.addon.userDisabled &&
                                !this.addon.appDisabled)
           XPIDatabase.addAddonMetadata(this.addon, file.persistentDescriptor);
         }
 
         // Retrieve the new DBAddonInternal for the add-on we just added
         let self = this;
         XPIDatabase.getAddonInLocation(this.addon.id, this.installLocation.name,
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_install.js
@@ -3,21 +3,16 @@
  */
 
 // This verifies that add-ons can be installed from XPI files
 
 // The maximum allowable time since install. If an add-on claims to have been
 // installed longer ago than this the the test will fail.
 const MAX_INSTALL_TIME = 10000;
 
-// Maximum error in file modification times. Some file systems don't store
-// modification times exactly. As long as we are closer than this then it
-// still passes.
-const MAX_TIME_DIFFERENCE = 3000;
-
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/NetUtil.jsm");
 
 // install.rdf size, icon.png, icon64.png size
 const ADDON1_SIZE = 705 + 16 + 16;
 
 do_load_httpd_js();
 var testserver;
@@ -138,22 +133,16 @@ function check_test_1() {
           zipReader.close();
         }
       }
       else {
         let iconFile = uri.QueryInterface(AM_Ci.nsIFileURL).file;
         do_check_true(iconFile.exists());
       }
 
-      // Make the pending install appear to be in the future.
-      let updateDate = Date.now() + 1000 * 60 * 60 * 24 * 365;
-      let extURI = pendingAddons[0].getResourceURI("");
-      let ext = extURI.QueryInterface(AM_Ci.nsIFileURL).file;
-      setExtensionModifiedTime(ext, updateDate);
-
       // The pending add-on cannot be disabled or enabled.
       do_check_false(hasFlag(pendingAddons[0].permissions, AddonManager.PERM_CAN_ENABLE));
       do_check_false(hasFlag(pendingAddons[0].permissions, AddonManager.PERM_CAN_DISABLE));
 
       restartManager();
 
       AddonManager.getAllInstalls(function(activeInstalls) {
         do_check_eq(activeInstalls, 0);
@@ -170,21 +159,19 @@ function check_test_1() {
 
           do_check_eq(a1.sourceURI.spec,
                       Services.io.newFileURI(do_get_addon("test_install1")).spec);
           // Should have been installed sometime in the last two second.
           let difference = Date.now() - a1.installDate.getTime();
           if (difference > MAX_INSTALL_TIME)
             do_throw("Add-on was installed " + difference + "ms ago");
           if (difference < 0)
-            do_throw("Add-on was installed " + -difference + "ms in the future");
+            do_throw("Add-on was installed " + difference + "ms in the future");
 
-          difference = a1.updateDate.getTime - updateDate;
-          if (Math.abs(difference) > MAX_TIME_DIFFERENCE)
-            do_throw("Add-on update time was out by " + difference + "ms");
+          do_check_eq(a1.installDate.getTime(), a1.updateDate.getTime());
 
           do_check_true(a1.hasResource("install.rdf"));
           do_check_false(a1.hasResource("foo.bar"));
 
           let uri = do_get_addon_root_uri(profileDir, "addon1@tests.mozilla.org");
           do_check_eq(a1.getResourceURI("install.rdf").spec, uri + "install.rdf");
           do_check_eq(a1.iconURL, uri + "icon.png");
           do_check_eq(a1.icon64URL, uri + "icon64.png");
@@ -257,23 +244,17 @@ function run_test_3(install) {
     ]
   }, [
     "onInstallStarted",
     "onInstallEnded",
   ], check_test_3);
   install.install();
 }
 
-function check_test_3(aInstall) {
-  // Make the pending install appear to be in the future.
-  let updateDate = Date.now() + 1000 * 60 * 60 * 24 * 365 * 2;
-  let extURI = aInstall.addon.getResourceURI("");
-  let ext = extURI.QueryInterface(AM_Ci.nsIFileURL).file;
-  setExtensionModifiedTime(ext, updateDate);
-
+function check_test_3() {
   ensure_test_completed();
   AddonManager.getAddonByID("addon2@tests.mozilla.org", function(olda2) {
     do_check_eq(olda2, null);
     restartManager();
 
     AddonManager.getAllInstalls(function(installs) {
       do_check_eq(installs, 0);
 
@@ -290,20 +271,17 @@ function check_test_3(aInstall) {
 
         // Should have been installed sometime in the last two second.
         let difference = Date.now() - a2.installDate.getTime();
         if (difference > MAX_INSTALL_TIME)
           do_throw("Add-on was installed " + difference + "ms ago");
         if (difference < 0)
           do_throw("Add-on was installed " + difference + "ms in the future");
 
-        difference = a2.updateDate.getTime - updateDate;
-        if (Math.abs(difference) > MAX_TIME_DIFFERENCE)
-          do_throw("Add-on update time was out by " + difference + "ms");
-
+        do_check_eq(a2.installDate.getTime(), a2.updateDate.getTime());
         gInstallDate = a2.installDate.getTime();
 
         run_test_4();
       });
     });
   });
 }
 
@@ -389,16 +367,18 @@ function check_test_5(install) {
           do_check_true(a2.isActive);
           do_check_true(isExtensionInAddonsList(profileDir, a2.id));
           do_check_true(do_get_addon("test_install2_2").exists());
           do_check_in_crash_annotation(a2.id, a2.version);
           do_check_eq(a2.sourceURI.spec,
                       "http://localhost:4444/addons/test_install2_2.xpi");
 
           do_check_eq(a2.installDate.getTime(), gInstallDate);
+          // Update date should be later (or the same if this test is too fast)
+          do_check_true(a2.installDate <= a2.updateDate);
 
           a2.uninstall();
           restartManager();
 
           run_test_6();
         });
       });
     });