Bug 1320736 - Part 1: Set installDate in installAddonFromLocation, r?aswan draft
authorBob Silverberg <bsilverberg@mozilla.com>
Thu, 26 Jan 2017 16:13:32 -0500
changeset 485066 5e5f397dffa5d1a410a1b4a8a1ede99c0f0b6768
parent 484998 e9b926463f9ea76b836ebecd824506e1febee19e
child 485067 baa165855bab8ede4f0dd95b674f1b3de15871ba
push id45617
push userbmo:bob.silverberg@gmail.com
push dateThu, 16 Feb 2017 02:18:58 +0000
reviewersaswan
bugs1320736
milestone54.0a1
Bug 1320736 - Part 1: Set installDate in installAddonFromLocation, r?aswan MozReview-Commit-ID: AB5GexbHYge
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -4060,16 +4060,18 @@ this.XPIProvider = {
                                           "shutdown", uninstallReason,
                                           { newVersion });
         }
         this.callBootstrapMethod(oldAddon, existingAddon,
                                  "uninstall", uninstallReason, { newVersion });
         this.unloadBootstrapScope(existingAddonID);
         flushChromeCaches();
       }
+    } else {
+      addon.installDate = Date.now();
     }
 
     let file = addon._sourceBundle;
 
     XPIProvider._addURIMapping(addon.id, file);
     XPIProvider.callBootstrapMethod(addon, file, "install", installReason);
     addon.state = AddonManager.STATE_INSTALLED;
     logger.debug("Install of temporary addon in " + aFile.path + " completed.");
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
@@ -74,18 +74,21 @@ add_task(function* test_unsigned_no_id_t
     name: "no ID",
     description: "extension without an ID",
     manifest_version: 2,
     version: "1.0"
   };
 
   const addonDir = yield promiseWriteWebManifestForExtension(manifest, gTmpD,
                                                 "the-addon-sub-dir");
+  const testDate = new Date();
   const addon = yield AddonManager.installTemporaryAddon(addonDir);
   ok(addon.id, "ID should have been auto-generated");
+  ok(Math.abs(addon.installDate - testDate) < 10000, "addon has an expected installDate");
+  ok(Math.abs(addon.updateDate - testDate) < 10000, "addon has an expected updateDate");
 
   // The sourceURI of a temporary installed addon should be equal to the
   // file url of the installed source dir.
   equal(addon.sourceURI && addon.sourceURI.spec,
         Services.io.newFileURI(addonDir).spec,
         "SourceURI of the add-on has the expected value");
 
   // Install the same directory again, as if re-installing or reloading.