зеркало из https://github.com/mozilla/gecko-dev.git
Bug 833708: Correctly set the active update's errorCode when there isn't enough space in Gonk. r=dhylands
This commit is contained in:
Родитель
7c86473ca0
Коммит
0c5e954231
|
@ -48,6 +48,7 @@ DirectoryProvider.prototype = {
|
|||
classID: Components.ID("{9181eb7c-6f87-11e1-90b1-4f59d80dd2e5}"),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDirectoryServiceProvider]),
|
||||
_xpcom_factory: XPCOMUtils.generateSingletonFactory(DirectoryProvider),
|
||||
|
||||
getFile: function dp_getFile(prop, persistent) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
|
@ -105,6 +106,7 @@ DirectoryProvider.prototype = {
|
|||
if (!Services.volumeService) {
|
||||
return this.createUpdatesDir(LOCAL_DIR, subdir);
|
||||
}
|
||||
|
||||
let activeUpdate = Services.um.activeUpdate;
|
||||
if (gUseSDCard) {
|
||||
if (this.volumeHasFreeSpace(gExtStorage, requiredSpace)) {
|
||||
|
@ -158,7 +160,8 @@ DirectoryProvider.prototype = {
|
|||
// error and let upstream code handle it more gracefully.
|
||||
log("Error: No volume found with " + requiredSpace + " bytes for downloading"+
|
||||
" update " + activeUpdate.name);
|
||||
throw Cr.NS_ERROR_FILE_TOO_BIG;
|
||||
activeUpdate.errorCode = Cr.NS_ERROR_FILE_TOO_BIG;
|
||||
return null;
|
||||
},
|
||||
|
||||
createUpdatesDir: function dp_createUpdatesDir(root, subdir) {
|
||||
|
|
|
@ -25,7 +25,6 @@ const PREF_DOWNLOAD_WATCHDOG_TIMEOUT = "b2g.update.download-watchdog-timeout
|
|||
const PREF_DOWNLOAD_WATCHDOG_MAX_RETRIES = "b2g.update.download-watchdog-max-retries";
|
||||
|
||||
const NETWORK_ERROR_OFFLINE = 111;
|
||||
const FILE_ERROR_TOO_BIG = 112;
|
||||
const HTTP_ERROR_OFFSET = 1000;
|
||||
|
||||
const STATE_DOWNLOADING = 'downloading';
|
||||
|
@ -314,7 +313,8 @@ UpdatePrompt.prototype = {
|
|||
}
|
||||
|
||||
log("Error downloading update " + aUpdate.name + ": " + aUpdate.errorCode);
|
||||
if (aUpdate.errorCode == FILE_ERROR_TOO_BIG) {
|
||||
let errorCode = aUpdate.errorCode >>> 0;
|
||||
if (errorCode == Cr.NS_ERROR_FILE_TOO_BIG) {
|
||||
aUpdate.statusText = "file-too-big";
|
||||
}
|
||||
this.showUpdateError(aUpdate);
|
||||
|
|
|
@ -3499,9 +3499,6 @@ Downloader.prototype = {
|
|||
try {
|
||||
updateArchive = FileUtils.getDir(KEY_UPDATE_ARCHIVE_DIR, [], true);
|
||||
} catch (e) {
|
||||
if (e == Cr.NS_ERROR_FILE_TOO_BIG) {
|
||||
this._update.errorCode = FILE_ERROR_TOO_BIG;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
AUS_Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||
const KEY_UPDATE_ARCHIVE_DIR = "UpdArchD"
|
||||
|
||||
let gActiveUpdate = null;
|
||||
|
||||
function FakeDirProvider() {}
|
||||
FakeDirProvider.prototype = {
|
||||
classID: Components.ID("{f30b43a7-2bfa-4e5f-8c4f-abc7dd4ac486}"),
|
||||
QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsIDirectoryServiceProvider]),
|
||||
|
||||
getFile: function(prop, persistent) {
|
||||
if (prop == KEY_UPDATE_ARCHIVE_DIR) {
|
||||
if (gActiveUpdate) {
|
||||
gActiveUpdate.errorCode = AUS_Cr.NS_ERROR_FILE_TOO_BIG;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
do_register_cleanup(end_test);
|
||||
DEBUG_AUS_TEST = true;
|
||||
|
||||
removeUpdateDirsAndFiles();
|
||||
setUpdateURLOverride();
|
||||
overrideXHR(xhr_pt1);
|
||||
standardInit();
|
||||
|
||||
logTestInfo("testing that error codes set from a directory provider propagate" +
|
||||
"up to AUS.downloadUpdate() correctly");
|
||||
|
||||
gDirProvider = new FakeDirProvider();
|
||||
gOldProvider = AUS_Cc["@mozilla.org/browser/directory-provider;1"]
|
||||
.createInstance(AUS_Ci.nsIDirectoryServiceProvider);
|
||||
|
||||
gDirService = AUS_Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(AUS_Ci.nsIProperties);
|
||||
|
||||
gDirService.unregisterProvider(gOldProvider);
|
||||
gDirService.registerProvider(gDirProvider);
|
||||
|
||||
Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, true);
|
||||
do_execute_soon(run_test_pt1);
|
||||
}
|
||||
|
||||
function xhr_pt1() {
|
||||
gXHR.status = 200;
|
||||
gXHR.responseText = gResponseBody;
|
||||
try {
|
||||
var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"].
|
||||
createInstance(AUS_Ci.nsIDOMParser);
|
||||
gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
|
||||
}
|
||||
catch(e) {
|
||||
gXHR.responseXML = null;
|
||||
}
|
||||
var e = { target: gXHR };
|
||||
gXHR.onload(e);
|
||||
}
|
||||
|
||||
function run_test_pt1() {
|
||||
gUpdates = null;
|
||||
gUpdateCount = null;
|
||||
gCheckFunc = check_test_pt1;
|
||||
|
||||
|
||||
let patches = getRemotePatchString();
|
||||
let updates = getRemoteUpdateString(patches);
|
||||
gResponseBody = getRemoteUpdatesXMLString(updates);
|
||||
gUpdateChecker.checkForUpdates(updateCheckListener, true);
|
||||
}
|
||||
|
||||
function check_test_pt1() {
|
||||
do_check_eq(gUpdateCount, 1);
|
||||
|
||||
gActiveUpdate = gUpdates[0];
|
||||
do_check_neq(gActiveUpdate, null);
|
||||
|
||||
let state = gAUS.downloadUpdate(gActiveUpdate, true);
|
||||
do_check_eq(state, "null");
|
||||
do_check_eq(gActiveUpdate.errorCode >>> 0 , AUS_Cr.NS_ERROR_FILE_TOO_BIG);
|
||||
do_test_finished();
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
gDirService.unregisterProvider(gDirProvider);
|
||||
gDirService.registerProvider(gOldProvider);
|
||||
gActiveUpdate = null;
|
||||
gDirService = null;
|
||||
gDirProvider = null;
|
||||
|
||||
cleanUp();
|
||||
}
|
|
@ -32,3 +32,5 @@ run-if = os == 'linux' || os == 'mac' || os == 'sunos'
|
|||
skip-if = toolkit == "gonk"
|
||||
reason = custom nsIUpdatePrompt
|
||||
[test_bug794211.js]
|
||||
[test_bug833708.js]
|
||||
run-if = toolkit == "gonk"
|
||||
|
|
Загрузка…
Ссылка в новой задаче