Bug 562901: Add icon64URL to API. r=Unfocused, sr=robstrong, a=blocking-b6

This commit is contained in:
Dave Townsend 2010-09-01 11:10:03 -07:00
Родитель 5b56dec94c
Коммит cfc7951c95
5 изменённых файлов: 37 добавлений и 25 удалений

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

@ -106,12 +106,13 @@ const TOOLKIT_ID = "toolkit@mozilla.org";
const BRANCH_REGEXP = /^([^\.]+\.[0-9]+[a-z]*).*/gi;
const DB_SCHEMA = 2;
const DB_SCHEMA = 3;
const REQ_VERSION = 2;
// Properties that exist in the install manifest
const PROP_METADATA = ["id", "version", "type", "internalName", "updateURL",
"updateKey", "optionsURL", "aboutURL", "iconURL"]
"updateKey", "optionsURL", "aboutURL", "iconURL",
"icon64URL"]
const PROP_LOCALE_SINGLE = ["name", "description", "creator", "homepageURL"];
const PROP_LOCALE_MULTI = ["developers", "translators", "contributors"];
const PROP_TARGETAPP = ["id", "minVersion", "maxVersion"];
@ -2640,10 +2641,10 @@ var XPIProvider = {
const FIELDS_ADDON = "internal_id, id, location, version, type, internalName, " +
"updateURL, updateKey, optionsURL, aboutURL, iconURL, " +
"defaultLocale, visible, active, userDisabled, appDisabled, " +
"pendingUninstall, descriptor, installDate, updateDate, " +
"applyBackgroundUpdates, bootstrap, skinnable, size, " +
"sourceURI, releaseNotesURI";
"icon64URL, defaultLocale, visible, active, userDisabled, " +
"appDisabled, pendingUninstall, descriptor, installDate, " +
"updateDate, applyBackgroundUpdates, bootstrap, skinnable, " +
"size, sourceURI, releaseNotesURI";
/**
* A helper function to log an SQL error.
@ -2784,11 +2785,11 @@ var XPIDatabase = {
addAddonMetadata_addon: "INSERT INTO addon VALUES (NULL, :id, :location, " +
":version, :type, :internalName, :updateURL, " +
":updateKey, :optionsURL, :aboutURL, :iconURL, " +
":locale, :visible, :active, :userDisabled, " +
":appDisabled, :pendingUninstall, :descriptor, " +
":installDate, :updateDate, :applyBackgroundUpdates, " +
":bootstrap, :skinnable, :size, :sourceURI, " +
":releaseNotesURI)",
":icon64URL, :locale, :visible, :active, " +
":userDisabled, :appDisabled, :pendingUninstall, " +
":descriptor, :installDate, :updateDate, " +
":applyBackgroundUpdates, :bootstrap, :skinnable, " +
":size, :sourceURI, :releaseNotesURI)",
addAddonMetadata_addon_locale: "INSERT INTO addon_locale VALUES " +
"(:internal_id, :name, :locale)",
addAddonMetadata_locale: "INSERT INTO locale (name, description, creator, " +
@ -3112,7 +3113,8 @@ var XPIDatabase = {
"id TEXT, location TEXT, version TEXT, " +
"type TEXT, internalName TEXT, updateURL TEXT, " +
"updateKey TEXT, optionsURL TEXT, aboutURL TEXT, " +
"iconURL TEXT, defaultLocale INTEGER, " +
"iconURL TEXT, icon64URL TEXT, " +
"defaultLocale INTEGER, " +
"visible INTEGER, active INTEGER, " +
"userDisabled INTEGER, appDisabled INTEGER, " +
"pendingUninstall INTEGER, descriptor TEXT, " +
@ -5433,17 +5435,21 @@ function AddonWrapper(aAddon) {
});
}, this);
this.__defineGetter__("iconURL", function() {
if (aAddon.active && aAddon.iconURL)
return aAddon.iconURL;
// Maps iconURL and icon64URL to the properties of the same name or icon.png
// and icon64.png in the add-on's files.
["icon", "icon64"].forEach(function(aProp) {
this.__defineGetter__(aProp + "URL", function() {
if (aAddon.active && aAddon[aProp + "URL"])
return aAddon[aProp + "URL"];
if (this.hasResource("icon.png"))
return this.getResourceURI("icon.png").spec;
if (this.hasResource(aProp + ".png"))
return this.getResourceURI(aProp + ".png").spec;
if (aAddon._repositoryAddon)
return aAddon._repositoryAddon.iconURL;
if (aAddon._repositoryAddon)
return aAddon._repositoryAddon[aProp + "URL"];
return null;
return null;
}, this);
}, this);
PROP_LOCALE_SINGLE.forEach(function(aProp) {

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

@ -0,0 +1 @@
Fake icon image

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

@ -427,7 +427,8 @@ function writeInstallRDFToDir(aData, aDir) {
rdf += '<Description about="urn:mozilla:install-manifest">\n';
["id", "version", "type", "internalName", "updateURL", "updateKey",
"optionsURL", "aboutURL", "iconURL", "skinnable"].forEach(function(aProp) {
"optionsURL", "aboutURL", "iconURL", "icon64URL",
"skinnable"].forEach(function(aProp) {
if (aProp in aData)
rdf += "<em:" + aProp + ">" + escapeXML(aData[aProp]) + "</em:" + aProp + ">\n";
});

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

@ -11,8 +11,8 @@ const MAX_INSTALL_TIME = 10000;
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/NetUtil.jsm");
// install.rdf size, icon.png size
const ADDON1_SIZE = 705 + 16;
// install.rdf size, icon.png, icon64.png size
const ADDON1_SIZE = 705 + 16 + 16;
do_load_httpd_js();
var testserver;
@ -73,6 +73,7 @@ function run_test_1() {
let uri = Services.io.newFileURI(file).spec;
do_check_eq(install.addon.getResourceURI("install.rdf").spec, "jar:" + uri + "!/install.rdf");
do_check_eq(install.addon.iconURL, "jar:" + uri + "!/icon.png");
do_check_eq(install.addon.icon64URL, "jar:" + uri + "!/icon64.png");
do_check_eq(install.iconURL, null);
do_check_eq(install.sourceURI.spec, uri);
@ -147,9 +148,10 @@ function check_test_1() {
let dir = profileDir.clone();
dir.append("addon1@tests.mozilla.org");
dir.append("install.rdf");
let uri = Services.io.newFileURI(dir).spec;
do_check_eq(a1.getResourceURI("install.rdf").spec, uri);
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");
a1.uninstall();
restartManager();

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

@ -19,6 +19,7 @@ function run_test() {
optionsURL: "chrome://test/content/options.xul",
aboutURL: "chrome://test/content/about.xul",
iconURL: "chrome://test/skin/icon.png",
icon64URL: "chrome://test/skin/icon64.png",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
@ -280,6 +281,7 @@ function run_test() {
do_check_eq(a1.optionsURL, "chrome://test/content/options.xul");
do_check_eq(a1.aboutURL, "chrome://test/content/about.xul");
do_check_eq(a1.iconURL, "chrome://test/skin/icon.png");
do_check_eq(a1.icon64URL, "chrome://test/skin/icon64.png");
do_check_eq(a1.name, "Test Addon 1");
do_check_eq(a1.description, "Test Description");
do_check_eq(a1.creator, "Test Creator");