mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Followup for Bug 595059 - Incorrect errorCode comparison and enabled check in showUpdateError. r=dtownsend, a=approval2.0
This commit is contained in:
parent
bc31b46407
commit
f1e5def4c9
@ -2814,6 +2814,9 @@ UpdatePrompt.prototype = {
|
||||
* See nsIUpdateService.idl
|
||||
*/
|
||||
showUpdateError: function UP_showUpdateError(update) {
|
||||
if (!this._enabled)
|
||||
return;
|
||||
|
||||
if (update.errorCode &&
|
||||
(update.errorCode == CERT_ATTR_CHECK_FAILED_NO_UPDATE ||
|
||||
update.errorCode == CERT_ATTR_CHECK_FAILED_HAS_UPDATE)) {
|
||||
|
@ -141,8 +141,6 @@ const URL_UPDATE = URL_HOST + URL_PATH + "/update.sjs";
|
||||
|
||||
const URI_UPDATE_PROMPT_DIALOG = "chrome://mozapps/content/update/updates.xul";
|
||||
|
||||
const CRC_ERROR = 4;
|
||||
|
||||
const ADDON_ID_SUFFIX = "@appupdatetest.mozilla.org";
|
||||
const ADDON_PREP_DIR = "appupdateprep";
|
||||
// Preference for storing add-ons that are disabled by the tests to prevent them
|
||||
|
@ -83,6 +83,9 @@ const STATE_SUCCEEDED = "succeeded";
|
||||
const STATE_DOWNLOAD_FAILED = "download-failed";
|
||||
const STATE_FAILED = "failed";
|
||||
|
||||
const CRC_ERROR = 4;
|
||||
const WRITE_ERROR = 7;
|
||||
|
||||
const FILE_BACKUP_LOG = "backup-update.log";
|
||||
const FILE_LAST_LOG = "last-update.log";
|
||||
const FILE_UPDATES_DB = "updates.xml";
|
||||
|
@ -56,7 +56,7 @@ function run_test() {
|
||||
removeUpdateDirsAndFiles();
|
||||
setUpdateChannel();
|
||||
|
||||
var registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
|
||||
let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
|
||||
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
|
||||
"Fake Window Watcher",
|
||||
"@mozilla.org/embedcomp/window-watcher;1",
|
||||
@ -71,18 +71,21 @@ function run_test() {
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
|
||||
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
|
||||
WindowWatcherFactory);
|
||||
do_test_finished();
|
||||
cleanUp();
|
||||
}
|
||||
|
||||
function run_test_pt1() {
|
||||
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
|
||||
var url = URL_HOST + URL_PATH + "/partial.mar";
|
||||
var patches = getLocalPatchString("partial", url, null, null, null, null,
|
||||
let url = URL_HOST + URL_PATH + "/partial.mar";
|
||||
let patches = getLocalPatchString("partial", url, null, null, null, null,
|
||||
STATE_FAILED) +
|
||||
getLocalPatchString(null, null, null, null, null, null,
|
||||
STATE_NONE);
|
||||
var updates = getLocalUpdateString(patches, null, null, "version 1.0", "1.0",
|
||||
let updates = getLocalUpdateString(patches, null, null, "version 1.0", "1.0",
|
||||
null, null, null, null, url);
|
||||
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
|
||||
writeStatusFile(STATE_FAILED);
|
||||
@ -93,7 +96,7 @@ function run_test_pt1() {
|
||||
"entering private browsing\n");
|
||||
do_check_eq(gUpdateManager.activeUpdate.state, STATE_DOWNLOADING);
|
||||
|
||||
var privBrowsing = AUS_Cc[PRIVATEBROWSING_CONTRACT_ID].
|
||||
let privBrowsing = AUS_Cc[PRIVATEBROWSING_CONTRACT_ID].
|
||||
getService(AUS_Ci.nsIPrivateBrowsingService).
|
||||
QueryInterface(AUS_Ci.nsIObserver);
|
||||
|
||||
@ -125,8 +128,8 @@ var WindowWatcher = {
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(AUS_Ci.nsIWindowWatcher)
|
||||
|| iid.equals(AUS_Ci.nsISupports))
|
||||
if (iid.equals(AUS_Ci.nsIWindowWatcher) ||
|
||||
iid.equals(AUS_Ci.nsISupports))
|
||||
return this;
|
||||
|
||||
throw AUS_Cr.NS_ERROR_NO_INTERFACE;
|
||||
|
85
toolkit/mozapps/update/test/unit/test_bug595059.js
Normal file
85
toolkit/mozapps/update/test/unit/test_bug595059.js
Normal file
@ -0,0 +1,85 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Bug 595059 - begin download of a complete update after a failure applying a
|
||||
* partial update.
|
||||
*/
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
dump("Testing: Bug 595059 - calling nsIUpdatePrompt::showUpdateError " +
|
||||
"should call getNewPrompter and alert on the object returned by " +
|
||||
"getNewPrompter when the update.state = " + STATE_FAILED + " and the " +
|
||||
"update.errorCode = " + WRITE_ERROR + "\n");
|
||||
|
||||
removeUpdateDirsAndFiles();
|
||||
setUpdateChannel();
|
||||
|
||||
let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
|
||||
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
|
||||
"Fake Window Watcher",
|
||||
"@mozilla.org/embedcomp/window-watcher;1",
|
||||
WindowWatcherFactory);
|
||||
|
||||
standardInit();
|
||||
|
||||
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
|
||||
let url = URL_HOST + URL_PATH + "/complete.mar";
|
||||
let patches = getLocalPatchString("complete", url, null, null, null, null,
|
||||
STATE_FAILED);
|
||||
let updates = getLocalUpdateString(patches, null, null, "version 1.0", "1.0",
|
||||
null, null, null, null, url);
|
||||
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
|
||||
writeStatusFile(STATE_FAILED);
|
||||
|
||||
reloadUpdateManagerData();
|
||||
|
||||
let update = gUpdateManager.activeUpdate;
|
||||
update.errorCode = WRITE_ERROR;
|
||||
let prompter = AUS_Cc["@mozilla.org/updates/update-prompt;1"].
|
||||
createInstance(AUS_Ci.nsIUpdatePrompt);
|
||||
prompter.showUpdateError(update);
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
|
||||
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
|
||||
WindowWatcherFactory);
|
||||
do_test_finished();
|
||||
cleanUp();
|
||||
}
|
||||
|
||||
var WindowWatcher = {
|
||||
getNewPrompter: function(aParent) {
|
||||
do_check_eq(aParent, null);
|
||||
return {
|
||||
alert: function(aTitle, aText) {
|
||||
let title = getString("updaterIOErrorTitle");
|
||||
do_check_eq(aTitle, title);
|
||||
let text = gUpdateBundle.formatStringFromName("updaterIOErrorMsg",
|
||||
[Services.appinfo.name,
|
||||
Services.appinfo.name], 2);
|
||||
do_check_eq(aText, text);
|
||||
end_test();
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(AUS_Ci.nsIWindowWatcher) ||
|
||||
iid.equals(AUS_Ci.nsISupports))
|
||||
return this;
|
||||
|
||||
throw AUS_Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
var WindowWatcherFactory = {
|
||||
createInstance: function createInstance(outer, iid) {
|
||||
if (outer != null)
|
||||
throw AUS_Cr.NS_ERROR_NO_AGGREGATION;
|
||||
return WindowWatcher.QueryInterface(iid);
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user