(test only change) Bug 493805 - Additional app update test cleanup. r=me

This commit is contained in:
Robert Strong 2009-05-19 13:24:12 -07:00
Родитель 460d1168c1
Коммит c40ee3cb9c
13 изменённых файлов: 176 добавлений и 158 удалений

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

@ -52,9 +52,9 @@ const PREF_APP_UPDATE_URL_OVERRIDE = "app.update.url.override";
const PREF_APP_UPDATE_SHOW_INSTALLED_UI = "app.update.showInstalledUI";
const URI_UPDATES_PROPERTIES = "chrome://mozapps/locale/update/updates.properties";
const gUpdateBundle = AUS_Cc["@mozilla.org/intl/stringbundle;1"]
.getService(AUS_Ci.nsIStringBundleService)
.createBundle(URI_UPDATES_PROPERTIES);
const gUpdateBundle = AUS_Cc["@mozilla.org/intl/stringbundle;1"].
getService(AUS_Ci.nsIStringBundleService).
createBundle(URI_UPDATES_PROPERTIES);
const STATE_NONE = "null";
const STATE_DOWNLOADING = "downloading";
@ -79,10 +79,9 @@ const PERMS_DIRECTORY = 0755;
const URL_HOST = "http://localhost:4444/"
const DIR_DATA = "data"
var gDirSvc = AUS_Cc["@mozilla.org/file/directory_service;1"]
.getService(AUS_Ci.nsIProperties);
var gPrefs = AUS_Cc["@mozilla.org/preferences;1"]
.getService(AUS_Ci.nsIPrefBranch);
var gDirSvc = AUS_Cc["@mozilla.org/file/directory_service;1"].
getService(AUS_Ci.nsIProperties);
var gAUS;
var gUpdateChecker;
var gUpdateManager;
@ -101,6 +100,37 @@ var gUpdates;
var gStatusCode;
var gStatusText;
function getPrefBranch() {
return AUS_Cc["@mozilla.org/preferences;1"].getService(AUS_Ci.nsIPrefBranch);
}
/**
* Nulls out the most commonly used global vars used by tests as appropriate.
* This is not in the tail file due to check-interactive executing the tail file
* prior to _execute_test();.
*/
function cleanUp() {
gDirSvc.unregisterProvider(dirProvider);
if (gXHR) {
gXHRCallback = null;
gXHR.responseXML = null;
// null out the event handlers to prevent a mFreeCount leak of 1
gXHR.onerror = null;
gXHR.onload = null;
gXHR.onprogress = null;
gXHR = null;
}
gUpdateManager = null;
gUpdateChecker = null;
gAUS = null;
gTestserver = null;
}
/**
* Initializes the most commonly used global vars used by tests and
* nsIApplicationUpdateService
@ -108,35 +138,36 @@ var gStatusText;
function startAUS() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1.0", "2.0");
var pb = getPrefBranch();
// Don't display UI for a successful installation. Some apps may not set this
// pref to false like Firefox does.
gPrefs.setBoolPref(PREF_APP_UPDATE_SHOW_INSTALLED_UI, false);
pb.setBoolPref(PREF_APP_UPDATE_SHOW_INSTALLED_UI, false);
// Enable Update logging
gPrefs.setBoolPref("app.update.log.all", true);
pb.setBoolPref("app.update.log.all", true);
// Lessens the noise in the logs when using Update Service logging
gPrefs.setBoolPref("app.update.enabled", false);
gPrefs.setBoolPref("extensions.blocklist.enabled", false);
gPrefs.setBoolPref("extensions.update.enabled", false);
gPrefs.setBoolPref("browser.search.update", false);
gPrefs.setBoolPref("browser.microsummary.updateGenerators", false);
pb.setBoolPref("app.update.enabled", false);
pb.setBoolPref("extensions.blocklist.enabled", false);
pb.setBoolPref("extensions.update.enabled", false);
pb.setBoolPref("browser.search.update", false);
pb.setBoolPref("browser.microsummary.updateGenerators", false);
gAUS = AUS_Cc["@mozilla.org/updates/update-service;1"]
.getService(AUS_Ci.nsIApplicationUpdateService);
var os = AUS_Cc["@mozilla.org/observer-service;1"]
.getService(AUS_Ci.nsIObserverService);
gAUS = AUS_Cc["@mozilla.org/updates/update-service;1"].
getService(AUS_Ci.nsIApplicationUpdateService);
var os = AUS_Cc["@mozilla.org/observer-service;1"].
getService(AUS_Ci.nsIObserverService);
os.notifyObservers(null, "profile-after-change", null);
}
/* Initializes nsIUpdateChecker */
function startUpdateChecker() {
gUpdateChecker = AUS_Cc["@mozilla.org/updates/update-checker;1"]
.createInstance(AUS_Ci.nsIUpdateChecker);
gUpdateChecker = AUS_Cc["@mozilla.org/updates/update-checker;1"].
createInstance(AUS_Ci.nsIUpdateChecker);
}
/* Initializes nsIUpdateManager */
function startUpdateManager() {
gUpdateManager = AUS_Cc["@mozilla.org/updates/update-manager;1"]
.getService(AUS_Ci.nsIUpdateManager);
gUpdateManager = AUS_Cc["@mozilla.org/updates/update-manager;1"].
getService(AUS_Ci.nsIUpdateManager);
}
/**
@ -386,8 +417,8 @@ function writeStatusFile(aStatus) {
* replaced.
*/
function writeFile(aFile, aText) {
var fos = AUS_Cc["@mozilla.org/network/safe-file-output-stream;1"]
.createInstance(AUS_Ci.nsIFileOutputStream);
var fos = AUS_Cc["@mozilla.org/network/safe-file-output-stream;1"].
createInstance(AUS_Ci.nsIFileOutputStream);
if (!aFile.exists())
aFile.create(AUS_Ci.nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE);
fos.init(aFile, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, PERMS_FILE, 0);
@ -412,8 +443,8 @@ function writeFile(aFile, aText) {
* @returns The string of text read from the file.
*/
function readFile(aFile) {
var fis = AUS_Cc["@mozilla.org/network/file-input-stream;1"]
.createInstance(AUS_Ci.nsIFileInputStream);
var fis = AUS_Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(AUS_Ci.nsIFileInputStream);
if (!aFile.exists())
return null;
fis.init(aFile, MODE_RDONLY, PERMS_FILE, 0);
@ -456,8 +487,8 @@ function getString(aName) {
* WARNING: unable to post SHUTDOWN message
*/
function toggleOffline(aOffline) {
const ioService = AUS_Cc["@mozilla.org/network/io-service;1"]
.getService(AUS_Ci.nsIIOService);
const ioService = AUS_Cc["@mozilla.org/network/io-service;1"].
getService(AUS_Ci.nsIIOService);
try {
ioService.manageOfflineStatus = !aOffline;
@ -505,9 +536,9 @@ xhr.prototype = {
_url: null,
_method: null,
open: function (method, url) {
gXHR.channel.originalURI = AUS_Cc["@mozilla.org/network/io-service;1"]
.getService(AUS_Ci.nsIIOService)
.newURI(url, null, null);
gXHR.channel.originalURI = AUS_Cc["@mozilla.org/network/io-service;1"].
getService(AUS_Ci.nsIIOService).
newURI(url, null, null);
gXHR._method = method; gXHR._url = url;
},
responseXML: null,
@ -629,58 +660,11 @@ function removeUpdateDirsAndFiles() {
"\nException: " + e + "\n");
}
var updatesSubDir = appDir.clone();
updatesSubDir.append("updates");
updatesSubDir.append("0");
if (updatesSubDir.exists()) {
file = updatesSubDir.clone();
file.append("update.mar");
try {
if (file.exists())
file.remove(false);
}
catch (e) {
dump("Unable to remove file\npath: " + file.path +
"\nException: " + e + "\n");
}
file = updatesSubDir.clone();
file.append("update.status");
try {
if (file.exists())
file.remove(false);
}
catch (e) {
dump("Unable to remove file\npath: " + file.path +
"\nException: " + e + "\n");
}
file = updatesSubDir.clone();
file.append("update.version");
try {
if (file.exists())
file.remove(false);
}
catch (e) {
dump("Unable to remove file\npath: " + file.path +
"\nException: " + e + "\n");
}
try {
updatesSubDir.remove(true);
}
catch (e) {
dump("Unable to remove directory\npath: " + updatesSubDir.path +
"\nException: " + e + "\n");
}
}
// This fails sporadically on Mac OS X so wrap it in a try catch
var updatesDir = appDir.clone();
updatesDir.append("updates");
try {
if (updatesDir.exists())
updatesDir.remove(true);
removeDirRecursive(updatesDir);
}
catch (e) {
dump("Unable to remove directory\npath: " + updatesDir.path +
@ -688,6 +672,37 @@ function removeUpdateDirsAndFiles() {
}
}
/**
* Deletes a directory and its children. First it tries nsIFile::Remove(true).
* If that fails it will fall back to recursing, setting the appropriate
* permissions, and deleting the current entry.
* @param dir
* A nsIFile for the directory to be deleted
*/
function removeDirRecursive(aDir) {
try {
aDir.remove(true);
return;
}
catch (e) {
}
var dirEntries = aDir.directoryEntries;
while (dirEntries.hasMoreElements()) {
var entry = dirEntries.getNext().QueryInterface(AUS_Ci.nsIFile);
if (entry.isDirectory()) {
removeDirRecursive(entry);
}
else {
entry.permissions = PERMS_FILE;
entry.remove(false);
}
}
aDir.permissions = PERMS_DIRECTORY;
aDir.remove(true);
}
/**
* Helper for starting the http server used by the tests
* @param aRelativeDirName

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

@ -36,22 +36,5 @@
* ***** END LICENSE BLOCK *****
*/
gDirSvc.unregisterProvider(dirProvider);
if (gXHR) {
gXHRCallback = null;
gXHR.responseXML = null;
// null out the event handlers to prevent a mFreeCount leak of 1
gXHR.onerror = null;
gXHR.onload = null;
gXHR.onprogress = null;
gXHR = null;
}
gUpdateManager = null;
gUpdateChecker = null;
gAUS = null;
gPrefs = null;
gTestserver = null;
// Not used since check-interactive executes this prior to _execute_test();
// being executed.

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

@ -53,4 +53,5 @@ function run_test() {
// Check if the update dir can be written to
dump("Testing: nsIApplicationUpdateService:canUpdate\n");
do_check_true(gAUS.canUpdate);
cleanUp();
}

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

@ -44,10 +44,9 @@ var gExpectedCount;
function run_test() {
do_test_pending();
removeUpdateDirsAndFiles();
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE,
URL_HOST + "update.xml");
var defaults = gPrefs.QueryInterface(AUS_Ci.nsIPrefService)
.getDefaultBranch(null);
var pb = getPrefBranch();
pb.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, URL_HOST + "update.xml");
var defaults = pb.QueryInterface(AUS_Ci.nsIPrefService).getDefaultBranch(null);
defaults.setCharPref("app.update.channel", "bogus_channel");
// The mock XMLHttpRequest is MUCH faster
overrideXHR(callHandleEvent);
@ -58,6 +57,7 @@ function run_test() {
function end_test() {
do_test_finished();
cleanUp();
}
// Helper function for testing update counts returned from an update xml
@ -82,8 +82,8 @@ function callHandleEvent() {
gXHR.status = 400;
gXHR.responseText = gResponseBody;
try {
var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"]
.createInstance(AUS_Ci.nsIDOMParser);
var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(AUS_Ci.nsIDOMParser);
gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
}
catch(e) {

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

@ -46,7 +46,7 @@ function run_test() {
do_test_pending();
removeUpdateDirsAndFiles();
// The mock XMLHttpRequest is MUCH faster
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, URL_HOST + "update.xml");
getPrefBranch().setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, URL_HOST + "update.xml");
overrideXHR(callHandleEvent);
startAUS();
startUpdateChecker();
@ -57,6 +57,7 @@ function run_test() {
function end_test() {
stop_httpserver(do_test_finished);
cleanUp();
}
// Callback function used by the custom XMLHttpRequest implemetation to
@ -65,8 +66,8 @@ function callHandleEvent() {
gXHR.status = 400;
gXHR.responseText = gResponseBody;
try {
var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"]
.createInstance(AUS_Ci.nsIDOMParser);
var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(AUS_Ci.nsIDOMParser);
gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
}
catch(e) {

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

@ -55,14 +55,15 @@ function run_test() {
overrideXHR(callHandleEvent);
startAUS();
startUpdateChecker();
gAppInfo = AUS_Cc["@mozilla.org/xre/app-info;1"]
.getService(AUS_Ci.nsIXULAppInfo)
.QueryInterface(AUS_Ci.nsIXULRuntime);
gAppInfo = AUS_Cc["@mozilla.org/xre/app-info;1"].
getService(AUS_Ci.nsIXULAppInfo).
QueryInterface(AUS_Ci.nsIXULRuntime);
do_timeout(0, "run_test_pt1()");
}
function end_test() {
do_test_finished();
cleanUp();
}
// Callback function used by the custom XMLHttpRequest implemetation to
@ -82,7 +83,7 @@ function run_test_pt1() {
gCheckFunc = check_test_pt1;
var url = URL_PREFIX + "%PRODUCT%/";
dump("Testing: url constructed with %PRODUCT% - " + url + "\n");
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
getPrefBranch().setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
gUpdateChecker.checkForUpdates(updateCheckListener, true);
}
@ -96,7 +97,7 @@ function run_test_pt2() {
gCheckFunc = check_test_pt2;
var url = URL_PREFIX + "%VERSION%/";
dump("Testing: url constructed with %VERSION% - " + url + "\n");
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
getPrefBranch().setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
gUpdateChecker.checkForUpdates(updateCheckListener, true);
}
@ -110,7 +111,7 @@ function run_test_pt3() {
gCheckFunc = check_test_pt3;
var url = URL_PREFIX + "%BUILD_ID%/";
dump("Testing: url constructed with %BUILD_ID% - " + url + "\n");
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
getPrefBranch().setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
gUpdateChecker.checkForUpdates(updateCheckListener, true);
}
@ -125,7 +126,7 @@ function run_test_pt4() {
gCheckFunc = check_test_pt4;
var url = URL_PREFIX + "%BUILD_TARGET%/";
dump("Testing: url constructed with %BUILD_TARGET% - " + url + "\n");
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
getPrefBranch().setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
gUpdateChecker.checkForUpdates(updateCheckListener, true);
}
@ -141,8 +142,8 @@ function check_test_pt4() {
// Mac universal build should report a different ABI than either macppc
// or mactel. This is necessary since nsUpdateService.js will set the ABI to
// Universal-gcc3 for Mac universal builds.
var macutils = AUS_Cc["@mozilla.org/xpcom/mac-utils;1"]
.getService(AUS_Ci.nsIMacUtils);
var macutils = AUS_Cc["@mozilla.org/xpcom/mac-utils;1"].
getService(AUS_Ci.nsIMacUtils);
if (macutils.isUniversalBinary)
abi = "Universal-gcc3";
@ -153,14 +154,21 @@ function check_test_pt4() {
}
// url constructed with %LOCALE%
// Bug 446527 added the locale to the updater.ini
// Bug 488936 added the locale to the updater.locale file
function run_test_pt5() {
gCheckFunc = check_test_pt5;
var url = URL_PREFIX + "%LOCALE%/";
dump("Testing: url constructed with %LOCALE% - " + url + "\n");
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
getPrefBranch().setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
try {
gUpdateChecker.checkForUpdates(updateCheckListener, true);
}
catch (e) {
dump("***\n*** The following error is most likely due to a missing " +
"update.locale file\n***\n");
do_throw(e);
}
}
function check_test_pt5() {
do_check_eq(getResult(gRequestURL), gInstallationLocale);
@ -172,9 +180,9 @@ function run_test_pt6() {
gCheckFunc = check_test_pt6;
var url = URL_PREFIX + "%CHANNEL%/";
dump("Testing: url constructed with %CHANNEL% - " + url + "\n");
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
var defaults = gPrefs.QueryInterface(AUS_Ci.nsIPrefService)
.getDefaultBranch(null);
var pb = getPrefBranch();
pb.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
var defaults = pb.QueryInterface(AUS_Ci.nsIPrefService).getDefaultBranch(null);
defaults.setCharPref(PREF_APP_UPDATE_CHANNEL, "bogus_channel");
gUpdateChecker.checkForUpdates(updateCheckListener, true);
}
@ -189,9 +197,9 @@ function run_test_pt7() {
gCheckFunc = check_test_pt7;
var url = URL_PREFIX + "%CHANNEL%/";
dump("Testing: url constructed with %CHANNEL% - " + url + "\n");
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
var defaults = gPrefs.QueryInterface(AUS_Ci.nsIPrefService)
.getDefaultBranch(null);
var pb = getPrefBranch();
pb.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
var defaults = pb.QueryInterface(AUS_Ci.nsIPrefService).getDefaultBranch(null);
defaults.setCharPref(PREF_PARTNER_BRANCH + "bogus_partner1", "bogus_partner1");
defaults.setCharPref(PREF_PARTNER_BRANCH + "bogus_partner2", "bogus_partner2");
gUpdateChecker.checkForUpdates(updateCheckListener, true);
@ -207,7 +215,7 @@ function run_test_pt8() {
gCheckFunc = check_test_pt8;
var url = URL_PREFIX + "%PLATFORM_VERSION%/";
dump("Testing: url constructed with %PLATFORM_VERSION% - " + url + "\n");
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
getPrefBranch().setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
gUpdateChecker.checkForUpdates(updateCheckListener, true);
}
@ -221,14 +229,14 @@ function run_test_pt9() {
gCheckFunc = check_test_pt9;
var url = URL_PREFIX + "%OS_VERSION%/";
dump("Testing: url constructed with %OS_VERSION% - " + url + "\n");
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
getPrefBranch().setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
gUpdateChecker.checkForUpdates(updateCheckListener, true);
}
function check_test_pt9() {
var osVersion;
var sysInfo = AUS_Cc["@mozilla.org/system-info;1"]
.getService(AUS_Ci.nsIPropertyBag2);
var sysInfo = AUS_Cc["@mozilla.org/system-info;1"].
getService(AUS_Ci.nsIPropertyBag2);
osVersion = sysInfo.getProperty("name") + " " + sysInfo.getProperty("version");
if (osVersion) {
@ -251,9 +259,9 @@ function run_test_pt10() {
gCheckFunc = check_test_pt10;
var url = URL_PREFIX + "%DISTRIBUTION%/";
dump("Testing: url constructed with %DISTRIBUTION% - " + url + "\n");
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
var defaults = gPrefs.QueryInterface(AUS_Ci.nsIPrefService)
.getDefaultBranch(null);
var pb = getPrefBranch();
pb.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
var defaults = pb.QueryInterface(AUS_Ci.nsIPrefService).getDefaultBranch(null);
defaults.setCharPref(PREF_APP_DISTRIBUTION, "bogus_distro");
gUpdateChecker.checkForUpdates(updateCheckListener, true);
}
@ -268,9 +276,9 @@ function run_test_pt11() {
gCheckFunc = check_test_pt11;
var url = URL_PREFIX + "%DISTRIBUTION_VERSION%/";
dump("Testing: url constructed with %DISTRIBUTION_VERSION% - " + url + "\n");
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
var defaults = gPrefs.QueryInterface(AUS_Ci.nsIPrefService)
.getDefaultBranch(null);
var pb = getPrefBranch();
pb.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
var defaults = pb.QueryInterface(AUS_Ci.nsIPrefService).getDefaultBranch(null);
defaults.setCharPref(PREF_APP_DISTRIBUTION_VERSION, "bogus_distro_version");
gUpdateChecker.checkForUpdates(updateCheckListener, true);
}
@ -285,7 +293,7 @@ function run_test_pt12() {
gCheckFunc = check_test_pt12;
var url = URL_PREFIX;
dump("Testing: url constructed that doesn't have a parameter - " + url + "\n");
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
getPrefBranch().setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
gUpdateChecker.checkForUpdates(updateCheckListener, true);
}
@ -299,7 +307,7 @@ function run_test_pt13() {
gCheckFunc = check_test_pt13;
var url = URL_PREFIX + "?bogus=param";
dump("Testing: url constructed that has a parameter - " + url + "\n");
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
getPrefBranch().setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, url);
gUpdateChecker.checkForUpdates(updateCheckListener, true);
}

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

@ -50,12 +50,14 @@ function run_test() {
removeUpdateDirsAndFiles();
startAUS();
startUpdateChecker();
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, URL_HOST + "update.xml");
getPrefBranch().setCharPref(PREF_APP_UPDATE_URL_OVERRIDE,
URL_HOST + "update.xml");
do_timeout(0, "run_test_pt1()");
}
function end_test() {
stop_httpserver(do_test_finished);
cleanUp();
}
// Custom error httpd handler used to return error codes we can't simulate

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

@ -51,13 +51,15 @@ function run_test() {
removeUpdateDirsAndFiles();
startAUS();
startUpdateChecker();
gPrefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, URL_HOST + "update.xml");
getPrefBranch().setCharPref(PREF_APP_UPDATE_URL_OVERRIDE,
URL_HOST + "update.xml");
overrideXHR(callHandleEvent);
do_timeout(0, "run_test_pt1()");
}
function end_test() {
do_test_finished();
cleanUp();
}
// Callback function used by the custom XMLHttpRequest implemetation to

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

@ -42,8 +42,8 @@ function run_test() {
dump("Testing: addition of a successful update to " + FILE_UPDATES_DB +
" and verification of update properties\n");
removeUpdateDirsAndFiles();
var defaults = gPrefs.QueryInterface(AUS_Ci.nsIPrefService)
.getDefaultBranch(null);
var defaults = getPrefBranch().QueryInterface(AUS_Ci.nsIPrefService).
getDefaultBranch(null);
defaults.setCharPref("app.update.channel", "bogus_channel");
var patches = getLocalPatchString(null, null, null, null, null, null,
@ -114,4 +114,5 @@ function run_test() {
do_check_eq(patch.size, "775");
do_check_true(patch.selected);
do_check_eq(patch.state, STATE_FAILED);
cleanUp();
}

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

@ -42,8 +42,8 @@ function run_test() {
dump("Testing: removal of an update download in progress for an older " +
"version of the application on startup - bug 485624\n");
removeUpdateDirsAndFiles();
var defaults = gPrefs.QueryInterface(AUS_Ci.nsIPrefService)
.getDefaultBranch(null);
var defaults = getPrefBranch().QueryInterface(AUS_Ci.nsIPrefService).
getDefaultBranch(null);
defaults.setCharPref("app.update.channel", "bogus_channel");
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
@ -59,4 +59,5 @@ function run_test() {
do_check_eq(gUpdateManager.activeUpdate, null);
do_check_eq(gUpdateManager.updateCount, 0);
cleanUp();
}

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

@ -42,8 +42,8 @@ function run_test() {
dump("Testing: resuming an update download in progress for the same " +
"version of the application on startup - bug 485624\n");
removeUpdateDirsAndFiles();
var defaults = gPrefs.QueryInterface(AUS_Ci.nsIPrefService)
.getDefaultBranch(null);
var defaults = getPrefBranch().QueryInterface(AUS_Ci.nsIPrefService).
getDefaultBranch(null);
defaults.setCharPref("app.update.channel", "bogus_channel");
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
@ -60,4 +60,5 @@ function run_test() {
do_check_eq(gUpdateManager.updateCount, 1);
do_check_eq(gUpdateManager.activeUpdate.state, STATE_DOWNLOADING);
cleanUp();
}

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

@ -122,6 +122,8 @@ function run_test() {
dump("Unable to remove directory\npath: " + updatesSubDir.path +
"\nException: " + e + "\n");
}
cleanUp();
}
// Launches the updater binary to apply a mar file
@ -144,8 +146,8 @@ function runUpdate(aUpdatesSubDir, aUpdater) {
if (/ /.test(updatesSubDirPath))
updatesSubDirPath = '"' + updatesSubDirPath + '"';
var process = AUS_Cc["@mozilla.org/process/util;1"]
.createInstance(AUS_Ci.nsIProcess);
var process = AUS_Cc["@mozilla.org/process/util;1"].
createInstance(AUS_Ci.nsIProcess);
process.init(updateBin);
var args = [updatesSubDirPath];
process.run(true, args, args.length);
@ -165,11 +167,11 @@ function getTestFile(aDir, aLeafName) {
// Returns the binary contents of a file
function getFileBytes(aFile) {
var fis = AUS_Cc["@mozilla.org/network/file-input-stream;1"]
.createInstance(AUS_Ci.nsIFileInputStream);
var fis = AUS_Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(AUS_Ci.nsIFileInputStream);
fis.init(aFile, -1, -1, false);
var bis = AUS_Cc["@mozilla.org/binaryinputstream;1"]
.createInstance(AUS_Ci.nsIBinaryInputStream);
var bis = AUS_Cc["@mozilla.org/binaryinputstream;1"].
createInstance(AUS_Ci.nsIBinaryInputStream);
bis.setInputStream(fis);
var data = bis.readBytes(bis.available());
bis.close();

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

@ -133,6 +133,7 @@ function run_test() {
}
removeUpdateDirsAndFiles();
cleanUp();
}
// Launches the updater binary to apply a mar file
@ -155,8 +156,8 @@ function runUpdate(aUpdatesSubDir, aUpdater) {
if (/ /.test(updatesSubDirPath))
updatesSubDirPath = '"' + updatesSubDirPath + '"';
var process = AUS_Cc["@mozilla.org/process/util;1"]
.createInstance(AUS_Ci.nsIProcess);
var process = AUS_Cc["@mozilla.org/process/util;1"].
createInstance(AUS_Ci.nsIProcess);
process.init(updateBin);
var args = [updatesSubDirPath];
process.run(true, args, args.length);
@ -176,11 +177,11 @@ function getTestFile(aDir, aLeafName) {
// Returns the binary contents of a file
function getFileBytes(aFile) {
var fis = AUS_Cc["@mozilla.org/network/file-input-stream;1"]
.createInstance(AUS_Ci.nsIFileInputStream);
var fis = AUS_Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(AUS_Ci.nsIFileInputStream);
fis.init(aFile, -1, -1, false);
var bis = AUS_Cc["@mozilla.org/binaryinputstream;1"]
.createInstance(AUS_Ci.nsIBinaryInputStream);
var bis = AUS_Cc["@mozilla.org/binaryinputstream;1"].
createInstance(AUS_Ci.nsIBinaryInputStream);
bis.setInputStream(fis);
var data = bis.readBytes(bis.available());
bis.close();