mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
Bug 549969 - Add ability to save xml attributes from update xml that app update doesn't care about. r=dolske
This commit is contained in:
parent
aa12b16132
commit
77c25513a8
@ -113,7 +113,7 @@ interface nsIUpdatePatch : nsISupports
|
||||
* that the front end and other application services can use to learn more
|
||||
* about what is going on.
|
||||
*/
|
||||
[scriptable, uuid(31eced2b-8adb-46f9-992b-26858ab3d558)]
|
||||
[scriptable, uuid(2379e2e1-8eab-4084-8d8c-94ffeee56804)]
|
||||
interface nsIUpdate : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -189,17 +189,6 @@ interface nsIUpdate : nsISupports
|
||||
*/
|
||||
attribute AString channel;
|
||||
|
||||
/**
|
||||
* Stores custom string data provided by the update xml for use by the
|
||||
* application.
|
||||
*
|
||||
* Implementation Note: After an update has been successfully applied this
|
||||
* value will be added to the app.update.extra preference and if an
|
||||
* application uses this preference to determine that an update has been
|
||||
* applied it should also delete the preference.
|
||||
*/
|
||||
attribute AString extra1;
|
||||
|
||||
/**
|
||||
* Whether to show the update prompt which requires user confirmation when an
|
||||
* update is found during a background update check. This overrides the
|
||||
|
@ -53,13 +53,13 @@ const PREF_APP_UPDATE_AUTO = "app.update.auto";
|
||||
const PREF_APP_UPDATE_BACKGROUND_INTERVAL = "app.update.download.backgroundInterval";
|
||||
const PREF_APP_UPDATE_CHANNEL = "app.update.channel";
|
||||
const PREF_APP_UPDATE_ENABLED = "app.update.enabled";
|
||||
const PREF_APP_UPDATE_EXTRA1 = "app.update.extra1";
|
||||
const PREF_APP_UPDATE_IDLETIME = "app.update.idletime";
|
||||
const PREF_APP_UPDATE_INCOMPATIBLE_MODE = "app.update.incompatible.mode";
|
||||
const PREF_APP_UPDATE_INTERVAL = "app.update.interval";
|
||||
const PREF_APP_UPDATE_LOG = "app.update.log";
|
||||
const PREF_APP_UPDATE_MODE = "app.update.mode";
|
||||
const PREF_APP_UPDATE_NEVER_BRANCH = "app.update.never.";
|
||||
const PREF_APP_UPDATE_POSTUPDATE = "app.update.postupdate";
|
||||
const PREF_APP_UPDATE_PROMPTWAITTIME = "app.update.promptWaitTime";
|
||||
const PREF_APP_UPDATE_SHOW_INSTALLED_UI = "app.update.showInstalledUI";
|
||||
const PREF_APP_UPDATE_SILENT = "app.update.silent";
|
||||
@ -860,36 +860,57 @@ function Update(update) {
|
||||
attr.QueryInterface(Ci.nsIDOMAttr);
|
||||
if (attr.value == "undefined")
|
||||
continue;
|
||||
else if (attr.name == "installDate" && attr.value)
|
||||
this.installDate = parseInt(attr.value);
|
||||
else if (attr.name == "isCompleteUpdate")
|
||||
this.isCompleteUpdate = attr.value == "true";
|
||||
else if (attr.name == "isSecurityUpdate")
|
||||
this.isSecurityUpdate = attr.value == "true";
|
||||
else if (attr.name == "showPrompt")
|
||||
this.showPrompt = attr.value == "true";
|
||||
else if (attr.name == "showNeverForVersion")
|
||||
this.showNeverForVersion = attr.value == "true";
|
||||
else if (attr.name == "showSurvey")
|
||||
this.showSurvey = attr.value == "true";
|
||||
else if (attr.name == "detailsURL")
|
||||
this._detailsURL = attr.value;
|
||||
else if (attr.name == "channel")
|
||||
this.channel = attr.value;
|
||||
else if (attr.name == "extensionVersion") {
|
||||
// Prevent extensionVersion from replacing appVersion if appVersion is
|
||||
// present in the update xml.
|
||||
if (!this.appVersion)
|
||||
this.appVersion = attr.value;
|
||||
}
|
||||
else if (attr.name == "installDate" && attr.value)
|
||||
this.installDate = parseInt(attr.value);
|
||||
else if (attr.name == "isCompleteUpdate")
|
||||
this.isCompleteUpdate = attr.value == "true";
|
||||
else if (attr.name == "isSecurityUpdate")
|
||||
this.isSecurityUpdate = attr.value == "true";
|
||||
else if (attr.name == "showNeverForVersion")
|
||||
this.showNeverForVersion = attr.value == "true";
|
||||
else if (attr.name == "showPrompt")
|
||||
this.showPrompt = attr.value == "true";
|
||||
else if (attr.name == "showSurvey")
|
||||
this.showSurvey = attr.value == "true";
|
||||
else if (attr.name == "version") {
|
||||
// Prevent version from replacing displayVersion if displayVersion is
|
||||
// present in the update xml.
|
||||
if (!this.displayVersion)
|
||||
this.displayVersion = attr.value;
|
||||
}
|
||||
else
|
||||
else {
|
||||
this[attr.name] = attr.value;
|
||||
|
||||
switch (attr.name) {
|
||||
case "appVersion":
|
||||
case "billboardURL":
|
||||
case "buildID":
|
||||
case "channel":
|
||||
case "displayVersion":
|
||||
case "licenseURL":
|
||||
case "name":
|
||||
case "platformVersion":
|
||||
case "previousAppVersion":
|
||||
case "serviceURL":
|
||||
case "statusText":
|
||||
case "type":
|
||||
break;
|
||||
default:
|
||||
// Save custom attributes when serializing to the local xml file but
|
||||
// don't use this method for the expected attributes which are already
|
||||
// handled in serialize.
|
||||
this.setProperty(attr.name, attr.value);
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Set the initial value with the current time when it doesn't already have a
|
||||
@ -987,36 +1008,36 @@ Update.prototype = {
|
||||
*/
|
||||
serialize: function Update_serialize(updates) {
|
||||
var update = updates.createElementNS(URI_UPDATE_NS, "update");
|
||||
update.setAttribute("type", this.type);
|
||||
update.setAttribute("name", this.name);
|
||||
update.setAttribute("displayVersion", this.displayVersion);
|
||||
// for backwards compatibility in case the user downgrades
|
||||
update.setAttribute("version", this.displayVersion);
|
||||
update.setAttribute("appVersion", this.appVersion);
|
||||
update.setAttribute("buildID", this.buildID);
|
||||
update.setAttribute("channel", this.channel);
|
||||
update.setAttribute("displayVersion", this.displayVersion);
|
||||
// for backwards compatibility in case the user downgrades
|
||||
update.setAttribute("extensionVersion", this.appVersion);
|
||||
update.setAttribute("installDate", this.installDate);
|
||||
update.setAttribute("isCompleteUpdate", this.isCompleteUpdate);
|
||||
update.setAttribute("name", this.name);
|
||||
update.setAttribute("serviceURL", this.serviceURL);
|
||||
update.setAttribute("showNeverForVersion", this.showNeverForVersion);
|
||||
update.setAttribute("showPrompt", this.showPrompt);
|
||||
update.setAttribute("showSurvey", this.showSurvey);
|
||||
update.setAttribute("type", this.type);
|
||||
// for backwards compatibility in case the user downgrades
|
||||
|
||||
// Optional attributes
|
||||
update.setAttribute("version", this.displayVersion);
|
||||
if (this.billboardURL)
|
||||
update.setAttribute("billboardURL", this.billboardURL);
|
||||
if (this.detailsURL)
|
||||
update.setAttribute("detailsURL", this.detailsURL);
|
||||
if (this.licenseURL)
|
||||
update.setAttribute("licenseURL", this.licenseURL);
|
||||
if (this.platformVersion)
|
||||
update.setAttribute("platformVersion", this.platformVersion);
|
||||
if (this.previousAppVersion)
|
||||
update.setAttribute("previousAppVersion", this.previousAppVersion);
|
||||
if (this.detailsURL)
|
||||
update.setAttribute("detailsURL", this.detailsURL);
|
||||
if (this.billboardURL)
|
||||
update.setAttribute("billboardURL", this.billboardURL);
|
||||
if (this.licenseURL)
|
||||
update.setAttribute("licenseURL", this.licenseURL);
|
||||
update.setAttribute("serviceURL", this.serviceURL);
|
||||
update.setAttribute("installDate", this.installDate);
|
||||
if (this.statusText)
|
||||
update.setAttribute("statusText", this.statusText);
|
||||
update.setAttribute("isCompleteUpdate", this.isCompleteUpdate);
|
||||
update.setAttribute("channel", this.channel);
|
||||
update.setAttribute("showPrompt", this.showPrompt);
|
||||
update.setAttribute("showSurvey", this.showSurvey);
|
||||
update.setAttribute("showNeverForVersion", this.showNeverForVersion);
|
||||
if (this.extra1)
|
||||
update.setAttribute("extra1", this.extra1);
|
||||
updates.documentElement.appendChild(update);
|
||||
|
||||
for (var p in this._properties) {
|
||||
@ -1197,8 +1218,7 @@ UpdateService.prototype = {
|
||||
|
||||
// Update the patch's metadata.
|
||||
um.activeUpdate = update;
|
||||
gPref.setCharPref(PREF_APP_UPDATE_EXTRA1,
|
||||
update.extra1 ? update.extra1 : "undefined");
|
||||
gPref.setBoolPref(PREF_APP_UPDATE_POSTUPDATE, true);
|
||||
prompter.showUpdateInstalled();
|
||||
|
||||
// Done with this update. Clean it up.
|
||||
|
@ -190,12 +190,13 @@ function getRemoteUpdateString(aPatches, aType, aName, aDisplayVersion,
|
||||
aAppVersion, aPlatformVersion, aBuildID,
|
||||
aDetailsURL, aBillboardURL, aLicenseURL,
|
||||
aShowPrompt, aShowNeverForVersion, aShowSurvey,
|
||||
aExtra1, aVersion, aExtensionVersion) {
|
||||
aVersion, aExtensionVersion, aCustom1,
|
||||
aCustom2) {
|
||||
return getUpdateString(aType, aName, aDisplayVersion, aAppVersion,
|
||||
aPlatformVersion, aBuildID, aDetailsURL,
|
||||
aBillboardURL, aLicenseURL, aShowPrompt,
|
||||
aShowNeverForVersion, aShowSurvey, aExtra1, aVersion,
|
||||
aExtensionVersion) + ">\n" +
|
||||
aShowNeverForVersion, aShowSurvey, aVersion,
|
||||
aExtensionVersion, aCustom1, aCustom2) + ">\n" +
|
||||
aPatches +
|
||||
" </update>\n";
|
||||
}
|
||||
@ -255,8 +256,8 @@ function getLocalUpdateString(aPatches, aType, aName, aDisplayVersion,
|
||||
aServiceURL, aInstallDate, aStatusText,
|
||||
aIsCompleteUpdate, aChannel, aForegroundDownload,
|
||||
aShowPrompt, aShowNeverForVersion, aShowSurvey,
|
||||
aExtra1, aVersion, aExtensionVersion,
|
||||
aPreviousAppVersion) {
|
||||
aVersion, aExtensionVersion, aPreviousAppVersion,
|
||||
aCustom1, aCustom2) {
|
||||
var serviceURL = aServiceURL ? aServiceURL : "http://test_service/";
|
||||
var installDate = aInstallDate ? aInstallDate : "1238441400314";
|
||||
var statusText = aStatusText ? aStatusText : "Install Pending";
|
||||
@ -268,7 +269,8 @@ function getLocalUpdateString(aPatches, aType, aName, aDisplayVersion,
|
||||
return getUpdateString(aType, aName, aDisplayVersion, aAppVersion,
|
||||
aPlatformVersion, aBuildID, aDetailsURL, aBillboardURL,
|
||||
aLicenseURL, aShowPrompt, aShowNeverForVersion,
|
||||
aShowSurvey, aExtra1, aVersion, aExtensionVersion) +
|
||||
aShowSurvey, aVersion, aExtensionVersion, aCustom1,
|
||||
aCustom2) +
|
||||
" " +
|
||||
previousAppVersion +
|
||||
"serviceURL=\"" + serviceURL + "\" " +
|
||||
@ -343,22 +345,27 @@ function getLocalPatchString(aType, aURL, aHashFunction, aHashValue, aSize,
|
||||
* @param aShowSurvey
|
||||
* Whether to show the 'No Thanks' button in the update prompt.
|
||||
* If null will not be added and the backend will default to false.
|
||||
* @param aExtra1
|
||||
* A custom string provided by the update xml for use by the
|
||||
* application.
|
||||
* If null will not be added.
|
||||
* @param aVersion
|
||||
* The update's application version from 1.9.2.
|
||||
* If null will not be present.
|
||||
* @param aExtensionVersion
|
||||
* The update's application version from 1.9.2.
|
||||
* If null will not be present.
|
||||
* @param aCustom1
|
||||
* A custom attribute name AND attribute value to add to the xml.
|
||||
* Example: custom1_attribute="custom1 value"
|
||||
* If null will not be present.
|
||||
* @param aCustom2
|
||||
* A custom attribute name AND attribute value to add to the xml.
|
||||
* Example: custom2_attribute="custom2 value"
|
||||
* If null will not be present.
|
||||
* @returns The string representing an update element for an update xml file.
|
||||
*/
|
||||
function getUpdateString(aType, aName, aDisplayVersion, aAppVersion,
|
||||
aPlatformVersion, aBuildID, aDetailsURL, aBillboardURL,
|
||||
aLicenseURL, aShowPrompt, aShowNeverForVersion,
|
||||
aShowSurvey, aExtra1, aVersion, aExtensionVersion) {
|
||||
aShowSurvey, aVersion, aExtensionVersion, aCustom1,
|
||||
aCustom2) {
|
||||
var type = aType ? aType : "major";
|
||||
var name = aName ? aName : "App Update Test";
|
||||
var displayVersion = "";
|
||||
@ -390,7 +397,8 @@ function getUpdateString(aType, aName, aDisplayVersion, aAppVersion,
|
||||
var showPrompt = aShowPrompt ? "showPrompt=\"" + aShowPrompt + "\" " : "";
|
||||
var showNeverForVersion = aShowNeverForVersion ? "showNeverForVersion=\"" + aShowNeverForVersion + "\" " : "";
|
||||
var showSurvey = aShowSurvey ? "showSurvey=\"" + aShowSurvey + "\" " : "";
|
||||
var extra1 = aExtra1 ? "extra1=\"" + aExtra1 + "\" " : "";
|
||||
var custom1 = aCustom1 ? aCustom1 + " " : "";
|
||||
var custom2 = aCustom2 ? aCustom2 + " " : "";
|
||||
return " <update type=\"" + type + "\" " +
|
||||
"name=\"" + name + "\" " +
|
||||
displayVersion +
|
||||
@ -398,14 +406,15 @@ function getUpdateString(aType, aName, aDisplayVersion, aAppVersion,
|
||||
appVersion +
|
||||
extensionVersion +
|
||||
platformVersion +
|
||||
"buildID=\"" + buildID + "\" " +
|
||||
detailsURL +
|
||||
billboardURL +
|
||||
licenseURL +
|
||||
showPrompt +
|
||||
showNeverForVersion +
|
||||
showSurvey +
|
||||
extra1;
|
||||
custom1 +
|
||||
custom2 +
|
||||
"buildID=\"" + buildID + "\"";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,8 +115,9 @@ function run_test_pt02() {
|
||||
"http://details/",
|
||||
"http://billboard/",
|
||||
"http://license/", "true",
|
||||
"true", "true", "test extra1",
|
||||
"4.1a1pre", "5.1a1pre");
|
||||
"true", "true", "4.1a1pre", "5.1a1pre",
|
||||
"custom1_attr=\"custom1 value\"",
|
||||
"custom2_attr=\"custom2 value\"");
|
||||
gResponseBody = getRemoteUpdatesXMLString(updates);
|
||||
gUpdateChecker.checkForUpdates(updateCheckListener, true);
|
||||
}
|
||||
@ -138,7 +139,7 @@ function check_test_pt02() {
|
||||
// }
|
||||
|
||||
do_check_eq(gUpdateCount, 1);
|
||||
var bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
|
||||
var bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount).QueryInterface(AUS_Ci.nsIPropertyBag);
|
||||
do_check_eq(bestUpdate.type, "minor");
|
||||
do_check_eq(bestUpdate.name, "Minor Test");
|
||||
do_check_eq(bestUpdate.displayVersion, "version 2.1a1pre");
|
||||
@ -151,7 +152,6 @@ function check_test_pt02() {
|
||||
do_check_true(bestUpdate.showPrompt);
|
||||
do_check_true(bestUpdate.showNeverForVersion);
|
||||
do_check_true(bestUpdate.showSurvey);
|
||||
do_check_eq(bestUpdate.extra1, "test extra1");
|
||||
do_check_eq(bestUpdate.serviceURL, URL_HOST + "update.xml?force=1");
|
||||
do_check_eq(bestUpdate.channel, "test_channel");
|
||||
do_check_false(bestUpdate.isCompleteUpdate);
|
||||
@ -166,6 +166,9 @@ function check_test_pt02() {
|
||||
do_check_eq(bestUpdate.patchCount, 2);
|
||||
//XXX TODO - test nsIUpdate:serialize
|
||||
|
||||
do_check_eq(bestUpdate.getProperty("custom1_attr"), "custom1 value");
|
||||
do_check_eq(bestUpdate.getProperty("custom2_attr"), "custom2 value");
|
||||
|
||||
var patch = bestUpdate.getPatchAt(0);
|
||||
do_check_eq(patch.type, "complete");
|
||||
do_check_eq(patch.URL, "http://complete/");
|
||||
@ -208,9 +211,7 @@ function run_test_pt03() {
|
||||
null, null,
|
||||
"5.1a1pre", "20080811053724",
|
||||
"http://details/",
|
||||
null,
|
||||
null, null,
|
||||
null, null, null,
|
||||
null, null, null, null, null,
|
||||
"version 4.1a1pre", "4.1a1pre");
|
||||
gResponseBody = getRemoteUpdatesXMLString(updates);
|
||||
gUpdateChecker.checkForUpdates(updateCheckListener, true);
|
||||
@ -231,7 +232,6 @@ function check_test_pt03() {
|
||||
do_check_false(bestUpdate.showPrompt);
|
||||
do_check_false(bestUpdate.showNeverForVersion);
|
||||
do_check_false(bestUpdate.showSurvey);
|
||||
do_check_eq(bestUpdate.extra1, null);
|
||||
do_check_eq(bestUpdate.serviceURL, URL_HOST + "update.xml?force=1");
|
||||
do_check_eq(bestUpdate.channel, "test_channel");
|
||||
do_check_false(bestUpdate.isCompleteUpdate);
|
||||
|
@ -55,8 +55,10 @@ function run_test() {
|
||||
"http://billboard1/", "http://license1/",
|
||||
"http://service1/", "1238441300314",
|
||||
"test status text", "false", "test_channel",
|
||||
"true", "true", "true", "true", "test extra1",
|
||||
"test version", "3.0", "3.0");
|
||||
"true", "true", "true", "true",
|
||||
"test version", "3.0", "3.0",
|
||||
"custom1_attr=\"custom1 value\"",
|
||||
"custom2_attr=\"custom2 value\"");
|
||||
|
||||
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
|
||||
writeStatusFile(STATE_SUCCEEDED);
|
||||
@ -68,7 +70,9 @@ function run_test() {
|
||||
"http://service2/", null,
|
||||
getString("patchApplyFailure"), "true",
|
||||
"test_channel", "false", null, null, null,
|
||||
null, "version 3", "3.0", null);
|
||||
"version 3", "3.0", null,
|
||||
"custom3_attr=\"custom3 value\"",
|
||||
"custom4_attr=\"custom4 value\"");
|
||||
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), false);
|
||||
|
||||
standardInit();
|
||||
@ -76,7 +80,7 @@ function run_test() {
|
||||
do_check_eq(gUpdateManager.activeUpdate, null);
|
||||
do_check_eq(gUpdateManager.updateCount, 2);
|
||||
|
||||
update = gUpdateManager.getUpdateAt(0);
|
||||
update = gUpdateManager.getUpdateAt(0).QueryInterface(AUS_Ci.nsIPropertyBag);
|
||||
do_check_eq(update.state, STATE_SUCCEEDED);
|
||||
do_check_eq(update.type, "major");
|
||||
do_check_eq(update.name, "New");
|
||||
@ -96,8 +100,10 @@ function run_test() {
|
||||
do_check_true(update.showPrompt);
|
||||
do_check_true(update.showNeverForVersion);
|
||||
do_check_true(update.showSurvey);
|
||||
do_check_eq(update.extra1, "test extra1");
|
||||
do_check_eq(update.previousAppVersion, "3.0");
|
||||
// Custom attributes
|
||||
do_check_eq(update.getProperty("custom1_attr"), "custom1 value");
|
||||
do_check_eq(update.getProperty("custom2_attr"), "custom2 value");
|
||||
|
||||
patch = update.selectedPatch;
|
||||
do_check_eq(patch.type, "partial");
|
||||
@ -108,7 +114,7 @@ function run_test() {
|
||||
do_check_true(patch.selected);
|
||||
do_check_eq(patch.state, STATE_SUCCEEDED);
|
||||
|
||||
update = gUpdateManager.getUpdateAt(1);
|
||||
update = gUpdateManager.getUpdateAt(1).QueryInterface(AUS_Ci.nsIPropertyBag);
|
||||
do_check_eq(update.state, STATE_FAILED);
|
||||
do_check_eq(update.name, "Existing");
|
||||
do_check_eq(update.type, "major");
|
||||
@ -130,8 +136,10 @@ function run_test() {
|
||||
do_check_false(update.showPrompt);
|
||||
do_check_false(update.showNeverForVersion);
|
||||
do_check_false(update.showSurvey);
|
||||
do_check_eq(update.extra1, null);
|
||||
do_check_eq(update.previousAppVersion, null);
|
||||
// Custom attributes
|
||||
do_check_eq(update.getProperty("custom3_attr"), "custom3 value");
|
||||
do_check_eq(update.getProperty("custom4_attr"), "custom4 value");
|
||||
|
||||
patch = update.selectedPatch;
|
||||
do_check_eq(patch.type, "complete");
|
||||
@ -154,7 +162,7 @@ function run_test() {
|
||||
"http://license/", "http://service/",
|
||||
"1238441400314", "test status text", null,
|
||||
"test_channel", "true", "true", "true", "true",
|
||||
"test extra1", "version 4.0", "4.0", "3.0");
|
||||
"version 4.0", "4.0", "3.0");
|
||||
|
||||
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
|
||||
writeStatusFile(STATE_SUCCEEDED);
|
||||
@ -166,7 +174,7 @@ function run_test() {
|
||||
null, "http://service/", null,
|
||||
getString("patchApplyFailure"), null,
|
||||
"test_channel", "false", null, null, null,
|
||||
null, "version 3", null, null);
|
||||
"version 3", null, null);
|
||||
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), false);
|
||||
|
||||
reloadUpdateManagerData();
|
||||
|
Loading…
Reference in New Issue
Block a user