michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: */ michael@0: michael@0: const KEY_UPDATE_ARCHIVE_DIR = "UpdArchD" michael@0: michael@0: let gActiveUpdate = null; michael@0: michael@0: function FakeDirProvider() {} michael@0: FakeDirProvider.prototype = { michael@0: classID: Components.ID("{f30b43a7-2bfa-4e5f-8c4f-abc7dd4ac486}"), michael@0: QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsIDirectoryServiceProvider]), michael@0: michael@0: getFile: function(prop, persistent) { michael@0: if (prop == KEY_UPDATE_ARCHIVE_DIR) { michael@0: if (gActiveUpdate) { michael@0: gActiveUpdate.errorCode = AUS_Cr.NS_ERROR_FILE_TOO_BIG; michael@0: } michael@0: } michael@0: return null; michael@0: } michael@0: }; michael@0: michael@0: function run_test() { michael@0: setupTestCommon(); michael@0: michael@0: setUpdateURLOverride(); michael@0: overrideXHR(xhr_pt1); michael@0: standardInit(); michael@0: michael@0: logTestInfo("testing that error codes set from a directory provider propagate" + michael@0: "up to AUS.downloadUpdate() correctly (Bug 794211)."); michael@0: michael@0: gDirProvider = new FakeDirProvider(); michael@0: gOldProvider = AUS_Cc["@mozilla.org/browser/directory-provider;1"] michael@0: .createInstance(AUS_Ci.nsIDirectoryServiceProvider); michael@0: michael@0: gDirService = AUS_Cc["@mozilla.org/file/directory_service;1"] michael@0: .getService(AUS_Ci.nsIProperties); michael@0: michael@0: gDirService.unregisterProvider(gOldProvider); michael@0: gDirService.registerProvider(gDirProvider); michael@0: michael@0: Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, true); michael@0: do_execute_soon(run_test_pt1); michael@0: } michael@0: michael@0: function xhr_pt1() { michael@0: gXHR.status = 200; michael@0: gXHR.responseText = gResponseBody; michael@0: try { michael@0: var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"]. michael@0: createInstance(AUS_Ci.nsIDOMParser); michael@0: gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml"); michael@0: } catch (e) { michael@0: gXHR.responseXML = null; michael@0: } michael@0: var e = { target: gXHR }; michael@0: gXHR.onload(e); michael@0: } michael@0: michael@0: function run_test_pt1() { michael@0: gUpdates = null; michael@0: gUpdateCount = null; michael@0: gCheckFunc = check_test_pt1; michael@0: michael@0: michael@0: let patches = getRemotePatchString(); michael@0: let updates = getRemoteUpdateString(patches); michael@0: gResponseBody = getRemoteUpdatesXMLString(updates); michael@0: gUpdateChecker.checkForUpdates(updateCheckListener, true); michael@0: } michael@0: michael@0: function check_test_pt1() { michael@0: do_check_eq(gUpdateCount, 1); michael@0: michael@0: gActiveUpdate = gUpdates[0]; michael@0: do_check_neq(gActiveUpdate, null); michael@0: michael@0: let state = gAUS.downloadUpdate(gActiveUpdate, true); michael@0: do_check_eq(state, "null"); michael@0: do_check_eq(gActiveUpdate.errorCode >>> 0 , AUS_Cr.NS_ERROR_FILE_TOO_BIG); michael@0: michael@0: doTestFinish(); michael@0: } michael@0: michael@0: function end_test() { michael@0: gDirService.unregisterProvider(gDirProvider); michael@0: gDirService.registerProvider(gOldProvider); michael@0: gActiveUpdate = null; michael@0: gDirService = null; michael@0: gDirProvider = null; michael@0: }