3. ui changes to support mochitest chrome tests - Bug 530872. r=dtownsend

This commit is contained in:
Robert Strong 2010-03-03 10:56:59 -08:00
Родитель 46f6d1360b
Коммит ecb493c765
4 изменённых файлов: 395 добавлений и 291 удалений

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

@ -5,18 +5,18 @@ wizard[description=""] .wizard-header-description {
display: none; display: none;
} }
link { /**
-moz-binding: url("chrome://mozapps/content/update/updates.xml#link"); * Stop animations when they aren't displayed (bug 341749).
-moz-user-focus: normal; */
cursor: pointer; #updates:not([currentpageid="checking"]) #checkingProgress,
} #updates:not([currentpageid="incompatibleCheck"]) #incompatibleCheckProgress,
#updates:not([currentpageid="downloading"]) #downloadThrobber,
link > label { #updates:not([currentpageid="downloading"]) #downloadProgress {
cursor: inherit; display: none;
} }
/** /**
* Remote Content * Remote content displayed in the billboard and license pages.
*/ */
remotecontent { remotecontent {
-moz-binding: url("chrome://mozapps/content/update/updates.xml#remotecontent"); -moz-binding: url("chrome://mozapps/content/update/updates.xml#remotecontent");

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

@ -73,6 +73,16 @@ var gConsole = null;
var gPref = null; var gPref = null;
var gLogEnabled = false; var gLogEnabled = false;
// Notes:
// 1. use the wizard's goTo method whenever possible to change the wizard
// page since it is simpler than most other methods and behaves nicely with
// mochitests.
// 2. using a page's onPageShow method to then change to a different page will
// of course call that page's onPageShow method which can make mochitests
// overly complicated and fragile so avoid doing this if at all possible.
// This is why a page's next attribute is set prior to the page being shown
// whenever possible.
/** /**
* Logs a string to the error console. * Logs a string to the error console.
* @param string * @param string
@ -127,6 +137,11 @@ var gUpdates = {
*/ */
update: null, update: null,
/**
* List of incompatible add-ons
*/
addons: [],
/** /**
* The updates.properties <stringbundle> element. * The updates.properties <stringbundle> element.
*/ */
@ -184,6 +199,9 @@ var gUpdates = {
* @param canAdvance * @param canAdvance
* true if the wizard can be advanced (e.g. the next / finish button * true if the wizard can be advanced (e.g. the next / finish button
* should be enabled), false otherwise. * should be enabled), false otherwise.
* @param showCancel
* true if the wizard's cancel button should be shown, false
* otherwise. If not specified this will default to false.
* *
* Note: * Note:
* Per Bug 324121 the wizard should not look like a wizard and to accomplish * Per Bug 324121 the wizard should not look like a wizard and to accomplish
@ -196,23 +214,33 @@ var gUpdates = {
* +--------------------------------------------------------------+ * +--------------------------------------------------------------+
*/ */
setButtons: function(extra1ButtonString, extra2ButtonString, setButtons: function(extra1ButtonString, extra2ButtonString,
nextFinishButtonString, canAdvance) { nextFinishButtonString, canAdvance, showCancel) {
this.wiz.canAdvance = canAdvance; this.wiz.canAdvance = canAdvance;
var bnf = this.wiz.getButton((this.wiz.onLastPage ? "finish" : "next")); var bnf = this.wiz.getButton(this.wiz.onLastPage ? "finish" : "next");
var be1 = this.wiz.getButton("extra1"); var be1 = this.wiz.getButton("extra1");
var be2 = this.wiz.getButton("extra2"); var be2 = this.wiz.getButton("extra2");
var bc = this.wiz.getButton("cancel");
// Set the labels for the next / finish, extra1, and extra2 buttons // Set the labels for the next / finish, extra1, and extra2 buttons
this._setButton(bnf, nextFinishButtonString); this._setButton(bnf, nextFinishButtonString);
this._setButton(be1, extra1ButtonString); this._setButton(be1, extra1ButtonString);
this._setButton(be2, extra2ButtonString); this._setButton(be2, extra2ButtonString);
bnf.hidden = !nextFinishButtonString; bnf.hidden = bnf.disabled = !nextFinishButtonString;
be1.hidden = !extra1ButtonString; be1.hidden = be1.disabled = !extra1ButtonString;
be2.hidden = !extra2ButtonString; be2.hidden = be2.disabled = !extra2ButtonString;
// Hide the back button each time setButtons is called (see bug 464765) bc.hidden = bc.disabled = !showCancel;
this.wiz.getButton("back").hidden = true;
// Hide and disable the back button each time setButtons is called
// (see bug 464765).
var btn = this.wiz.getButton("back");
btn.hidden = btn.disabled = true;
// Hide and disable the finish button if not on the last page or the next
// button if on the last page each time setButtons is called.
btn = this.wiz.getButton(this.wiz.onLastPage ? "next" : "finish");
btn.hidden = btn.disabled = true;
}, },
getAUSString: function(key, strings) { getAUSString: function(key, strings) {
@ -225,7 +253,7 @@ var gUpdates = {
// If the user clicks "No Thanks", we should not prompt them to update to // If the user clicks "No Thanks", we should not prompt them to update to
// this version again unless they manually select "Check for Updates..." // this version again unless they manually select "Check for Updates..."
// which will clear all of the "never" prefs. // which will clear all of the "never" prefs.
var neverPrefName = PREF_APP_UPDATE_NEVER_BRANCH + gUpdates.update.appVersion; var neverPrefName = PREF_APP_UPDATE_NEVER_BRANCH + this.update.appVersion;
gPref.setBoolPref(neverPrefName, true); gPref.setBoolPref(neverPrefName, true);
this.wiz.cancel(); this.wiz.cancel();
}, },
@ -316,7 +344,7 @@ var gUpdates = {
var brandStrings = document.getElementById("brandStrings"); var brandStrings = document.getElementById("brandStrings");
this.brandName = brandStrings.getString("brandShortName"); this.brandName = brandStrings.getString("brandShortName");
var pages = gUpdates.wiz.childNodes; var pages = this.wiz.childNodes;
for (var i = 0; i < pages.length; ++i) { for (var i = 0; i < pages.length; ++i) {
var page = pages[i]; var page = pages[i];
if (page.localName == "wizardpage") if (page.localName == "wizardpage")
@ -329,12 +357,10 @@ var gUpdates = {
this._cacheButtonStrings("extra1"); this._cacheButtonStrings("extra1");
this._cacheButtonStrings("extra2"); this._cacheButtonStrings("extra2");
this.wiz.getButton("cancel").hidden = true;
// Advance to the Start page. // Advance to the Start page.
var startPage = this.startPage; var startPage = this.startPage;
LOG("gUpdates", "onLoad - setting current page to startpage " + startPage.id); LOG("gUpdates", "onLoad - setting current page to startpage " + startPage.id);
gUpdates.wiz.currentPage = startPage; this.wiz.currentPage = startPage;
}, },
/** /**
@ -342,7 +368,7 @@ var gUpdates = {
*/ */
onUnload: function() { onUnload: function() {
if (this._runUnload) { if (this._runUnload) {
var cp = gUpdates.wiz.currentPage; var cp = this.wiz.currentPage;
if (cp.pageid != "finished" && cp.pageid != "finishedBackground") if (cp.pageid != "finished" && cp.pageid != "finishedBackground")
this.onWizardCancel(); this.onWizardCancel();
} }
@ -354,13 +380,19 @@ var gUpdates = {
* This is determined by how we were called by the update prompt: * This is determined by how we were called by the update prompt:
* *
* Prompt Method: Arg0: Update State: Src Event: Failed: Result: * Prompt Method: Arg0: Update State: Src Event: Failed: Result:
* showUpdateAvailable nsIUpdate obj -- background -- incompatibleCheck * showUpdateAvailable nsIUpdate obj -- background -- see Note below
* showUpdateDownloaded nsIUpdate obj pending background -- finishedBackground * showUpdateDownloaded nsIUpdate obj pending background -- finishedBackground
* showUpdateInstalled "installed" -- -- -- installed * showUpdateInstalled "installed" -- -- -- installed
* showUpdateError nsIUpdate obj failed either partial errorpatching * showUpdateError nsIUpdate obj failed either partial errorpatching
* showUpdateError nsIUpdate obj failed either complete errors * showUpdateError nsIUpdate obj failed either complete errors
* checkForUpdates null -- foreground -- checking * checkForUpdates null -- foreground -- checking
* checkForUpdates null downloading foreground -- downloading * checkForUpdates null downloading foreground -- downloading
*
* Note: the page returned (e.g. Result) for showUpdateAvaulable is as follows:
* New enabled incompatible add-ons : incompatibleCheck page
* No new enabled incompatible add-ons: either updatesfoundbasic or
* updatesfoundbillboard as determined by
* updatesFoundPageId
*/ */
get startPage() { get startPage() {
if ("arguments" in window && window.arguments[0]) { if ("arguments" in window && window.arguments[0]) {
@ -379,18 +411,20 @@ var gUpdates = {
} }
catch (e) { catch (e) {
} }
if (patchFailed == "partial") { if (patchFailed) {
// If the system failed to apply the partial patch, show the if (patchFailed == "partial" && this.update.patchCount == 2) {
// screen which best describes this condition, which is triggered // If the system failed to apply the partial patch, show the
// by the |STATE_FAILED| state. // screen which best describes this condition, which is triggered
state = STATE_FAILED; // by the |STATE_FAILED| state.
} state = STATE_FAILED;
else if (patchFailed == "complete") { }
// Otherwise, if the complete patch failed, which is far less else {
// likely, show the error text held by the update object in the // Otherwise, if the complete patch failed, which is far less
// generic errors page, triggered by the |STATE_DOWNLOAD_FAILED| // likely, show the error text held by the update object in the
// state. // generic errors page, triggered by the |STATE_DOWNLOAD_FAILED|
state = STATE_DOWNLOAD_FAILED; // state.
state = STATE_DOWNLOAD_FAILED;
}
} }
// Now select the best page to start with, given the current state of // Now select the best page to start with, given the current state of
@ -409,7 +443,14 @@ var gUpdates = {
return document.getElementById("errors"); return document.getElementById("errors");
} }
} }
return document.getElementById("incompatibleCheck"); if (this.update.licenseURL)
this.wiz.getPageById(this.updatesFoundPageId).setAttribute("next", "license");
if (this.shouldCheckAddonCompatibility) {
var incompatCheckPage = document.getElementById("incompatibleCheck");
incompatCheckPage.setAttribute("next", this.updatesFoundPageId);
return incompatCheckPage;
}
return document.getElementById(this.updatesFoundPageId);
} }
else if (arg0 == "installed") { else if (arg0 == "installed") {
return document.getElementById("installed"); return document.getElementById("installed");
@ -426,6 +467,51 @@ var gUpdates = {
return document.getElementById("checking"); return document.getElementById("checking");
}, },
get shouldCheckAddonCompatibility() {
// this early return should never happen
if (!this.update)
return false;
delete this.shouldCheckAddonCompatibility;
var ai = CoC["@mozilla.org/xre/app-info;1"].getService(CoI.nsIXULAppInfo);
var vc = CoC["@mozilla.org/xpcom/version-comparator;1"].
getService(CoI.nsIVersionComparator);
if (!this.update.appVersion ||
vc.compare(this.update.appVersion, ai.version) == 0)
return this.shouldCheckAddonCompatibility = false;
var em = CoC["@mozilla.org/extensions/manager;1"].
getService(CoI.nsIExtensionManager);
this.addons = em.getIncompatibleItemList(this.update.appVersion,
this.update.platformVersion,
CoI.nsIUpdateItem.TYPE_ANY, false);
if (this.addons.length > 0) {
// Don't include add-ons that are already incompatible with the current
// version of the application
var addons = em.getIncompatibleItemList(null, null,
CoI.nsIUpdateItem.TYPE_ANY, false);
for (var i = 0; i < addons.length; ++i) {
for (var j = 0; j < this.addons.length; ++j) {
if (addons[i].id == this.addons[j].id) {
this.addons.splice(j, 1);
break;
}
}
}
}
return this.shouldCheckAddonCompatibility = (this.addons.length != 0);
},
/**
* Returns the string page ID for the appropriate updates found page based
* on the update's metadata.
*/
get updatesFoundPageId() {
delete this.updatesFoundPageId;
return this.updatesFoundPageId = this.update.billboardURL ? "updatesfoundbillboard"
: "updatesfoundbasic";
},
/** /**
* Sets the Update object for this wizard * Sets the Update object for this wizard
* @param update * @param update
@ -453,9 +539,8 @@ var gCheckingPage = {
* Initialize * Initialize
*/ */
onPageShow: function() { onPageShow: function() {
document.getElementById("checkingProgress").hidden = false; gUpdates.setButtons(null, null, null, false, true);
gUpdates.wiz.getButton("cancel").hidden = false; gUpdates.wiz.getButton("cancel").focus();
gUpdates.setButtons(null, null, null, false);
this._checker = CoC["@mozilla.org/updates/update-checker;1"]. this._checker = CoC["@mozilla.org/updates/update-checker;1"].
createInstance(CoI.nsIUpdateChecker); createInstance(CoI.nsIUpdateChecker);
this._checker.checkForUpdates(this.updateListener, true); this._checker.checkForUpdates(this.updateListener, true);
@ -487,20 +572,35 @@ var gCheckingPage = {
* See nsIUpdateCheckListener * See nsIUpdateCheckListener
*/ */
onCheckComplete: function(request, updates, updateCount) { onCheckComplete: function(request, updates, updateCount) {
document.getElementById("checkingProgress").hidden = true;
gUpdates.wiz.getButton("cancel").hidden = true;
var aus = CoC["@mozilla.org/updates/update-service;1"]. var aus = CoC["@mozilla.org/updates/update-service;1"].
getService(CoI.nsIApplicationUpdateService); getService(CoI.nsIApplicationUpdateService);
gUpdates.setUpdate(aus.selectUpdate(updates, updates.length)); gUpdates.setUpdate(aus.selectUpdate(updates, updates.length));
if (gUpdates.update) { if (gUpdates.update) {
LOG("gCheckingPage", "onCheckComplete - update found"); LOG("gCheckingPage", "onCheckComplete - update found");
gUpdates.wiz.currentPage.setAttribute("next", "incompatibleCheck"); if (!aus.canApplyUpdates) {
} gUpdates.wiz.goTo("manualUpdate");
else return;
LOG("gCheckingPage", "onCheckComplete - no update found"); }
gUpdates.wiz.canAdvance = true; if (gUpdates.update.licenseURL) {
gUpdates.wiz.advance(); // gUpdates.updatesFoundPageId returns the pageid and not the
// element's id so use the wizard's getPageById method.
gUpdates.wiz.getPageById(gUpdates.updatesFoundPageId).setAttribute("next", "license");
}
if (gUpdates.shouldCheckAddonCompatibility) {
var incompatCheckPage = document.getElementById("incompatibleCheck");
incompatCheckPage.setAttribute("next", gUpdates.updatesFoundPageId);
gUpdates.wiz.goTo("incompatibleCheck");
}
else {
gUpdates.wiz.goTo(gUpdates.updatesFoundPageId);
}
return;
}
LOG("gCheckingPage", "onCheckComplete - no update found");
gUpdates.wiz.goTo("noupdatesfound");
}, },
/** /**
@ -508,10 +608,8 @@ var gCheckingPage = {
*/ */
onError: function(request, update) { onError: function(request, update) {
LOG("gCheckingPage", "onError - proceeding to error page"); LOG("gCheckingPage", "onError - proceeding to error page");
document.getElementById("checkingProgress").hidden = true;
gUpdates.wiz.getButton("cancel").hidden = true;
gUpdates.setUpdate(update); gUpdates.setUpdate(update);
gUpdates.wiz.currentPage = document.getElementById("errors"); gUpdates.wiz.goTo("errors");
}, },
/** /**
@ -608,11 +706,6 @@ var gNoUpdatesPage = {
* The page that checks if there are any incompatible add-ons. * The page that checks if there are any incompatible add-ons.
*/ */
var gIncompatibleCheckPage = { var gIncompatibleCheckPage = {
/**
* List of incompatible add-ons
*/
addons: [],
/** /**
* Count of incompatible add-ons to check for updates * Count of incompatible add-ons to check for updates
*/ */
@ -632,64 +725,17 @@ var gIncompatibleCheckPage = {
* Initialize * Initialize
*/ */
onPageShow: function() { onPageShow: function() {
var aus = CoC["@mozilla.org/updates/update-service;1"].
getService(CoI.nsIApplicationUpdateService);
// Display the manual update page if the user is unable to apply the update
if (!aus.canApplyUpdates) {
gUpdates.wiz.currentPage.setAttribute("next", "manualUpdate");
gUpdates.wiz.advance();
return;
}
var ai = CoC["@mozilla.org/xre/app-info;1"].getService(CoI.nsIXULAppInfo);
var vc = CoC["@mozilla.org/xpcom/version-comparator;1"].
getService(CoI.nsIVersionComparator);
if (!gUpdates.update.appVersion ||
vc.compare(gUpdates.update.appVersion, ai.version) == 0) {
// Go to the next page
gUpdates.wiz.advance();
return;
}
var em = CoC["@mozilla.org/extensions/manager;1"].
getService(CoI.nsIExtensionManager);
this.addons = em.getIncompatibleItemList(gUpdates.update.appVersion,
gUpdates.update.platformVersion,
CoI.nsIUpdateItem.TYPE_ANY, false);
if (this.addons.length > 0) {
// Don't include add-ons that are already incompatible with the current
// version of the application
var addons = em.getIncompatibleItemList(null, null,
CoI.nsIUpdateItem.TYPE_ANY, false);
for (var i = 0; i < addons.length; ++i) {
for (var j = 0; j < this.addons.length; ++j) {
if (addons[i].id == this.addons[j].id) {
this.addons.splice(j, 1);
break;
}
}
}
}
if (this.addons.length == 0) {
// Go to the next page
gUpdates.wiz.advance();
return;
}
LOG("gIncompatibleCheckPage", "onPageShow - checking for updates to " + LOG("gIncompatibleCheckPage", "onPageShow - checking for updates to " +
"incompatible add-ons"); "incompatible add-ons");
gUpdates.wiz.getButton("cancel").hidden = false; gUpdates.setButtons(null, null, null, false, true);
gUpdates.setButtons(null, null, null, false);
gUpdates.wiz.getButton("cancel").focus(); gUpdates.wiz.getButton("cancel").focus();
this._pBar = document.getElementById("incompatibleCheckProgress"); this._pBar = document.getElementById("incompatibleCheckProgress");
this._pBar.hidden = false; this._totalCount = gUpdates.addons.length;
this._totalCount = this.addons.length;
var em = CoC["@mozilla.org/extensions/manager;1"]. var em = CoC["@mozilla.org/extensions/manager;1"].
getService(CoI.nsIExtensionManager); getService(CoI.nsIExtensionManager);
em.update(this.addons, this.addons.length, em.update(gUpdates.addons, gUpdates.addons.length,
CoI.nsIExtensionManager.UPDATE_NOTIFY_NEWVERSION, this, CoI.nsIExtensionManager.UPDATE_NOTIFY_NEWVERSION, this,
CoI.nsIExtensionManager.UPDATE_WHEN_NEW_APP_DETECTED, CoI.nsIExtensionManager.UPDATE_WHEN_NEW_APP_DETECTED,
gUpdates.update.appVersion, gUpdates.update.platformVersion); gUpdates.update.appVersion, gUpdates.update.platformVersion);
@ -706,19 +752,23 @@ var gIncompatibleCheckPage = {
* See nsIExtensionManager.idl * See nsIExtensionManager.idl
*/ */
onUpdateEnded: function() { onUpdateEnded: function() {
if (this.addons.length == 0) { if (gUpdates.addons.length == 0) {
LOG("gIncompatibleCheckPage", "onUpdateEnded - updates were found " + LOG("gIncompatibleCheckPage", "onUpdateEnded - updates were found " +
"for all incompatible add-ons"); "for all incompatible add-ons");
} }
else { else {
LOG("gIncompatibleCheckPage", "onUpdateEnded - there are still " + LOG("gIncompatibleCheckPage", "onUpdateEnded - there are still " +
"incompatible add-ons"); "incompatible add-ons");
if (gUpdates.update.licenseURL) {
document.getElementById("license").setAttribute("next", "incompatibleList");
}
else {
// gUpdates.updatesFoundPageId returns the pageid and not the element's
// id so use the wizard's getPageById method.
gUpdates.wiz.getPageById(gUpdates.updatesFoundPageId).setAttribute("next", "incompatibleList");
}
} }
gUpdates.wiz.goTo(gUpdates.updatesFoundPageId);
this._pBar.hidden = true;
gUpdates.wiz.getButton("cancel").hidden = true;
gUpdates.wiz.canAdvance = true;
gUpdates.wiz.advance();
}, },
/** /**
@ -738,11 +788,11 @@ var gIncompatibleCheckPage = {
status != CoI.nsIAddonUpdateCheckListener.STATUS_VERSIONINFO) status != CoI.nsIAddonUpdateCheckListener.STATUS_VERSIONINFO)
return; return;
for (var i = 0; i < this.addons.length; ++i) { for (var i = 0; i < gUpdates.addons.length; ++i) {
if (this.addons[i].id == addon.id) { if (gUpdates.addons[i].id == addon.id) {
LOG("gIncompatibleCheckPage", "onAddonUpdateEnded - found update " + LOG("gIncompatibleCheckPage", "onAddonUpdateEnded - found update " +
"for add-on ID: " + addon.id); "for add-on ID: " + addon.id);
this.addons.splice(i, 1); gUpdates.addons.splice(i, 1);
break; break;
} }
} }
@ -782,34 +832,20 @@ var gManualUpdatePage = {
* The "Updates Are Available" page. Provides the user information about the * The "Updates Are Available" page. Provides the user information about the
* available update. * available update.
*/ */
var gUpdatesAvailablePage = { var gUpdatesFoundBasicPage = {
/**
* If this page has been previously loaded
*/
_loaded: false,
/** /**
* Initialize * Initialize
*/ */
onPageShow: function() { onPageShow: function() {
gUpdates.wiz.canRewind = false;
var update = gUpdates.update; var update = gUpdates.update;
gUpdates.setButtons("askLaterButton", gUpdates.setButtons("askLaterButton",
update.showNeverForVersion ? "noThanksButton" : null, update.showNeverForVersion ? "noThanksButton" : null,
"updateButton_" + update.type, true); "updateButton_" + update.type, true);
var btn = gUpdates.wiz.getButton("next"); var btn = gUpdates.wiz.getButton("next");
btn.className += " heed"; btn.classList.add("heed");
btn.focus(); btn.focus();
if (this._loaded)
return;
if (!update.licenseURL) {
if (gIncompatibleCheckPage.addons.length == 0)
gUpdates.wiz.currentPage.setAttribute("next", "downloading");
else
gUpdates.wiz.currentPage.setAttribute("next", "incompatibleList");
}
var updateName = update.name; var updateName = update.name;
if (update.channel == "nightly") { if (update.channel == "nightly") {
updateName = gUpdates.getAUSString("updateName", [gUpdates.brandName, updateName = gUpdates.getAUSString("updateName", [gUpdates.brandName,
@ -818,49 +854,17 @@ var gUpdatesAvailablePage = {
} }
var updateNameElement = document.getElementById("updateName"); var updateNameElement = document.getElementById("updateName");
updateNameElement.value = updateName; updateNameElement.value = updateName;
var updateTypeElement = document.getElementById("updateType");
updateTypeElement.setAttribute("severity", update.type);
var moreInfoContent = document.getElementById("moreInfoContent"); var introText = gUpdates.getAUSString("intro_minor_app", [gUpdates.brandName]);
var intro; var introElem = document.getElementById("updatesFoundInto");
if (update.billboardURL) { introElem.setAttribute("severity", update.type);
// for major updates, use the brandName and the version for the intro introElem.textContent = introText;
intro = gUpdates.getAUSString("intro_major_app_and_version",
[gUpdates.brandName, update.displayVersion]);
var remoteContent = document.getElementById("updateMoreInfoContent");
// update_name and update_version need to be set before url
// so that when attempting to download the url, we can show
// the formatted "Download..." string
remoteContent.update_name = gUpdates.brandName;
remoteContent.update_version = update.displayVersion;
remoteContent.url = update.billboardURL;
moreInfoContent.hidden = false; var updateMoreInfoURL = document.getElementById("updateMoreInfoURL");
document.getElementById("moreInfoURL").hidden = true; if (update.detailsURL)
document.getElementById("updateName").hidden = true; updateMoreInfoURL.setAttribute("url", update.detailsURL);
document.getElementById("updateNameSep").hidden = true; else
document.getElementById("upgradeEvangelism").hidden = true; updateMoreInfoURL.hidden = true;
document.getElementById("upgradeEvangelismSep").hidden = true;
// Clear all of the "never" prefs to handle the scenario where the user
// clicked "never" for an update, selected "Check for Updates...", and
// then canceled. If we don't clear the "never" prefs future
// notifications will never happen.
gPref.deleteBranch(PREF_APP_UPDATE_NEVER_BRANCH);
}
else {
// for minor updates, just use the brandName for the intro
intro = gUpdates.getAUSString("intro_minor_app", [gUpdates.brandName]);
// This element when hidden still receives focus events which will
// cause assertions with debug builds so remove it when it isn't used.
moreInfoContent.parentNode.removeChild(moreInfoContent);
var updateMoreInfoURL = document.getElementById("updateMoreInfoURL");
if (update.detailsURL)
updateMoreInfoURL.setAttribute("url", update.detailsURL);
else
updateMoreInfoURL.hidden = true;
}
updateTypeElement.textContent = intro;
var updateTitle = gUpdates.getAUSString("updatesfound_" + update.type + var updateTitle = gUpdates.getAUSString("updatesfound_" + update.type +
".title"); ".title");
@ -869,7 +873,79 @@ var gUpdatesAvailablePage = {
// wizard page show up // wizard page show up
gUpdates.wiz._adjustWizardHeader(); gUpdates.wiz._adjustWizardHeader();
this._loaded = true; // Clear all of the "never" prefs to handle the scenario where the user
// clicked "never" for an update, selected "Check for Updates...", and
// then canceled. If we don't clear the "never" prefs future
// notifications will never happen.
gPref.deleteBranch(PREF_APP_UPDATE_NEVER_BRANCH);
},
onExtra1: function() {
gUpdates.later();
},
onExtra2: function() {
gUpdates.never();
},
onWizardNext: function() {
gUpdates.wiz.getButton("next").classList.remove("heed");
}
};
/**
* The "Updates Are Available" page with a billboard. Provides the user
* information about the available update.
*/
var gUpdatesFoundBillboardPage = {
/**
* If this page has been previously loaded
*/
_billboardLoaded: false,
/**
* Initialize
*/
onPageShow: function() {
var update = gUpdates.update;
var updateTitle = gUpdates.getAUSString("updatesfound_" + update.type +
".title");
gUpdates.wiz.currentPage.setAttribute("label", updateTitle);
// this is necessary to make this change to the label of the current
// wizard page show up
gUpdates.wiz._adjustWizardHeader();
gUpdates.setButtons("askLaterButton",
update.showNeverForVersion ? "noThanksButton" : null,
"updateButton_" + update.type, true);
var btn = gUpdates.wiz.getButton("next");
btn.classList.add("heed");
btn.focus();
if (this._billboardLoaded)
return;
var remoteContent = document.getElementById("updateMoreInfoContent");
// update_name and update_version need to be set before url
// so that when attempting to download the url, we can show
// the formatted "Download..." string
remoteContent.update_name = gUpdates.brandName;
remoteContent.update_version = update.displayVersion;
remoteContent.url = update.billboardURL;
var introText = gUpdates.getAUSString("intro_major_app_and_version",
[gUpdates.brandName, update.displayVersion]);
var introElem = document.getElementById("updatesFoundBillboardIntro");
introElem.setAttribute("severity", update.type);
introElem.textContent = introText;
// Clear all of the "never" prefs to handle the scenario where the user
// clicked "never" for an update, selected "Check for Updates...", and
// then canceled. If we don't clear the "never" prefs future
// notifications will never happen.
gPref.deleteBranch(PREF_APP_UPDATE_NEVER_BRANCH);
this._billboardLoaded = true;
}, },
onExtra1: function() { onExtra1: function() {
@ -883,9 +959,7 @@ var gUpdatesAvailablePage = {
}, },
onWizardNext: function() { onWizardNext: function() {
var regex = new RegExp('\\s*heed'); gUpdates.wiz.getButton("next").classList.remove("heed");
var btn = gUpdates.wiz.getButton("next");
btn.className = btn.className.replace(regex, "");
}, },
/** /**
@ -898,7 +972,7 @@ var gUpdatesAvailablePage = {
remoteContent.stopDownloading(); remoteContent.stopDownloading();
} }
catch (e) { catch (e) {
LOG("gUpdatesAvailablePage", "onWizardCancel - " + LOG("gUpdatesFoundBillboardPage", "onWizardCancel - " +
"moreInfoContent.stopDownloading() failed: " + e); "moreInfoContent.stopDownloading() failed: " + e);
} }
} }
@ -925,16 +999,11 @@ var gLicensePage = {
if (this._licenseLoaded || licenseContent.getAttribute("state") == "error") { if (this._licenseLoaded || licenseContent.getAttribute("state") == "error") {
this.onAcceptDeclineRadio(); this.onAcceptDeclineRadio();
var licenseGroup = document.getElementById("acceptDeclineLicense"); var licenseGroup = document.getElementById("acceptDeclineLicense");
if (licenseGroup.selectedIndex == 0) licenseGroup.focus();
gUpdates.wiz.getButton("next").focus();
else
licenseGroup.focus();
return; return;
} }
gUpdates.wiz.getButton("extra1").disabled = true; gUpdates.wiz.canAdvance = false;
if (gIncompatibleCheckPage.addons.length == 0)
gUpdates.wiz.currentPage.setAttribute("next", "downloading");
// Disable the license radiogroup until the EULA has been downloaded // Disable the license radiogroup until the EULA has been downloaded
document.getElementById("acceptDeclineLicense").disabled = true; document.getElementById("acceptDeclineLicense").disabled = true;
@ -986,12 +1055,15 @@ var gLicensePage = {
gUpdates.wiz.canAdvance = licenseAccepted; gUpdates.wiz.canAdvance = licenseAccepted;
}, },
/**
* The non-standard "Back" button.
*/
onExtra1: function() { onExtra1: function() {
gUpdates.wiz.currentPage = document.getElementById("updatesfound"); gUpdates.wiz.goTo(gUpdates.updatesFoundPageId);
}, },
/** /**
* When the user accepts the license by hitting "Next" * When the user clicks next after accepting the license
*/ */
onWizardNext: function() { onWizardNext: function() {
try { try {
@ -1051,7 +1123,7 @@ var gIncompatibleListPage = {
document.getElementById("incompatibleListDesc").textContent = intro; document.getElementById("incompatibleListDesc").textContent = intro;
var addons = gIncompatibleCheckPage.addons; var addons = gUpdates.addons;
for (var i = 0; i < addons.length; ++i) { for (var i = 0; i < addons.length; ++i) {
var listitem = document.createElement("listitem"); var listitem = document.createElement("listitem");
listitem.setAttribute("label", addons[i].name + " " + addons[i].version); listitem.setAttribute("label", addons[i].name + " " + addons[i].version);
@ -1059,12 +1131,12 @@ var gIncompatibleListPage = {
} }
}, },
/**
* The non-standard "Back" button.
*/
onExtra1: function() { onExtra1: function() {
var updatesfoundPage = document.getElementById("updatesfound"); gUpdates.wiz.goTo(gUpdates.update.licenseURL ? "license"
if (updatesfoundPage.getAttribute("next") == "license") : gUpdates.updatesFoundPageId);
gUpdates.wiz.currentPage = document.getElementById("license");
else
gUpdates.wiz.currentPage = updatesfoundPage;
} }
}; };
@ -1106,7 +1178,6 @@ var gDownloadingPage = {
this._downloadName = document.getElementById("downloadName"); this._downloadName = document.getElementById("downloadName");
this._downloadStatus = document.getElementById("downloadStatus"); this._downloadStatus = document.getElementById("downloadStatus");
this._downloadProgress = document.getElementById("downloadProgress"); this._downloadProgress = document.getElementById("downloadProgress");
this._downloadProgress.hidden = false;
this._downloadThrobber = document.getElementById("downloadThrobber"); this._downloadThrobber = document.getElementById("downloadThrobber");
this._pauseButton = document.getElementById("pauseButton"); this._pauseButton = document.getElementById("pauseButton");
this._label_downloadStatus = this._downloadStatus.textContent; this._label_downloadStatus = this._downloadStatus.textContent;
@ -1147,7 +1218,9 @@ var gDownloadingPage = {
// we fell back from a partial patch to a complete patch and even // we fell back from a partial patch to a complete patch and even
// then we couldn't validate. Show a validation error with instructions // then we couldn't validate. Show a validation error with instructions
// on how to manually update. // on how to manually update.
this.showVerificationError(); this.removeDownloadListener();
gUpdates.wiz.goTo("errors");
return;
} }
else { else {
// Add this UI as a listener for active downloads // Add this UI as a listener for active downloads
@ -1171,12 +1244,6 @@ var gDownloadingPage = {
gUpdates.wiz.getButton("extra1").focus(); gUpdates.wiz.getButton("extra1").focus();
}, },
showVerificationError: function() {
var verificationError = gUpdates.getAUSString("verificationError",
[gUpdates.brandName]);
gUpdates.advanceToErrorPage(verificationError);
},
/** /**
* Updates the text status message * Updates the text status message
*/ */
@ -1252,6 +1319,15 @@ var gDownloadingPage = {
} }
}, },
/**
* Removes the download listener.
*/
removeDownloadListener: function() {
var aus = CoC["@mozilla.org/updates/update-service;1"].
getService(CoI.nsIApplicationUpdateService);
aus.removeDownloadListener(this);
},
/** /**
* When the user clicks the Pause/Resume button * When the user clicks the Pause/Resume button
*/ */
@ -1279,10 +1355,10 @@ var gDownloadingPage = {
// Remove ourself as a download listener so that we don't continue to be // Remove ourself as a download listener so that we don't continue to be
// fed progress and state notifications after the UI we're updating has // fed progress and state notifications after the UI we're updating has
// gone away. // gone away.
this.removeDownloadListener();
var aus = CoC["@mozilla.org/updates/update-service;1"]. var aus = CoC["@mozilla.org/updates/update-service;1"].
getService(CoI.nsIApplicationUpdateService); getService(CoI.nsIApplicationUpdateService);
aus.removeDownloadListener(this);
var um = CoC["@mozilla.org/updates/update-manager;1"]. var um = CoC["@mozilla.org/updates/update-manager;1"].
getService(CoI.nsIUpdateManager); getService(CoI.nsIUpdateManager);
um.activeUpdate = gUpdates.update; um.activeUpdate = gUpdates.update;
@ -1353,7 +1429,6 @@ var gDownloadingPage = {
onProgress: function(request, context, progress, maxProgress) { onProgress: function(request, context, progress, maxProgress) {
LOG("gDownloadingPage", "onProgress - progress: " + progress + "/" + LOG("gDownloadingPage", "onProgress - progress: " + progress + "/" +
maxProgress); maxProgress);
var name = gUpdates.getAUSString("downloadingPrefix", [gUpdates.update.name]); var name = gUpdates.getAUSString("downloadingPrefix", [gUpdates.update.name]);
let status = this._updateDownloadStatus(progress, maxProgress); let status = this._updateDownloadStatus(progress, maxProgress);
var currentProgress = Math.round(100 * (progress / maxProgress)); var currentProgress = Math.round(100 * (progress / maxProgress));
@ -1373,9 +1448,23 @@ var gDownloadingPage = {
this._downloadThrobber.setAttribute("state", "loading"); this._downloadThrobber.setAttribute("state", "loading");
if (this._downloadProgress.mode != "normal") if (this._downloadProgress.mode != "normal")
this._downloadProgress.mode = "normal"; this._downloadProgress.mode = "normal";
this._downloadProgress.value = currentProgress; if (this._downloadProgress.value != currentProgress)
this._pauseButton.disabled = false; this._downloadProgress.value = currentProgress;
this._downloadName.value = name; if (this._pauseButton.disabled)
this._pauseButton.disabled = false;
if (this._downloadName.value != name)
this._downloadName.value = name;
// If the update has completed downloading and the download status contains
// the original text return early to avoid an assertion in debug builds.
// Since the page will advance immmediately due to the update completing the
// download updating the status is not important.
// nsTextFrame::GetTrimmedOffsets 'Can only call this on frames that have
// been reflowed'.
if (progress == maxProgress &&
this._downloadStatus.textContent == this._label_downloadStatus)
return;
this._setStatus(status); this._setStatus(status);
}, },
@ -1422,8 +1511,8 @@ var gDownloadingPage = {
u.isCompleteUpdate) { u.isCompleteUpdate) {
// Verification error of complete patch, informational text is held in // Verification error of complete patch, informational text is held in
// the update object. // the update object.
this._downloadProgress.hidden = true; this.removeDownloadListener();
gUpdates.wiz.currentPage = document.getElementById("errors"); gUpdates.wiz.goTo("errors");
} }
else { else {
// Verification failed for a partial patch, complete patch is now // Verification failed for a partial patch, complete patch is now
@ -1447,21 +1536,16 @@ var gDownloadingPage = {
return; return;
case CoR.NS_OK: case CoR.NS_OK:
LOG("gDownloadingPage", "onStopRequest - patch verification succeeded"); LOG("gDownloadingPage", "onStopRequest - patch verification succeeded");
this._downloadProgress.hidden = true; this.removeDownloadListener();
gUpdates.wiz.canAdvance = true; gUpdates.wiz.goTo("finished");
gUpdates.wiz.advance();
break; break;
default: default:
LOG("gDownloadingPage", "onStopRequest - transfer failed"); LOG("gDownloadingPage", "onStopRequest - transfer failed");
// Some kind of transfer error, die. // Some kind of transfer error, die.
this._downloadProgress.hidden = true; this.removeDownloadListener();
gUpdates.wiz.currentPage = document.getElementById("errors"); gUpdates.wiz.goTo("errors");
break; break;
} }
var aus = CoC["@mozilla.org/updates/update-service;1"].
getService(CoI.nsIApplicationUpdateService);
aus.removeDownloadListener(this);
}, },
/** /**
@ -1477,7 +1561,7 @@ var gDownloadingPage = {
}; };
/** /**
* The "There was an error during the update" page. * The "There was an error applying the update's patch" page.
*/ */
var gErrorsPage = { var gErrorsPage = {
/** /**
@ -1499,42 +1583,32 @@ var gErrorsPage = {
var errorLinkLabel = document.getElementById("errorLinkLabel"); var errorLinkLabel = document.getElementById("errorLinkLabel");
errorLinkLabel.value = manualURL; errorLinkLabel.value = manualURL;
errorLinkLabel.setAttribute("url", manualURL); errorLinkLabel.setAttribute("url", manualURL);
}
};
/**
* The "There was an error applying a partial patch" page.
*/
var gErrorPatchingPage = {
/**
* Initialize
*/
onPageShow: function() {
gUpdates.setButtons(null, null, "okButton", true);
}, },
/** onWizardNext: function() {
* Finish button clicked. switch (gUpdates.update.selectedPatch.state) {
*/ case STATE_PENDING:
onWizardFinish: function() { gUpdates.wiz.goTo("finished");
// XXXjwalden COMPLETE AND TOTAL HACK!!! break;
// case STATE_DOWNLOADING:
// The problem the following code is working around is this: the update gUpdates.wiz.goTo("downloading");
// service's API for responding to updates is poor. Essentially, all break;
// the information we can get is that we've started to request a download or case STATE_DOWNLOAD_FAILED:
// that the download we've started has finished, with minimal details about gUpdates.wiz.goTo("errors");
// how it finished which aren't described in the API (and which internally break;
// are not entirely useful, either -- mostly unuseful nsresults). How }
// do you signal the difference between "this download failed" and "all
// downloads failed", particularly if you aim for API compatibility? The
// code in nsApplicationUpdateService only determines the difference *after*
// the current request is stopped, and since the subsequent second call to
// downloadUpdate doesn't start/stop a request, the download listener is
// never notified and whatever code was relying on it just fails without
// notification. The consequence of this is that it's impossible to
// properly remove the download listener.
//
// The code before this patch tried to do the exit after all downloads
// failed but was missing a QueryInterface to work; with it, making sure
// that the download listener is removed in all cases, including in the case
// where the last onStopRequest corresponds to *a* failed download instead
// of to *all* failed downloads, simply means that we have to try to remove
// that listener in the error page spawned by the update service. If there
// were time and API compat weren't a problem, we'd add an onFinish handler
// or something which could signal exactly what happened and not overload
// onStopRequest, but there isn't, so we can't.
//
var aus = CoC["@mozilla.org/updates/update-service;1"].
getService(CoI.nsIApplicationUpdateService);
aus.removeDownloadListener(gDownloadingPage);
} }
}; };
@ -1550,7 +1624,7 @@ var gFinishedPage = {
gUpdates.setButtons("restartLaterButton", null, "restartNowButton", gUpdates.setButtons("restartLaterButton", null, "restartNowButton",
true); true);
var btn = gUpdates.wiz.getButton("finish"); var btn = gUpdates.wiz.getButton("finish");
btn.className += " heed"; btn.classList.add("heed");
btn.focus(); btn.focus();
}, },
@ -1637,6 +1711,7 @@ var gInstalledPage = {
var branding = document.getElementById("brandStrings"); var branding = document.getElementById("brandStrings");
try { try {
// whatsNewURL should just be a pref (bug 546609).
var url = branding.getFormattedString("whatsNewURL", [ai.version]); var url = branding.getFormattedString("whatsNewURL", [ai.version]);
var whatsnewLink = document.getElementById("whatsnewLink"); var whatsnewLink = document.getElementById("whatsnewLink");
whatsnewLink.setAttribute("url", url); whatsnewLink.setAttribute("url", url);

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

@ -22,6 +22,7 @@
# #
# Contributor(s): # Contributor(s):
# Ben Goodger <ben@mozilla.org> # Ben Goodger <ben@mozilla.org>
# Robert Strong <robert.bugzilla@gmail.com> (Original Author)
# #
# Alternatively, the contents of this file may be used under the terms of # Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or # either the GNU General Public License Version 2 or later (the "GPL"), or
@ -78,7 +79,7 @@
onpageshow="gCheckingPage.onPageShow();"> onpageshow="gCheckingPage.onPageShow();">
<label>&updateCheck.label;</label> <label>&updateCheck.label;</label>
<separator class="thin"/> <separator class="thin"/>
<progressmeter id="checkingProgress" mode="undetermined" hidden="true"/> <progressmeter id="checkingProgress" mode="undetermined"/>
</wizardpage> </wizardpage>
<wizardpage id="pluginupdatesfound" pageid="pluginupdatesfound" <wizardpage id="pluginupdatesfound" pageid="pluginupdatesfound"
@ -97,15 +98,6 @@
<label id="noUpdatesAutoDisabled" hidden="true">&noupdatesautodisabled.intro;</label> <label id="noUpdatesAutoDisabled" hidden="true">&noupdatesautodisabled.intro;</label>
</wizardpage> </wizardpage>
<wizardpage id="incompatibleCheck" pageid="incompatibleCheck"
next="updatesfound" label="&incompatibleCheck.title;"
object="gIncompatibleCheckPage"
onpageshow="gIncompatibleCheckPage.onPageShow();">
<label>&incompatibleCheck.label;</label>
<separator class="thin"/>
<progressmeter id="incompatibleCheckProgress" mode="undetermined" hidden="true"/>
</wizardpage>
<wizardpage id="manualUpdate" pageid="manualUpdate" <wizardpage id="manualUpdate" pageid="manualUpdate"
label="&manualUpdate.title;" object="gManualUpdatePage" label="&manualUpdate.title;" object="gManualUpdatePage"
onpageshow="gManualUpdatePage.onPageShow();"> onpageshow="gManualUpdatePage.onPageShow();">
@ -118,32 +110,50 @@
</hbox> </hbox>
</wizardpage> </wizardpage>
<wizardpage id="updatesfound" pageid="updatesfound" next="license" <wizardpage id="incompatibleCheck" pageid="incompatibleCheck"
object="gUpdatesAvailablePage" label="" next="updatesfoundbasic" label="&incompatibleCheck.title;"
onpageshow="gUpdatesAvailablePage.onPageShow();" object="gIncompatibleCheckPage"
onextra1="gUpdatesAvailablePage.onExtra1();" onpageshow="gIncompatibleCheckPage.onPageShow();">
onextra2="gUpdatesAvailablePage.onExtra2();"> <label>&incompatibleCheck.label;</label>
<description id="updateType"/> <separator class="thin"/>
<progressmeter id="incompatibleCheckProgress" mode="undetermined"/>
</wizardpage>
<wizardpage id="updatesfoundbasic" pageid="updatesfoundbasic"
object="gUpdatesFoundBasicPage" label="" next="downloading"
onpageshow="gUpdatesFoundBasicPage.onPageShow();"
onextra1="gUpdatesFoundBasicPage.onExtra1();"
onextra2="gUpdatesFoundBasicPage.onExtra2();">
<description id="updatesFoundInto"/>
<separator class="thin"/> <separator class="thin"/>
<label id="updateName" crop="right" value=""/> <label id="updateName" crop="right" value=""/>
<separator id="updateNameSep" class="thin"/> <separator id="updateNameSep" class="thin"/>
<description id="upgradeEvangelism">&evangelism.desc;</description> <description id="upgradeEvangelism">&evangelism.desc;</description>
<separator id="upgradeEvangelismSep" flex="1"/> <separator id="upgradeEvangelismSep" flex="1"/>
<vbox flex="1"> <vbox flex="1">
<vbox id="moreInfoContent" flex="1">
<!-- note, the localized properties for this are prefixed by
the id. examples: updateMoreInfoContentNotFound
and updateMoreInfoContentDownloading -->
<remotecontent id="updateMoreInfoContent" flex="1"/>
</vbox>
<hbox id="moreInfoURL"> <hbox id="moreInfoURL">
<label class="text-link" id="updateMoreInfoURL" <label class="text-link" id="updateMoreInfoURL"
value="&clickHere.label;" onclick="openUpdateURL(event);"/> value="&clickHere.label;" onclick="openUpdateURL(event);"/>
</hbox> </hbox>
</vbox> </vbox>
</wizardpage> </wizardpage>
<wizardpage id="updatesfoundbillboard" pageid="updatesfoundbillboard"
object="gUpdatesFoundBillboardPage" label="" next="downloading"
onpageshow="gUpdatesFoundBillboardPage.onPageShow();"
onextra1="gUpdatesFoundBillboardPage.onExtra1();"
onextra2="gUpdatesFoundBillboardPage.onExtra2();">
<description id="updatesFoundBillboardIntro"/>
<separator class="thin"/>
<vbox id="moreInfoContent" flex="1">
<!-- note, the localized properties for this are prefixed by
the id. examples: updateMoreInfoContentNotFound
and updateMoreInfoContentDownloading -->
<remotecontent id="updateMoreInfoContent" flex="1"/>
</vbox>
</wizardpage>
<wizardpage id="license" pageid="license" next="incompatibleList" <wizardpage id="license" pageid="license" next="downloading"
object="gLicensePage" label="&license.titleText;" object="gLicensePage" label="&license.titleText;"
onpageshow="gLicensePage.onPageShow();" onpageshow="gLicensePage.onPageShow();"
onextra1="gLicensePage.onExtra1();"> onextra1="gLicensePage.onExtra1();">
@ -187,7 +197,7 @@
</hbox> </hbox>
<separator class="thin"/> <separator class="thin"/>
<hbox id="downloadStatusProgress"> <hbox id="downloadStatusProgress">
<progressmeter id="downloadProgress" mode="undetermined" flex="1" hidden="true"/> <progressmeter id="downloadProgress" mode="undetermined" flex="1"/>
<button id="pauseButton" oncommand="gDownloadingPage.onPause();" <button id="pauseButton" oncommand="gDownloadingPage.onPause();"
paused="false"/> paused="false"/>
</hbox> </hbox>
@ -217,7 +227,8 @@
</wizardpage> </wizardpage>
<wizardpage id="errorpatching" pageid="errorpatching" next="downloading" <wizardpage id="errorpatching" pageid="errorpatching" next="downloading"
label="&errorpatching.title;" object="gErrorsPage"> object="gErrorPatchingPage" label="&errorpatching.title;"
onpageshow="gErrorPatchingPage.onPageShow();">
<label>&errorpatching.intro;</label> <label>&errorpatching.intro;</label>
</wizardpage> </wizardpage>

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

@ -1232,7 +1232,7 @@ UpdateService.prototype = {
update.statusText = gUpdateBundle.GetStringFromName("patchApplyFailure"); update.statusText = gUpdateBundle.GetStringFromName("patchApplyFailure");
var oldType = update.selectedPatch ? update.selectedPatch.type var oldType = update.selectedPatch ? update.selectedPatch.type
: "complete"; : "complete";
if (update.selectedPatch && oldType == "partial") { if (update.selectedPatch && oldType == "partial" && update.patchCount == 2) {
// Partial patch application failed, try downloading the complete // Partial patch application failed, try downloading the complete
// update in the background instead. // update in the background instead.
LOG("UpdateService:_postUpdateProcessing - install of partial patch " + LOG("UpdateService:_postUpdateProcessing - install of partial patch " +
@ -1712,6 +1712,28 @@ UpdateManager.prototype = {
*/ */
_activeUpdate: null, _activeUpdate: null,
/**
* Handle Observer Service notifications
* @param subject
* The subject of the notification
* @param topic
* The notification name
* @param data
* Additional data
*/
observe: function UM_observe(subject, topic, data) {
// Hack to be able to run and cleanup tests by reloading the update data.
if (topic == "um-reload-update-data") {
this._updates = this._loadXMLFileIntoArray(getUpdateFile(
[FILE_UPDATES_DB]));
this._activeUpdate = null;
var updates = this._loadXMLFileIntoArray(getUpdateFile(
[FILE_UPDATE_ACTIVE]));
if (updates.length > 0)
this._activeUpdate = updates[0];
}
},
/** /**
* Loads an updates.xml formatted file into an array of nsIUpdate items. * Loads an updates.xml formatted file into an array of nsIUpdate items.
* @param file * @param file
@ -1912,7 +1934,7 @@ UpdateManager.prototype = {
classDescription: "Update Manager", classDescription: "Update Manager",
contractID: "@mozilla.org/updates/update-manager;1", contractID: "@mozilla.org/updates/update-manager;1",
classID: Components.ID("{093C2356-4843-4C65-8709-D7DBCBBE7DFB}"), classID: Components.ID("{093C2356-4843-4C65-8709-D7DBCBBE7DFB}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIUpdateManager]) QueryInterface: XPCOMUtils.generateQI([Ci.nsIUpdateManager, Ci.nsIObserver])
}; };
/** /**
@ -2195,10 +2217,8 @@ Downloader.prototype = {
* Cancels the active download. * Cancels the active download.
*/ */
cancel: function Downloader_cancel() { cancel: function Downloader_cancel() {
if (this._request && this._request instanceof Ci.nsIRequest) { if (this._request && this._request instanceof Ci.nsIRequest)
const NS_BINDING_ABORTED = 0x804b0002; this._request.cancel(Cr.NS_BINDING_ABORTED);
this._request.cancel(NS_BINDING_ABORTED);
}
}, },
/** /**
@ -2466,8 +2486,7 @@ Downloader.prototype = {
*/ */
onProgress: function Downloader_onProgress(request, context, progress, onProgress: function Downloader_onProgress(request, context, progress,
maxProgress) { maxProgress) {
LOG("Downloader.onProgress:onProgress - progress: " + progress + "/" + LOG("Downloader:onProgress - progress: " + progress + "/" + maxProgress);
maxProgress);
var listenerCount = this._listeners.length; var listenerCount = this._listeners.length;
for (var i = 0; i < listenerCount; ++i) { for (var i = 0; i < listenerCount; ++i) {
@ -2517,8 +2536,6 @@ Downloader.prototype = {
var state = this._patch.state; var state = this._patch.state;
var shouldShowPrompt = false; var shouldShowPrompt = false;
var deleteActiveUpdate = false; var deleteActiveUpdate = false;
const NS_BINDING_ABORTED = 0x804b0002;
const NS_ERROR_ABORT = 0x80004004;
if (Components.isSuccessCode(status)) { if (Components.isSuccessCode(status)) {
if (this._verifyDownload()) { if (this._verifyDownload()) {
state = STATE_PENDING; state = STATE_PENDING;
@ -2554,8 +2571,8 @@ Downloader.prototype = {
cleanUpUpdatesDir(); cleanUpUpdatesDir();
} }
} }
else if (status != NS_BINDING_ABORTED && else if (status != Cr.NS_BINDING_ABORTED &&
status != NS_ERROR_ABORT) { status != Cr.NS_ERROR_ABORT) {
LOG("Downloader:onStopRequest - non-verification failure"); LOG("Downloader:onStopRequest - non-verification failure");
// Some sort of other failure, log this in the |statusText| property // Some sort of other failure, log this in the |statusText| property
state = STATE_DOWNLOAD_FAILED; state = STATE_DOWNLOAD_FAILED;
@ -2845,7 +2862,8 @@ UpdatePrompt.prototype = {
this.updatePrompt._showUI(parent, uri, features, name, page, update); this.updatePrompt._showUI(parent, uri, features, name, page, update);
// fall thru // fall thru
case "quit-application": case "quit-application":
this.timer.cancel(); if (this.timer)
this.timer.cancel();
this.service.removeObserver(this, "quit-application"); this.service.removeObserver(this, "quit-application");
break; break;
} }