зеркало из https://github.com/mozilla/gecko-dev.git
Bug 312661 - Software Update 1st step displays 'AUS: Update XML File Malformed (200)' if working offline . r=rstrong
This commit is contained in:
Родитель
e9b1bb3657
Коммит
86d4dad064
|
@ -59,16 +59,19 @@ checker_error-200=AUS: Update XML File Malformed (200)
|
||||||
checker_error-403=AUS: Access Denied (403)
|
checker_error-403=AUS: Access Denied (403)
|
||||||
checker_error-404=AUS: Update XML File Not Found (404)
|
checker_error-404=AUS: Update XML File Not Found (404)
|
||||||
checker_error-500=AUS: Internal Server Error (500)
|
checker_error-500=AUS: Internal Server Error (500)
|
||||||
|
checker_error-2152398849=Failed (Unknown Reason)
|
||||||
|
checker_error-2152398861=AUS: Connection Refused
|
||||||
|
checker_error-2152398862=AUS: Connection timed out
|
||||||
|
# NS_ERROR_OFFLINE
|
||||||
|
checker_error-2152398864=Network is Offline (Go online)
|
||||||
|
checker_error-2152398867=AUS: Port not allowed (Contact your Administrator)
|
||||||
|
checker_error-2152398868=AUS: No data was received (Please try again)
|
||||||
checker_error-2152398878=AUS: Update Server Not Found (Check your internet connection or contact your Administrator)
|
checker_error-2152398878=AUS: Update Server Not Found (Check your internet connection or contact your Administrator)
|
||||||
checker_error-2152398890=Proxy Server Not Found (Check your internet connection or contact your Administrator)
|
checker_error-2152398890=Proxy Server Not Found (Check your internet connection or contact your Administrator)
|
||||||
checker_error-2152398861=AUS: Connection Refused
|
# NS_ERROR_DOCUMENT_NOT_CACHED
|
||||||
checker_error-2152398920=Proxy Server Connection Refused (Contact your Administrator)
|
checker_error-2152398918=Network is Offline (Go online)
|
||||||
checker_error-2152398862=AUS: Connection timed out
|
|
||||||
checker_error-2152398864=Network is Offline (Go online)
|
|
||||||
checker_error-2152398849=Failed (Unknown Reason)
|
|
||||||
checker_error-2152398868=AUS: No data was received (Please try again)
|
|
||||||
checker_error-2152398919=AUS: Data transfer was interrupted (Please try again)
|
checker_error-2152398919=AUS: Data transfer was interrupted (Please try again)
|
||||||
checker_error-2152398867=AUS: Port not allowed (Contact your Administrator)
|
checker_error-2152398920=Proxy Server Connection Refused (Contact your Administrator)
|
||||||
checker_error-verification_failed=The integrity of the update could not be verified (Contact your Administrator)
|
checker_error-verification_failed=The integrity of the update could not be verified (Contact your Administrator)
|
||||||
|
|
||||||
installSuccess=The Update was successfully installed
|
installSuccess=The Update was successfully installed
|
||||||
|
|
|
@ -322,18 +322,18 @@ function closeSafeOutputStream(fos) {
|
||||||
* @returns A human readable status text string
|
* @returns A human readable status text string
|
||||||
*/
|
*/
|
||||||
function getStatusTextFromCode(code, defaultCode) {
|
function getStatusTextFromCode(code, defaultCode) {
|
||||||
var sbs =
|
const updateBundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
|
||||||
Components.classes["@mozilla.org/intl/stringbundle;1"].
|
.getService(Components.interfaces.nsIStringBundleService)
|
||||||
getService(Components.interfaces.nsIStringBundleService);
|
.createBundle(URI_UPDATES_PROPERTIES);
|
||||||
var updateBundle = sbs.createBundle(URI_UPDATES_PROPERTIES);
|
var reason;
|
||||||
var reason = updateBundle.GetStringFromName("checker_error-" + defaultCode);
|
|
||||||
try {
|
try {
|
||||||
reason = updateBundle.GetStringFromName("checker_error-" + code);
|
reason = updateBundle.GetStringFromName("checker_error-" + code);
|
||||||
LOG("General", "Transfer Error: " + reason + ", code: " + code);
|
LOG("General", "Transfer Error: " + reason + ", code: " + code);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
// Use the default reason
|
// Use the default reason
|
||||||
LOG("General", "Transfer Error: " + reason + ", code: " + defaultCode);
|
reason = updateBundle.GetStringFromName("checker_error-" + defaultCode);
|
||||||
|
LOG("General", "Transfer Error: " + reason + ", default code: " + defaultCode);
|
||||||
}
|
}
|
||||||
return reason;
|
return reason;
|
||||||
}
|
}
|
||||||
|
@ -2099,14 +2099,21 @@ Checker.prototype = {
|
||||||
LOG("Checker", "onError: error during load");
|
LOG("Checker", "onError: error during load");
|
||||||
|
|
||||||
var request = event.target;
|
var request = event.target;
|
||||||
|
|
||||||
|
// Set a default value of |0|,
|
||||||
|
// then if |request.status| is defined (but) to this (useless) value,
|
||||||
|
// we will not use it.
|
||||||
|
var status = 0;
|
||||||
try {
|
try {
|
||||||
var status = request.status;
|
status = request.status;
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
var req = request.channel.QueryInterface(Components.interfaces.nsIRequest);
|
|
||||||
status = req.status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status == 0)
|
||||||
|
status = request.channel.QueryInterface(Components.interfaces.nsIRequest)
|
||||||
|
.status;
|
||||||
|
|
||||||
// If we can't find an error string specific to this status code,
|
// If we can't find an error string specific to this status code,
|
||||||
// just use the 200 message from above, which means everything
|
// just use the 200 message from above, which means everything
|
||||||
// "looks" fine but there was probably an XML error or a bogus file.
|
// "looks" fine but there was probably an XML error or a bogus file.
|
||||||
|
@ -2552,8 +2559,9 @@ Downloader.prototype = {
|
||||||
// TODO: use more informative error code here
|
// TODO: use more informative error code here
|
||||||
status = Components.results.NS_ERROR_UNEXPECTED;
|
status = Components.results.NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
var message = getStatusTextFromCode("verification_failed",
|
// Yes, this code is a string.
|
||||||
"verification_failed");
|
const vfCode = "verification_failed";
|
||||||
|
var message = getStatusTextFromCode(vfCode, vfCode);
|
||||||
this._update.statusText = message;
|
this._update.statusText = message;
|
||||||
|
|
||||||
if (this._update.isCompleteUpdate)
|
if (this._update.isCompleteUpdate)
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is the Application Update Service.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Robert Strong <robert.bugzilla@gmail.com>.
|
||||||
|
*
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||||
|
* the Mozilla Foundation <http://www.mozilla.org/>. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* General Update Check Tests */
|
||||||
|
|
||||||
|
const PREF_APP_UPDATE_URL_OVERRIDE = "app.update.url.override";
|
||||||
|
|
||||||
|
var gStatusText;
|
||||||
|
var gCheckFunc;
|
||||||
|
|
||||||
|
function run_test() {
|
||||||
|
do_test_pending();
|
||||||
|
var ioService = AUS_Cc["@mozilla.org/network/io-service;1"]
|
||||||
|
.getService(AUS_Ci.nsIIOService);
|
||||||
|
try {
|
||||||
|
ioService.manageOfflineStatus = false;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
}
|
||||||
|
ioService.offline = true;
|
||||||
|
startAUS();
|
||||||
|
do_timeout(0, "run_test_pt1()");
|
||||||
|
}
|
||||||
|
|
||||||
|
function end_test() {
|
||||||
|
do_test_finished();
|
||||||
|
}
|
||||||
|
|
||||||
|
// one update available and the update's property values
|
||||||
|
function run_test_pt1() {
|
||||||
|
gStatusText = null;
|
||||||
|
gCheckFunc = check_test_pt1;
|
||||||
|
dump("Testing: update,statusText when xml is not cached and network is offline\n");
|
||||||
|
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, "http://localhost:4444/");
|
||||||
|
gUpdateChecker.checkForUpdates(updateCheckListener, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_test_pt1() {
|
||||||
|
const URI_UPDATES_PROPERTIES = "chrome://mozapps/locale/update/updates.properties";
|
||||||
|
const updateBundle = AUS_Cc["@mozilla.org/intl/stringbundle;1"]
|
||||||
|
.getService(AUS_Ci.nsIStringBundleService)
|
||||||
|
.createBundle(URI_UPDATES_PROPERTIES);
|
||||||
|
var statusText = updateBundle.GetStringFromName("checker_error-2152398918");
|
||||||
|
do_check_eq(statusText, gStatusText);
|
||||||
|
end_test();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update check listener
|
||||||
|
const updateCheckListener = {
|
||||||
|
onProgress: function(request, position, totalSize) {
|
||||||
|
},
|
||||||
|
|
||||||
|
onCheckComplete: function(request, updates, updateCount) {
|
||||||
|
dump("onCheckComplete request.status = " + request.status + "\n\n");
|
||||||
|
// Use a timeout to allow the XHR to complete
|
||||||
|
do_timeout(0, "gCheckFunc()");
|
||||||
|
},
|
||||||
|
|
||||||
|
onError: function(request, update) {
|
||||||
|
gStatusText = update.statusText;
|
||||||
|
dump("onError update.statusText = " + update.statusText + "\n\n");
|
||||||
|
// Use a timeout to allow the XHR to complete
|
||||||
|
do_timeout(0, "gCheckFunc()");
|
||||||
|
},
|
||||||
|
|
||||||
|
QueryInterface: function(aIID) {
|
||||||
|
if (!aIID.equals(AUS_Ci.nsIUpdateCheckListener) &&
|
||||||
|
!aIID.equals(AUS_Ci.nsISupports))
|
||||||
|
throw AUS_Cr.NS_ERROR_NO_INTERFACE;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
};
|
Загрузка…
Ссылка в новой задаче