Bug 565291: Last update date for Personas always shows 'Unknown'. r=robstrong

This commit is contained in:
Dave Townsend 2010-07-01 21:33:34 -07:00
Родитель ea7bb6d5f2
Коммит b9b4dc6532
3 изменённых файлов: 43 добавлений и 0 удалений

Просмотреть файл

@ -405,6 +405,12 @@ function AddonWrapper(aTheme, aBeingEnabled) {
});
}, this);
["installDate", "updateDate"].forEach(function(prop) {
this.__defineGetter__(prop, function() {
return prop in aTheme ? new Date(aTheme[prop]) : null;
});
}, this);
this.__defineGetter__("creator", function() aTheme.author);
this.__defineGetter__("screenshots", function() [aTheme.previewURL]);
@ -540,6 +546,12 @@ function _setCurrentTheme(aData, aLocal) {
let theme = LightweightThemeManager.getUsedTheme(aData.id);
let isInstall = !theme || theme.version != aData.version;
if (isInstall) {
aData.updateDate = Date.now();
if (theme && "installDate" in theme)
aData.installDate = theme.installDate;
else
aData.installDate = aData.updateDate;
var oldWrapper = theme ? new AddonWrapper(theme) : null;
var wrapper = new AddonWrapper(aData);
AddonManagerPrivate.callInstallListeners("onExternalInstall", null,

Просмотреть файл

@ -275,6 +275,12 @@ function run_test_3() {
do_check_eq(p1.scope, AddonManager.SCOPE_PROFILE);
do_check_true("isCompatibleWith" in p1);
do_check_true("findUpdates" in p1);
do_check_eq(p1.installDate.getTime(), p1.updateDate.getTime());
// 5 seconds leeway seems like a lot, but tests can run slow and really if
// this is within 5 seconds it is fine. If it is going to be wrong then it
// is likely to be hours out at least
do_check_true((Date.now() - p1.installDate.getTime()) < 5000);
AddonManager.getAddonsByTypes(["theme"], function(addons) {
let seen = false;
@ -338,6 +344,12 @@ function run_test_4() {
do_check_true(p2.isActive);
do_check_eq(p2.pendingOperations, 0);
do_check_eq(p2.permissions, AddonManager.PERM_CAN_UNINSTALL);
do_check_eq(p2.installDate.getTime(), p2.updateDate.getTime());
// 5 seconds leeway seems like a lot, but tests can run slow and really if
// this is within 5 seconds it is fine. If it is going to be wrong then it
// is likely to be hours out at least
do_check_true((Date.now() - p2.installDate.getTime()) < 5000);
do_check_neq(null, p1);
do_check_false(p1.appDisabled);

Просмотреть файл

@ -16,6 +16,8 @@ const PARAMS = "?%REQ_VERSION%/%ITEM_ID%/%ITEM_VERSION%/%ITEM_MAXAPPVERSION%/" +
"%ITEM_STATUS%/%APP_ID%/%APP_VERSION%/%CURRENT_APP_VERSION%/" +
"%APP_OS%/%APP_ABI%/%APP_LOCALE%/%UPDATE_TYPE%";
var gInstallDate;
do_load_httpd_js();
var testserver;
const profileDir = gProfD.clone();
@ -399,6 +401,14 @@ function run_test_7() {
do_check_eq(p1.version, "1");
do_check_eq(p1.name, "Test LW Theme");
do_check_true(p1.isActive);
do_check_eq(p1.installDate.getTime(), p1.updateDate.getTime());
// 5 seconds leeway seems like a lot, but tests can run slow and really if
// this is within 5 seconds it is fine. If it is going to be wrong then it
// is likely to be hours out at least
do_check_true((Date.now() - p1.installDate.getTime()) < 5000);
gInstallDate = p1.installDate.getTime();
prepare_test({
"1@personas.mozilla.org": [
@ -420,6 +430,15 @@ function check_test_7() {
do_check_neq(p1, null);
do_check_eq(p1.version, "2");
do_check_eq(p1.name, "Updated Theme");
do_check_eq(p1.installDate.getTime(), gInstallDate);
do_check_true(p1.installDate.getTime() < p1.updateDate.getTime());
// 5 seconds leeway seems like a lot, but tests can run slow and really if
// this is within 5 seconds it is fine. If it is going to be wrong then it
// is likely to be hours out at least
do_check_true((Date.now() - p1.updateDate.getTime()) < 5000);
gInstallDate = p1.installDate.getTime();
run_test_8();
});