Bug 1320736 - Part 1: Set installDate in installAddonFromLocation, r?aswan
MozReview-Commit-ID: AB5GexbHYge
--- 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.