Bug 1149276 - Use Assert instead of do_check_ functions in xpcshell tests. r=spohl

This commit is contained in:
Robert Strong 2015-04-17 12:07:21 -07:00
Родитель 6df34d5d43
Коммит a2d87cd2f7
89 изменённых файлов: 1291 добавлений и 1443 удалений

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

@ -77,6 +77,11 @@ const ERR_BACKUP_DISCARD = "backup_discard: unable to remove";
const LOG_SVC_SUCCESSFUL_LAUNCH = "Process was started... waiting on result.";
// Typical end of a message when calling assert
const MSG_SHOULD_EQUAL = " should equal the expected value";
const MSG_SHOULD_EXIST = "the file or directory should exist";
const MSG_SHOULD_NOT_EXIST = "the file or directory should not exist";
// All we care about is that the last modified time has changed so that Mac OS
// X Launch Services invalidates its cache so the test allows up to one minute
// difference in the last modified time.
@ -757,8 +762,9 @@ function setupTestCommon() {
do_test_pending();
Assert.strictEqual(gTestID, undefined, "gTestID should be 'undefined' (" +
"setupTestCommon should only be called once)");
Assert.strictEqual(gTestID, undefined,
"gTestID should be 'undefined' (setupTestCommon should " +
"only be called once)");
let caller = Components.stack.caller;
gTestID = caller.filename.toString().split("/").pop().split(".")[0];
@ -775,7 +781,7 @@ function setupTestCommon() {
}
do_throw("The parallel run of this test failed. Failing non-parallel " +
"test so the log from the parallel run can be displayed in " +
"non-parallel log.")
"non-parallel log.");
} else {
gRealDump = dump;
dump = dumpOverride;
@ -1045,6 +1051,56 @@ function preventDistributionFiles() {
});
}
/**
* On Mac OS X this sets the last modified time for the app bundle directory to
* a date in the past to test that the last modified time is updated when an
* update has been successfully applied (bug 600098).
*/
function setAppBundleModTime() {
if (!IS_MACOSX) {
return;
}
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
/**
* On Mac OS X this checks that the last modified time for the app bundle
* directory has been updated when an update has been successfully applied
* (bug 600098).
*/
function checkAppBundleModTime() {
if (!IS_MACOSX) {
return;
}
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
Assert.ok(timeDiff < MAC_MAX_TIME_DIFFERENCE,
"the last modified time on the apply to directory should " +
"change after a successful update");
}
/**
* On Mac OS X and Windows this checks if the post update '.running' file exists
* to determine if the post update binary was launched.
*
* @param aShouldExist
* Whether the post update '.running' file should exist.
*/
function checkPostUpdateRunningFile(aShouldExist) {
if (!IS_WIN && !IS_MACOSX) {
return;
}
let postUpdateRunningFile = getPostUpdateFile(".running");
if (aShouldExist) {
Assert.ok(postUpdateRunningFile.exists(), MSG_SHOULD_EXIST);
} else {
Assert.ok(!postUpdateRunningFile.exists(), MSG_SHOULD_NOT_EXIST);
}
}
/**
* Initializes the most commonly used settings and creates an instance of the
@ -1086,7 +1142,7 @@ function getAppVersion() {
iniFile = gGREBinDirOrig.clone();
iniFile.append(FILE_APPLICATION_INI);
}
Assert.ok(iniFile.exists(), "the application.ini file should exist");
Assert.ok(iniFile.exists(), MSG_SHOULD_EXIST);
let iniParser = Cc["@mozilla.org/xpcom/ini-parser-factory;1"].
getService(Ci.nsIINIParserFactory).
createINIParser(iniFile);
@ -1171,7 +1227,7 @@ function getStageDirFile(aRelPath, aAllowNonexistent) {
}
}
if (!aAllowNonexistent) {
Assert.ok(file.exists(), file.path + " should exist");
Assert.ok(file.exists(), MSG_SHOULD_EXIST);
}
return file;
}
@ -1425,9 +1481,9 @@ function lockDirectory(aDir) {
file.QueryInterface(Ci.nsILocalFileWin);
file.fileAttributesWin |= file.WFA_READONLY;
file.fileAttributesWin &= ~file.WFA_READWRITE;
debugDump("testing the successful creation of the lock file");
do_check_true(file.exists());
do_check_false(file.isWritable());
Assert.ok(file.exists(), MSG_SHOULD_EXIST);
Assert.ok(!file.isWritable(),
"the lock file should not be writeable");
}
/**
* Helper function for unlocking a directory on Windows.
@ -1444,9 +1500,8 @@ function unlockDirectory(aDir) {
file.QueryInterface(Ci.nsILocalFileWin);
file.fileAttributesWin |= file.WFA_READWRITE;
file.fileAttributesWin &= ~file.WFA_READONLY;
debugDump("removing and testing the successful removal of the lock file");
file.remove(false);
do_check_false(file.exists());
Assert.ok(!file.exists(), MSG_SHOULD_NOT_EXIST);
}
/**
@ -1470,10 +1525,10 @@ function runUpdate(aExpectedExitValue, aExpectedStatus, aCallback) {
if (!updater.exists()) {
updater = getTestDirFile(FILE_UPDATER_BIN);
if (!updater.exists()) {
do_throw("Unable to find updater binary!");
do_throw("Unable to find the updater binary!");
}
}
Assert.ok(updater.exists(), "updater or updater.app should exist");
Assert.ok(updater.exists(), MSG_SHOULD_EXIST);
let updatesDir = getUpdatesPatchDir();
updater.copyToFollowingLinks(updatesDir, updater.leafName);
@ -1483,7 +1538,7 @@ function runUpdate(aExpectedExitValue, aExpectedStatus, aCallback) {
updateBin.append("Contents");
updateBin.append("MacOS");
updateBin.append("updater");
Assert.ok(updateBin.exists(), updateBin.path + " should exist");
Assert.ok(updateBin.exists(), MSG_SHOULD_EXIST);
}
let applyToDir = getApplyDirFile(null, true);
@ -1553,11 +1608,10 @@ function runUpdate(aExpectedExitValue, aExpectedStatus, aCallback) {
logTestInfo(aLine);
});
}
debugDump("testing updater binary process exitValue against expected " +
"exit value");
do_check_eq(process.exitValue, aExpectedExitValue);
debugDump("testing update status against expected status");
do_check_eq(status, aExpectedStatus);
Assert.equal(process.exitValue, aExpectedExitValue,
"the process exit value" + MSG_SHOULD_EQUAL);
Assert.equal(status, aExpectedStatus,
"the update status" + MSG_SHOULD_EQUAL);
if (aCallback !== null) {
if (typeof(aCallback) == typeof(Function)) {
@ -1597,7 +1651,7 @@ function shouldRunServiceTest(aFirstTest) {
let binDir = getGREBinDir();
let updaterBin = binDir.clone();
updaterBin.append(FILE_UPDATER_BIN);
Assert.ok(updaterBin.exists(), updaterBin.path + " should exist");
Assert.ok(updaterBin.exists(), MSG_SHOULD_EXIST);
let updaterBinPath = updaterBin.path;
if (/ /.test(updaterBinPath)) {
@ -1618,9 +1672,10 @@ function shouldRunServiceTest(aFirstTest) {
// in which case we should fail the test if the updater binary is signed so
// the build system can be fixed by adding the registry key.
if (IS_AUTHENTICODE_CHECK_ENABLED) {
Assert.ok(!isBinSigned, "the updater.exe binary should not be signed " +
"when the test registry key doesn't exist (if it is, build " +
"system configuration bug?)");
Assert.ok(!isBinSigned,
"the updater.exe binary should not be signed when the test " +
"registry key doesn't exist (if it is, build system " +
"configuration bug?)");
}
logTestInfo("this test can only run on the buildbot build system at this " +
@ -1634,7 +1689,6 @@ function shouldRunServiceTest(aFirstTest) {
let process = Cc["@mozilla.org/process/util;1"].
createInstance(Ci.nsIProcess);
process.init(helperBin);
debugDump("checking if the service exists on this machine.");
process.run(true, args, args.length);
Assert.notEqual(process.exitValue, 0xEE, "the maintenance service should " +
"be installed (if not, build system configuration bug?)");
@ -1643,16 +1697,17 @@ function shouldRunServiceTest(aFirstTest) {
// service should be anything but stopped, so be strict here and fail the
// test.
if (aFirstTest) {
Assert.equal(process.exitValue, 0, "service should not be running for " +
"the first test");
Assert.equal(process.exitValue, 0,
"the service should not be running for the first test");
}
if (IS_AUTHENTICODE_CHECK_ENABLED) {
// The test registry key exists and IS_AUTHENTICODE_CHECK_ENABLED is true
// so the binaries should be signed. To run the test locally
// DISABLE_UPDATER_AUTHENTICODE_CHECK can be defined.
Assert.ok(isBinSigned, "the updater.exe binary should be signed (if not, " +
"build system configuration bug?)");
Assert.ok(isBinSigned,
"the updater.exe binary should be signed (if not, build system " +
"configuration bug?)");
}
// In case the machine is running an old maintenance service or if it
@ -1768,10 +1823,10 @@ function setupAppFiles() {
if (!updater.exists()) {
updater = getTestDirFile(FILE_UPDATER_BIN);
if (!updater.exists()) {
do_throw("Unable to find updater binary!");
do_throw("Unable to find the updater binary!");
}
}
let testBinDir = getGREBinDir()
let testBinDir = getGREBinDir();
updater.copyToFollowingLinks(testBinDir, updater.leafName);
debugDump("finish - copying or creating symlinks to application files " +
@ -1822,7 +1877,7 @@ function copyFileToTestAppDir(aFileRelPath, aInGreDir) {
fileRelPath = fileRelPath + ".app";
}
Assert.ok(srcFile.exists(), srcFile.path + " should exist");
Assert.ok(srcFile.exists(), MSG_SHOULD_EXIST);
// Symlink libraries. Note that the XUL library on Mac OS X doesn't have a
// file extension and shouldSymlink will always be false on Windows.
@ -1858,8 +1913,8 @@ function copyFileToTestAppDir(aFileRelPath, aInGreDir) {
process.init(ln);
let args = ["-s", srcFile.path, destFile.path];
process.run(true, args, args.length);
debugDump("verifying symlink. Path: " + destFile.path);
do_check_true(destFile.isSymlink());
Assert.ok(destFile.isSymlink(),
"the file should be a symlink");
} catch (e) {
do_throw("Unable to create symlink for file! Path: " + srcFile.path +
", Exception: " + e);
@ -1891,14 +1946,13 @@ function attemptServiceInstall() {
"directory path: " + maintSvcDir.path);
}
}
Assert.ok(!!maintSvcDir, "maintenance service install directory should " +
"exist");
Assert.ok(maintSvcDir.exists(), "maintenance service install directory " +
"should exist");
if (!maintSvcDir) {
do_throw("Unable to find the maintenance service install directory");
}
Assert.ok(maintSvcDir.exists(), MSG_SHOULD_EXIST);
let oldMaintSvcBin = maintSvcDir.clone();
oldMaintSvcBin.append(FILE_MAINTENANCE_SERVICE_BIN);
Assert.ok(oldMaintSvcBin.exists(), "maintenance service install directory " +
"binary should exist. Path: " + oldMaintSvcBin.path);
Assert.ok(oldMaintSvcBin.exists(), MSG_SHOULD_EXIST);
let buildMaintSvcBin = getGREBinDir();
buildMaintSvcBin.append(FILE_MAINTENANCE_SERVICE_BIN);
if (readFileBytes(oldMaintSvcBin) == readFileBytes(buildMaintSvcBin)) {
@ -1926,7 +1980,7 @@ function attemptServiceInstall() {
}
Assert.ok(false, "should be able copy the test maintenance service to " +
"the maintenance service directory (if not, build system " +
"configuration bug?). Path: " + maintSvcDir.path);
"configuration bug?), path: " + maintSvcDir.path);
}
return true;
@ -1947,9 +2001,12 @@ function runUpdateUsingService(aInitialStatus, aExpectedStatus, aCheckSvcLog) {
// Check the service logs for a successful update
function checkServiceLogs(aOriginalContents) {
let contents = readServiceLogFile();
debugDump("the contents of maintenanceservice.log:\n" + contents + "\n");
do_check_neq(contents, aOriginalContents);
do_check_neq(contents.indexOf(LOG_SVC_SUCCESSFUL_LAUNCH), -1);
Assert.notEqual(contents, aOriginalContents,
"the contents of the maintenanceservice.log should not " +
"be the same as the original contents");
Assert.notEqual(contents.indexOf(LOG_SVC_SUCCESSFUL_LAUNCH), -1,
"the contents of the maintenanceservice.log should " +
"contain the successful launch string");
}
function readServiceLogFile() {
let file = Cc["@mozilla.org/file/directory_service;1"].
@ -1982,17 +2039,17 @@ function runUpdateUsingService(aInitialStatus, aExpectedStatus, aCheckSvcLog) {
helperBinProcess.init(helperBin);
debugDump("stopping service...");
helperBinProcess.run(true, helperBinArgs, helperBinArgs.length);
Assert.notEqual(helperBinProcess.exitValue, 0xEE, "the maintenance " +
"service should exist");
Assert.notEqual(helperBinProcess.exitValue, 0xEE,
"the maintenance service should exist");
if (helperBinProcess.exitValue != 0) {
if (aFailTest) {
Assert.ok(false, "maintenance service should stop! Process " +
"exitValue: " + helperBinProcess.exitValue);
Assert.ok(false, "the maintenance service should stop, process exit " +
"value: " + helperBinProcess.exitValue);
}
logTestInfo("maintenance service did not stop which may cause test " +
"failures later. Process exitValue: " +
"failures later, process exit value: " +
helperBinProcess.exitValue);
} else {
debugDump("service stopped");
@ -2011,8 +2068,9 @@ function runUpdateUsingService(aInitialStatus, aExpectedStatus, aCheckSvcLog) {
createInstance(Ci.nsIProcess);
helperBinProcess.init(helperBin);
helperBinProcess.run(true, helperBinArgs, helperBinArgs.length);
Assert.equal(helperBinProcess.exitValue, 0, "the process for " +
aApplication + " should stop");
Assert.equal(helperBinProcess.exitValue, 0,
"the process should have stopped, process name: " +
aApplication);
}
// Make sure the service from the previous test is already stopped.
@ -2047,7 +2105,8 @@ function runUpdateUsingService(aInitialStatus, aExpectedStatus, aCheckSvcLog) {
writeStatusFile(aInitialStatus);
// sanity check
do_check_eq(readStatusState(), aInitialStatus);
Assert.equal(readStatusState(), aInitialStatus,
"the update status state" + MSG_SHOULD_EQUAL);
writeVersionFile(DEFAULT_UPDATE_VERSION);
@ -2067,9 +2126,9 @@ function runUpdateUsingService(aInitialStatus, aExpectedStatus, aCheckSvcLog) {
let updater = getTestDirFile(FILE_UPDATER_BIN);
if (!updater.exists()) {
do_throw("Unable to find updater binary!");
do_throw("Unable to find the updater binary!");
}
let testBinDir = getGREBinDir()
let testBinDir = getGREBinDir();
updater.copyToFollowingLinks(testBinDir, updater.leafName);
updater.copyToFollowingLinks(updatesDir, updater.leafName);
@ -2129,8 +2188,8 @@ function runUpdateUsingService(aInitialStatus, aExpectedStatus, aCheckSvcLog) {
logTestInfo(aLine);
});
}
debugDump("testing update status against expected status");
do_check_eq(status, aExpectedStatus);
Assert.equal(status, aExpectedStatus,
"the update status" + MSG_SHOULD_EQUAL);
if (aCheckSvcLog) {
checkServiceLogs(svcOriginalLog);
@ -2162,7 +2221,7 @@ function getLaunchBin() {
createInstance(Ci.nsILocalFile);
launchBin.initWithPath("/bin/sh");
}
Assert.ok(launchBin.exists(), launchBin.path + " should exist");
Assert.ok(launchBin.exists(), MSG_SHOULD_EXIST);
return launchBin;
}
@ -2289,8 +2348,8 @@ function setupUpdaterTest(aMarFile) {
writeFile(testFile, aTestFile.originalContents);
}
// Skip these tests on Windows and OS/2 since their
// implementaions of chmod doesn't really set permissions.
// Skip these tests on Windows since chmod doesn't really set permissions
// on Windows.
if (!IS_WIN && aTestFile.originalPerms) {
testFile.permissions = aTestFile.originalPerms;
// Store the actual permissions on the file for reference later after
@ -2490,10 +2549,9 @@ function checkUpdateLogContents(aCompareLogFile, aExcludeDistributionDir) {
// Don't write the contents of the file to the log to reduce log spam
// unless there is a failure.
if (compareLogContents == updateLogContents) {
debugDump("log contents are correct");
do_check_true(true);
Assert.ok(true, "the update log contents" + MSG_SHOULD_EQUAL);
} else {
logTestInfo("log contents are not correct");
logTestInfo("the update log contents are not correct");
let aryLog = updateLogContents.split("\n");
let aryCompare = compareLogContents.split("\n");
// Pushing an empty string to both arrays makes it so either array's length
@ -2503,13 +2561,15 @@ function checkUpdateLogContents(aCompareLogFile, aExcludeDistributionDir) {
// xpcshell tests won't display the entire contents so log the incorrect
// line.
for (let i = 0; i < aryLog.length; ++i) {
if (aryCompare[i] != aryLog[i]) {
logTestInfo("the first incorrect line in the log is: " + aryLog[i]);
do_check_eq(aryCompare[i], aryLog[i]);
if (aryLog[i] != aryCompare[i]) {
logTestInfo("the first incorrect line in the update log is: " +
aryLog[i]);
Assert.equal(aryLog[i], aryCompare[i],
"the update log contents" + MSG_SHOULD_EQUAL);
}
}
// This should never happen!
do_throw("Unable to find incorrect log contents!");
do_throw("Unable to find incorrect update log contents!");
}
}
@ -2523,13 +2583,9 @@ function checkUpdateLogContains(aCheckString) {
let updateLog = getUpdatesPatchDir();
updateLog.append(FILE_UPDATE_LOG);
let updateLogContents = readFileBytes(updateLog);
if (updateLogContents.indexOf(aCheckString) != -1) {
debugDump("log file does contain: " + aCheckString);
do_check_true(true);
} else {
logTestInfo("log file does not contain: " + aCheckString);
do_check_true(false);
}
Assert.notEqual(updateLogContents.indexOf(aCheckString), -1,
"the update log contents" + MSG_SHOULD_EQUAL + ", value: " +
aCheckString);
}
/**
@ -2554,21 +2610,15 @@ function checkFilesAfterUpdateSuccess(aGetFileFunc, aStageDirExists,
let testFile = aGetFileFunc(aTestFile.relPathDir + aTestFile.fileName, true);
debugDump("testing file: " + testFile.path);
if (aTestFile.compareFile || aTestFile.compareContents) {
do_check_true(testFile.exists());
Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
// Skip these tests on Windows and OS/2 since their
// implementaions of chmod doesn't really set permissions.
// Skip these tests on Windows since chmod doesn't really set permissions
// on Windows.
if (!IS_WIN && aTestFile.comparePerms) {
// Check if the permssions as set in the complete mar file are correct.
let logPerms = "testing file permissions - ";
if (aTestFile.originalPerms) {
logPerms += "original permissions: " +
aTestFile.originalPerms.toString(8) + ", ";
}
debugDump("compare permissions : " +
aTestFile.comparePerms.toString(8) + ", " +
"updated permissions : " + testFile.permissions.toString(8));
do_check_eq(testFile.permissions & 0xfff, aTestFile.comparePerms & 0xfff);
Assert.equal(testFile.permissions & 0xfff,
aTestFile.comparePerms & 0xfff,
"the file permissions" + MSG_SHOULD_EQUAL);
}
let fileContents1 = readFileBytes(testFile);
@ -2578,14 +2628,13 @@ function checkFilesAfterUpdateSuccess(aGetFileFunc, aStageDirExists,
// Don't write the contents of the file to the log to reduce log spam
// unless there is a failure.
if (fileContents1 == fileContents2) {
debugDump("file contents are correct");
do_check_true(true);
Assert.ok(true, "the file contents" + MSG_SHOULD_EQUAL);
} else {
logTestInfo("file contents are not correct");
do_check_eq(fileContents1, fileContents2);
Assert.equal(fileContents1, fileContents2,
"the file contents" + MSG_SHOULD_EQUAL);
}
} else {
do_check_false(testFile.exists());
Assert.ok(!testFile.exists(), MSG_SHOULD_NOT_EXIST);
}
});
@ -2595,18 +2644,17 @@ function checkFilesAfterUpdateSuccess(aGetFileFunc, aStageDirExists,
let testDir = aGetFileFunc(aTestDir.relPathDir, true);
debugDump("testing directory: " + testDir.path);
if (aTestDir.dirRemoved) {
do_check_false(testDir.exists());
Assert.ok(!testDir.exists(), MSG_SHOULD_NOT_EXIST);
} else {
do_check_true(testDir.exists());
Assert.ok(testDir.exists(), MSG_SHOULD_EXIST);
if (aTestDir.files) {
aTestDir.files.forEach(function CFAUS_TD_F_FE(aTestFile) {
let testFile = aGetFileFunc(aTestDir.relPathDir + aTestFile, true);
debugDump("testing directory file: " + testFile.path);
if (aTestDir.filesRemoved) {
do_check_false(testFile.exists());
Assert.ok(!testFile.exists(), MSG_SHOULD_NOT_EXIST);
} else {
do_check_true(testFile.exists());
Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
}
});
}
@ -2614,14 +2662,12 @@ function checkFilesAfterUpdateSuccess(aGetFileFunc, aStageDirExists,
if (aTestDir.subDirs) {
aTestDir.subDirs.forEach(function CFAUS_TD_SD_FE(aSubDir) {
let testSubDir = aGetFileFunc(aTestDir.relPathDir + aSubDir, true);
debugDump("testing sub-directory: " + testSubDir.path);
do_check_true(testSubDir.exists());
Assert.ok(testSubDir.exists(), MSG_SHOULD_EXIST);
if (aTestDir.subDirFiles) {
aTestDir.subDirFiles.forEach(function CFAUS_TD_SDF_FE(aTestFile) {
let testFile = aGetFileFunc(aTestDir.relPathDir +
aSubDir + aTestFile, true);
debugDump("testing sub-directory file: " + testFile.path);
do_check_true(testFile.exists());
Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
});
}
});
@ -2655,21 +2701,15 @@ function checkFilesAfterUpdateFailure(aGetFileFunc, aStageDirExists,
let testFile = aGetFileFunc(aTestFile.relPathDir + aTestFile.fileName, true);
debugDump("testing file: " + testFile.path);
if (aTestFile.compareFile || aTestFile.compareContents) {
do_check_true(testFile.exists());
Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
// Skip these tests on Windows and OS/2 since their
// implementaions of chmod doesn't really set permissions.
// Skip these tests on Windows since chmod doesn't really set permissions
// on Windows.
if (!IS_WIN && aTestFile.comparePerms) {
// Check the original permssions are retained on the file.
let logPerms = "testing file permissions - ";
if (aTestFile.originalPerms) {
logPerms += "original permissions: " +
aTestFile.originalPerms.toString(8) + ", ";
}
debugDump("compare permissions : " +
aTestFile.comparePerms.toString(8) + ", " +
"updated permissions : " + testFile.permissions.toString(8));
do_check_eq(testFile.permissions & 0xfff, aTestFile.comparePerms & 0xfff);
Assert.equal(testFile.permissions & 0xfff,
aTestFile.comparePerms & 0xfff,
"the file permissions" + MSG_SHOULD_EQUAL);
}
let fileContents1 = readFileBytes(testFile);
@ -2679,14 +2719,13 @@ function checkFilesAfterUpdateFailure(aGetFileFunc, aStageDirExists,
// Don't write the contents of the file to the log to reduce log spam
// unless there is a failure.
if (fileContents1 == fileContents2) {
debugDump("file contents are correct");
do_check_true(true);
Assert.ok(true, "the file contents" + MSG_SHOULD_EQUAL);
} else {
logTestInfo("file contents are not correct");
do_check_eq(fileContents1, fileContents2);
Assert.equal(fileContents1, fileContents2,
"the file contents" + MSG_SHOULD_EQUAL);
}
} else {
do_check_false(testFile.exists());
Assert.ok(!testFile.exists(), MSG_SHOULD_NOT_EXIST);
}
});
@ -2694,28 +2733,24 @@ function checkFilesAfterUpdateFailure(aGetFileFunc, aStageDirExists,
"performed after a failed update");
gTestDirs.forEach(function CFAUF_TD_FE(aTestDir) {
let testDir = aGetFileFunc(aTestDir.relPathDir, true);
debugDump("testing directory: " + testDir.path);
do_check_true(testDir.exists());
Assert.ok(testDir.exists(), MSG_SHOULD_EXIST);
if (aTestDir.files) {
aTestDir.files.forEach(function CFAUS_TD_F_FE(aTestFile) {
let testFile = aGetFileFunc(aTestDir.relPathDir + aTestFile, true);
debugDump("testing directory file: " + testFile.path);
do_check_true(testFile.exists());
Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
});
}
if (aTestDir.subDirs) {
aTestDir.subDirs.forEach(function CFAUS_TD_SD_FE(aSubDir) {
let testSubDir = aGetFileFunc(aTestDir.relPathDir + aSubDir, true);
debugDump("testing sub-directory: " + testSubDir.path);
do_check_true(testSubDir.exists());
Assert.ok(testSubDir.exists(), MSG_SHOULD_EXIST);
if (aTestDir.subDirFiles) {
aTestDir.subDirFiles.forEach(function CFAUS_TD_SDF_FE(aTestFile) {
let testFile = aGetFileFunc(aTestDir.relPathDir +
aSubDir + aTestFile, true);
debugDump("testing sub-directory file: " + testFile.path);
do_check_true(testFile.exists());
Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
});
}
});
@ -2744,31 +2779,28 @@ function checkFilesAfterUpdateFailure(aGetFileFunc, aStageDirExists,
function checkFilesAfterUpdateCommon(aGetFileFunc, aStageDirExists,
aToBeDeletedDirExists) {
debugDump("testing extra directories");
let stageDir = getStageDirFile(null, true);
debugDump("testing directory should " +
(aStageDirExists ? "" : "not ") +
"exist: " + stageDir.path);
do_check_eq(stageDir.exists(), aStageDirExists);
if (aStageDirExists) {
Assert.ok(stageDir.exists(), MSG_SHOULD_EXIST);
} else {
Assert.ok(!stageDir.exists(), MSG_SHOULD_NOT_EXIST);
}
let toBeDeletedDirExists = IS_WIN ? aToBeDeletedDirExists : false;
let toBeDeletedDir = getApplyDirFile(DIR_TOBEDELETED, true);
debugDump("testing directory should " +
(toBeDeletedDirExists ? "" : "not ") +
"exist: " + toBeDeletedDir.path);
do_check_eq(toBeDeletedDir.exists(), toBeDeletedDirExists);
if (toBeDeletedDirExists) {
Assert.ok(toBeDeletedDir.exists(), MSG_SHOULD_EXIST);
} else {
Assert.ok(!toBeDeletedDir.exists(), MSG_SHOULD_NOT_EXIST);
}
debugDump("testing updating directory doesn't exist in the application " +
"directory");
let updatingDir = getApplyDirFile("updating", true);
do_check_false(updatingDir.exists());
Assert.ok(!updatingDir.exists(), MSG_SHOULD_NOT_EXIST);
if (stageDir.exists()) {
debugDump("testing updating directory doesn't exist in the staging " +
"directory");
updatingDir = stageDir.clone();
updatingDir.append("updating");
do_check_false(updatingDir.exists());
Assert.ok(!updatingDir.exists(), MSG_SHOULD_NOT_EXIST);
}
debugDump("testing backup files should not be left behind in the " +
@ -2788,7 +2820,8 @@ function checkFilesAfterUpdateCommon(aGetFileFunc, aStageDirExists,
let entries = updatesDir.QueryInterface(Ci.nsIFile).directoryEntries;
while (entries.hasMoreElements()) {
let entry = entries.getNext().QueryInterface(Ci.nsIFile);
do_check_neq(getFileExtension(entry), "patch");
Assert.notEqual(getFileExtension(entry), "patch",
"the file's extension should not equal patch");
}
}
@ -2809,19 +2842,35 @@ function checkCallbackAppLog() {
// It is possible for the log file contents check to occur before the log file
// contents are completely written so wait until the contents are the expected
// value. If the contents are never the expected value then the test will
// fail by timing out.
// fail by timing out after gTimeoutRuns is greater than MAX_TIMEOUT_RUNS or
// the test harness times out the test.
if (logContents != expectedLogContents) {
gTimeoutRuns++;
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
logTestInfo("callback log contents are not correct");
let aryLog = logContents.split("\n");
let aryCompare = expectedLogContents.split("\n");
// Pushing an empty string to both arrays makes it so either array's length
// can be used in the for loop below without going out of bounds.
aryLog.push("");
aryCompare.push("");
// xpcshell tests won't display the entire contents so log the incorrect
// line.
for (let i = 0; i < aryLog.length; ++i) {
if (aryLog[i] != aryCompare[i]) {
logTestInfo("the first incorrect line in the callback log is: " +
aryLog[i]);
Assert.equal(aryLog[i], aryCompare[i],
"the callback log contents" + MSG_SHOULD_EQUAL);
}
}
// This should never happen!
do_throw("Unable to find incorrect callback log contents!");
}
do_timeout(TEST_HELPER_TIMEOUT, checkCallbackAppLog);
return;
}
if (logContents == expectedLogContents) {
debugDump("callback log file contents are correct");
do_check_true(true);
} else {
debugDump("callback log file contents are not correct");
do_check_eq(logContents, expectedLogContents);
}
Assert.ok(true, "the callback log contents" + MSG_SHOULD_EQUAL);
waitForFilesInUse();
}
@ -2860,7 +2909,8 @@ function checkPostUpdateAppLog() {
// It is possible for the log file contents check to occur before the log file
// contents are completely written so wait until the contents are the expected
// value. If the contents are never the expected value then the test will
// fail by timing out.
// fail by timing out after gTimeoutRuns is greater than MAX_TIMEOUT_RUNS or
// the test harness times out the test.
if (logContents != "post-update\n") {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the post update " +
@ -2870,9 +2920,7 @@ function checkPostUpdateAppLog() {
do_timeout(TEST_HELPER_TIMEOUT, checkPostUpdateAppLog);
return;
}
debugDump("post update app log file contents are correct");
do_check_true(true);
Assert.ok(true, "the post update log contents" + MSG_SHOULD_EQUAL);
gCheckFunc();
}
@ -2883,7 +2931,8 @@ function checkPostUpdateAppLog() {
* the callback application.
*/
function checkCallbackServiceLog() {
do_check_neq(gServiceLaunchedCallbackLog, null);
Assert.ok(!!gServiceLaunchedCallbackLog,
"gServiceLaunchedCallbackLog should be defined");
let expectedLogContents = gServiceLaunchedCallbackArgs.join("\n") + "\n";
let logFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
@ -2892,16 +2941,35 @@ function checkCallbackServiceLog() {
// It is possible for the log file contents check to occur before the log file
// contents are completely written so wait until the contents are the expected
// value. If the contents are never the expected value then the test will
// fail by timing out.
// fail by timing out after gTimeoutRuns is greater than MAX_TIMEOUT_RUNS or
// the test harness times out the test.
if (logContents != expectedLogContents) {
debugDump("callback service log not expected value, waiting longer");
gTimeoutRuns++;
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
logTestInfo("callback service log contents are not correct");
let aryLog = logContents.split("\n");
let aryCompare = expectedLogContents.split("\n");
// Pushing an empty string to both arrays makes it so either array's length
// can be used in the for loop below without going out of bounds.
aryLog.push("");
aryCompare.push("");
// xpcshell tests won't display the entire contents so log the incorrect
// line.
for (let i = 0; i < aryLog.length; ++i) {
if (aryLog[i] != aryCompare[i]) {
logTestInfo("the first incorrect line in the service callback log " +
"is: " + aryLog[i]);
Assert.equal(aryLog[i], aryCompare[i],
"the service callback log contents" + MSG_SHOULD_EQUAL);
}
}
// This should never happen!
do_throw("Unable to find incorrect service callback log contents!");
}
do_timeout(TEST_HELPER_TIMEOUT, checkCallbackServiceLog);
return;
}
debugDump("testing that the callback application successfully launched " +
"and the expected command line arguments were passed to it");
do_check_eq(logContents, expectedLogContents);
Assert.ok(true, "the callback service log contents" + MSG_SHOULD_EQUAL);
waitForFilesInUse();
}
@ -2961,7 +3029,8 @@ function waitForFilesInUse() {
* An nsIFile to check if it has moz-backup for its extension.
*/
function checkForBackupFiles(aFile) {
do_check_neq(getFileExtension(aFile), "moz-backup");
Assert.notEqual(getFileExtension(aFile), "moz-backup",
"the file's extension should not equal moz-backup");
}
/**
@ -3195,7 +3264,7 @@ function start_httpserver() {
* The callback to call after stopping the http server.
*/
function stop_httpserver(aCallback) {
do_check_true(!!aCallback);
Assert.ok(!!aCallback, "the aCallback parameter should be defined");
gTestserver.stop(aCallback);
}
@ -3464,10 +3533,11 @@ const gProcessObserver = {
gAppTimer.cancel();
gAppTimer = null;
}
Assert.equal(gProcess.exitValue, 0, "the exitValue for the application " +
"process should be '0'");
Assert.equal(aTopic, "process-finished", "the application process " +
"observer topic should be 'process-finished'");
Assert.equal(gProcess.exitValue, 0,
"the application process exit value should be 0");
Assert.equal(aTopic, "process-finished",
"the application process observer topic should be " +
"process-finished");
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
@ -3480,10 +3550,10 @@ const gTimerCallback = {
notify: function TC_notify(aTimer) {
gAppTimer = null;
if (gProcess.isRunning) {
logTestInfo("attempt to kill process");
logTestInfo("attempting to kill process");
gProcess.kill();
}
Assert.ok(false, "Launch application timer expired")
Assert.ok(false, "launch application timer expired");
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsITimerCallback])
};

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

@ -11,9 +11,9 @@ function run_test() {
let testFile = getCurrentProcessDir();
testFile.append("update_write_access_test");
testFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
do_check_true(testFile.exists());
Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
testFile.remove(false);
do_check_false(testFile.exists());
Assert.ok(!testFile.exists(), MSG_SHOULD_NOT_EXIST);
standardInit();
@ -21,32 +21,26 @@ function run_test() {
// Create a mutex to prevent being able to check for or apply updates.
debugDump("attempting to create mutex");
let handle = createMutex(getPerInstallationMutexName());
debugDump("testing that the mutex was successfully created");
do_check_true(!!handle);
Assert.ok(!!handle, "the update mutex should have been created");
// Check if available updates cannot be checked for when there is a mutex
// for this installation.
debugDump("testing nsIApplicationUpdateService:canCheckForUpdates is " +
"false when there is a mutex");
do_check_false(gAUS.canCheckForUpdates);
Assert.ok(!gAUS.canCheckForUpdates, "should not be able to check for " +
"updates when there is an update mutex");
// Check if updates cannot be applied when there is a mutex for this
// installation.
debugDump("testing nsIApplicationUpdateService:canApplyUpdates is " +
"false when there is a mutex");
do_check_false(gAUS.canApplyUpdates);
Assert.ok(!gAUS.canApplyUpdates, "should not be able to apply updates " +
"when there is an update mutex");
debugDump("destroying mutex");
closeHandle(handle)
closeHandle(handle);
}
// Check if available updates can be checked for
debugDump("testing nsIApplicationUpdateService:canCheckForUpdates is true");
do_check_true(gAUS.canCheckForUpdates);
Assert.ok(gAUS.canCheckForUpdates, "should be able to check for updates");
// Check if updates can be applied
debugDump("testing nsIApplicationUpdateService:canApplyUpdates is true");
do_check_true(gAUS.canApplyUpdates);
Assert.ok(gAUS.canApplyUpdates, "should be able to apply updates");
if (IS_WIN) {
// Attempt to create a mutex when application update has already created one
@ -54,8 +48,8 @@ function run_test() {
debugDump("attempting to create mutex");
let handle = createMutex(getPerInstallationMutexName());
debugDump("testing that the mutex was not successfully created");
do_check_eq(handle, null);
Assert.ok(!handle, "should not be able to create the update mutex when " +
"the application has created the update mutex");
}
doTestFinish();

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

@ -28,16 +28,19 @@ function run_test() {
standardInit();
do_check_eq(gUpdateManager.updateCount, 1);
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager update count" + MSG_SHOULD_EQUAL);
let update = gUpdateManager.getUpdateAt(0);
do_check_eq(update.name, "Existing");
Assert.equal(update.name, "Existing",
"the update's name" + MSG_SHOULD_EQUAL);
do_check_eq(gUpdateManager.activeUpdate, null);
Assert.ok(!gUpdateManager.activeUpdate,
"there should not be an active update");
// Verify that the active-update.xml file has had the update from the old
// channel removed.
let file = getUpdatesXMLFile(true);
debugDump("verifying contents of " + FILE_UPDATE_ACTIVE);
do_check_eq(readFile(file), getLocalUpdatesXMLString(""));
Assert.equal(readFile(file), getLocalUpdatesXMLString(""),
"the contents of active-update.xml" + MSG_SHOULD_EQUAL);
doTestFinish();
}

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

@ -24,11 +24,14 @@ function run_test() {
// Gonk doesn't resume downloads at boot time, so the update
// will remain active until the user chooses a new one, at
// which point, the old update will be removed.
do_check_neq(gUpdateManager.activeUpdate, null);
Assert.ok(!!gUpdateManager.activeUpdate,
"there should be an active update");
} else {
do_check_eq(gUpdateManager.activeUpdate, null);
Assert.ok(!gUpdateManager.activeUpdate,
"there should not be an active update");
}
do_check_eq(gUpdateManager.updateCount, 0);
Assert.equal(gUpdateManager.updateCount, 0,
"the update manager update count" + MSG_SHOULD_EQUAL);
doTestFinish();
}

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

@ -25,11 +25,14 @@ function run_test() {
// Gonk doesn't resume downloads at boot time, so the update
// will remain active until the user chooses a new one, at
// which point, the old update will be removed.
do_check_neq(gUpdateManager.activeUpdate, null);
Assert.ok(!!gUpdateManager.activeUpdate,
"there should be an active update");
} else {
do_check_eq(gUpdateManager.activeUpdate, null);
Assert.ok(!gUpdateManager.activeUpdate,
"there should not be an active update");
}
do_check_eq(gUpdateManager.updateCount, 0);
Assert.equal(gUpdateManager.updateCount, 0,
"the update manager update count" + MSG_SHOULD_EQUAL);
doTestFinish();
}

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

@ -19,19 +19,17 @@ function run_test() {
standardInit();
let dir = getUpdatesDir();
dir.append("0");
debugDump("testing " + dir.path + " should exist");
do_check_true(dir.exists());
dir.append(DIR_PATCH);
Assert.ok(dir.exists(), MSG_SHOULD_EXIST);
let statusFile = dir.clone();
statusFile.append(FILE_UPDATE_STATUS);
debugDump("testing " + statusFile.path + " should not exist");
do_check_false(statusFile.exists());
Assert.ok(!statusFile.exists(), MSG_SHOULD_NOT_EXIST);
debugDump("testing activeUpdate == null");
do_check_eq(gUpdateManager.activeUpdate, null);
debugDump("testing updateCount == 0");
do_check_eq(gUpdateManager.updateCount, 0);
Assert.ok(!gUpdateManager.activeUpdate,
"there should not be an active update");
Assert.equal(gUpdateManager.updateCount, 0,
"the update manager update count" + MSG_SHOULD_EQUAL);
doTestFinish();
}

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

@ -20,20 +20,18 @@ function run_test() {
// Check that there is no activeUpdate first so the updates directory is
// cleaned up by the UpdateManager before the remaining tests.
debugDump("testing activeUpdate == null");
do_check_eq(gUpdateManager.activeUpdate, null);
debugDump("testing updateCount == 0");
do_check_eq(gUpdateManager.updateCount, 0);
Assert.ok(!gUpdateManager.activeUpdate,
"there should not be an active update");
Assert.equal(gUpdateManager.updateCount, 0,
"the update manager update count" + MSG_SHOULD_EQUAL);
let dir = getUpdatesDir();
dir.append("0");
debugDump("testing " + dir.path + " should exist");
do_check_true(dir.exists());
dir.append(DIR_PATCH);
Assert.ok(dir.exists(), MSG_SHOULD_EXIST);
let versionFile = dir.clone();
versionFile.append(FILE_UPDATE_VERSION);
debugDump("testing " + versionFile.path + " should not exist");
do_check_false(versionFile.exists());
Assert.ok(!versionFile.exists(), MSG_SHOULD_NOT_EXIST);
doTestFinish();
}

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

@ -17,31 +17,26 @@ function run_test() {
let dir = getUpdatesDir();
let log = dir.clone();
log.append("0");
log.append(DIR_PATCH);
log.append(FILE_UPDATE_LOG);
writeFile(log, "Last Update Log");
standardInit();
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
log = dir.clone();
log.append(FILE_LAST_LOG);
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
debugDump("testing " + log.path + " contents");
do_check_eq(readFile(log), "Last Update Log");
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
Assert.equal(readFile(log), "Last Update Log",
"the last update log contents" + MSG_SHOULD_EQUAL);
log = dir.clone();
log.append(FILE_BACKUP_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
dir.append("0");
debugDump("testing " + dir.path + " should exist (bug 512994)");
do_check_true(dir.exists());
dir.append(DIR_PATCH);
Assert.ok(dir.exists(), MSG_SHOULD_EXIST);
doTestFinish();
}

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

@ -25,34 +25,28 @@ function run_test() {
writeFile(log, "To Be Deleted Backup Update Log");
log = dir.clone();
log.append("0");
log.append(DIR_PATCH);
log.append(FILE_UPDATE_LOG);
writeFile(log, "Last Update Log");
standardInit();
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
log = dir.clone();
log.append(FILE_LAST_LOG);
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
debugDump("testing " + log.path + " contents");
do_check_eq(readFile(log), "Last Update Log");
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
Assert.equal(readFile(log), "Last Update Log",
"the last update log contents" + MSG_SHOULD_EQUAL);
log = dir.clone();
log.append(FILE_BACKUP_LOG);
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
Assert.equal(readFile(log), "Backup Update Log",
"the backup update log contents" + MSG_SHOULD_EQUAL);
debugDump("testing " + log.path + " contents (bug 470979)");
do_check_eq(readFile(log), "Backup Update Log");
dir.append("0");
debugDump("testing " + dir.path + " should exist (bug 512994)");
do_check_true(dir.exists());
dir.append(DIR_PATCH);
Assert.ok(dir.exists(), MSG_SHOULD_EXIST);
doTestFinish();
}

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

@ -60,7 +60,8 @@ function run_test_helper_pt1(aMsg, aExpectedStatusResult, aNextRunFunc) {
}
function check_test_helper_pt1_1() {
do_check_eq(gUpdateCount, 1);
Assert.equal(gUpdateCount, 1,
"the update count" + MSG_SHOULD_EQUAL);
gCheckFunc = check_test_helper_pt1_2;
let bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
let state = gAUS.downloadUpdate(bestUpdate, false);
@ -71,7 +72,8 @@ function check_test_helper_pt1_1() {
}
function check_test_helper_pt1_2() {
do_check_eq(gStatusResult, gExpectedStatusResult);
Assert.equal(gStatusResult, gExpectedStatusResult,
"the download status result" + MSG_SHOULD_EQUAL);
gAUS.removeDownloadListener(downloadListener);
gNextRunFunc();
}
@ -91,7 +93,8 @@ function run_test_helper_bug828858_pt1(aMsg, aExpectedStatusResult, aNextRunFunc
}
function check_test_helper_bug828858_pt1_1() {
do_check_eq(gUpdateCount, 1);
Assert.equal(gUpdateCount, 1,
"the update count" + MSG_SHOULD_EQUAL);
gCheckFunc = check_test_helper_bug828858_pt1_2;
let bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
let state = gAUS.downloadUpdate(bestUpdate, false);
@ -103,9 +106,11 @@ function check_test_helper_bug828858_pt1_1() {
function check_test_helper_bug828858_pt1_2() {
if (gStatusResult == Cr.NS_ERROR_CONTENT_CORRUPTED) {
do_check_eq(gStatusResult, Cr.NS_ERROR_CONTENT_CORRUPTED);
Assert.ok(true,
"the status result should equal NS_ERROR_CONTENT_CORRUPTED");
} else {
do_check_eq(gStatusResult, gExpectedStatusResult);
Assert.equal(gStatusResult, gExpectedStatusResult,
"the download status result" + MSG_SHOULD_EQUAL);
}
gAUS.removeDownloadListener(downloadListener);
gNextRunFunc();

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

@ -43,16 +43,19 @@ function run_test() {
}
const WindowWatcher = {
getNewPrompter: function(aParent) {
do_check_eq(aParent, null);
getNewPrompter: function WW_getNewPrompter(aParent) {
Assert.ok(!aParent,
"the aParent parameter should not be defined");
return {
alert: function(aTitle, aText) {
alert: function WW_GNP_alert(aTitle, aText) {
let title = getString("updaterIOErrorTitle");
do_check_eq(aTitle, title);
Assert.equal(aTitle, title,
"the ui string for title" + MSG_SHOULD_EQUAL);
let text = gUpdateBundle.formatStringFromName("updaterIOErrorMsg",
[Services.appinfo.name,
Services.appinfo.name], 2);
do_check_eq(aText, text);
Assert.equal(aText, text,
"the ui string for message" + MSG_SHOULD_EQUAL);
doTestFinish();
}

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

@ -70,14 +70,18 @@ function run_test_pt1() {
}
function check_test_pt1() {
do_check_eq(gUpdateCount, 1);
Assert.equal(gUpdateCount, 1,
"the update count" + MSG_SHOULD_EQUAL);
gActiveUpdate = gUpdates[0];
do_check_neq(gActiveUpdate, null);
Assert.ok(!!gActiveUpdate,
"there should be an active update");
let state = gAUS.downloadUpdate(gActiveUpdate, true);
do_check_eq(state, "null");
do_check_eq(gActiveUpdate.errorCode >>> 0 , Cr.NS_ERROR_FILE_TOO_BIG);
Assert.equal(state, STATE_NONE,
"the update state" + MSG_SHOULD_EQUAL);
Assert.equal(gActiveUpdate.errorCode >>> 0 , Cr.NS_ERROR_FILE_TOO_BIG,
"the update error code" + MSG_SHOULD_EQUAL);
doTestFinish();
}
@ -94,7 +98,7 @@ function end_test() {
function FakeDirProvider() {}
FakeDirProvider.prototype = {
getFile: function(prop, persistent) {
getFile: function FP_getFile(prop, persistent) {
if (prop == KEY_UPDATE_ARCHIVE_DIR) {
if (gActiveUpdate) {
gActiveUpdate.errorCode = Cr.NS_ERROR_FILE_TOO_BIG;

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

@ -35,8 +35,10 @@ function xhr_pt1(aXHR) {
}
function check_test_pt1(request, update) {
do_check_eq(gStatusCode, Cr.NS_ERROR_OFFLINE);
do_check_eq(update.errorCode, NETWORK_ERROR_OFFLINE);
Assert.equal(gStatusCode, Cr.NS_ERROR_OFFLINE,
"the download status code" + MSG_SHOULD_EQUAL);
Assert.equal(update.errorCode, NETWORK_ERROR_OFFLINE,
"the update error code" + MSG_SHOULD_EQUAL);
// Forward the error to AUS, which should register the online observer
gAUS.onError(request, update);
@ -70,8 +72,9 @@ function xhr_pt2(aXHR) {
function check_test_pt2(update) {
// We just verify that there are updates to know the check succeeded.
do_check_neq(update, null);
do_check_eq(update.name, "App Update Test");
Assert.ok(!!update, "there should be an update");
Assert.equal(update.name, "App Update Test",
"the update name" + MSG_SHOULD_EQUAL);
doTestFinish();
}

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

@ -65,7 +65,8 @@ function run_test_helper_pt1(aMsg, aExpectedStatusResult, aNextRunFunc) {
}
function check_test_helper_pt1_1() {
do_check_eq(gUpdateCount, 1);
Assert.equal(gUpdateCount, 1,
"the update count" + MSG_SHOULD_EQUAL);
gCheckFunc = check_test_helper_pt1_2;
let bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
let state = gAUS.downloadUpdate(bestUpdate, false);
@ -76,7 +77,8 @@ function check_test_helper_pt1_1() {
}
function check_test_helper_pt1_2() {
do_check_eq(gStatusResult, gExpectedStatusResult);
Assert.equal(gStatusResult, gExpectedStatusResult,
"the download status result" + MSG_SHOULD_EQUAL);
gAUS.removeDownloadListener(downloadListener);
gNextRunFunc();
}

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

@ -22,11 +22,15 @@ function run_test() {
if (IS_TOOLKIT_GONK) {
// GONK doesn't resume downloads at boot time, so the updateCount will
// always be zero.
do_check_eq(gUpdateManager.updateCount, 0);
Assert.equal(gUpdateManager.updateCount, 0,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
} else {
do_check_eq(gUpdateManager.updateCount, 1);
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
}
do_check_eq(gUpdateManager.activeUpdate.state, STATE_DOWNLOADING);
Assert.equal(gUpdateManager.activeUpdate.state, STATE_DOWNLOADING,
"the update manager activeUpdate state attribute" +
MSG_SHOULD_EQUAL);
// Pause the download and reload the Update Manager with an empty update so
// the Application Update Service doesn't write the update xml files during

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

@ -31,7 +31,8 @@ function run_test_helper_pt1(aMsg, aExpectedCount, aNextRunFunc) {
}
function check_test_helper_pt1() {
do_check_eq(gUpdateCount, gExpectedCount);
Assert.equal(gUpdateCount, gExpectedCount,
"the update count" + MSG_SHOULD_EQUAL);
gNextRunFunc();
}
@ -100,60 +101,100 @@ function check_test_pt02() {
// defaultDetailsURL = "";
// }
do_check_eq(gUpdateCount, 1);
Assert.equal(gUpdateCount, 1,
"the update count" + MSG_SHOULD_EQUAL);
let bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount).QueryInterface(Ci.nsIPropertyBag);
do_check_eq(bestUpdate.type, "minor");
do_check_eq(bestUpdate.name, "Minor Test");
do_check_eq(bestUpdate.displayVersion, "version 2.1a1pre");
do_check_eq(bestUpdate.appVersion, "2.1a1pre");
do_check_eq(bestUpdate.platformVersion, "3.1a1pre");
do_check_eq(bestUpdate.buildID, "20080811053724");
do_check_eq(bestUpdate.detailsURL, "http://details/");
do_check_eq(bestUpdate.billboardURL, "http://billboard/");
do_check_eq(bestUpdate.licenseURL, "http://license/");
do_check_true(bestUpdate.showPrompt);
do_check_true(bestUpdate.showNeverForVersion);
do_check_eq(bestUpdate.promptWaitTime, "345600");
do_check_eq(bestUpdate.serviceURL, URL_HOST + "/update.xml?force=1");
do_check_eq(bestUpdate.channel, "test_channel");
do_check_false(bestUpdate.isCompleteUpdate);
do_check_false(bestUpdate.isSecurityUpdate);
Assert.equal(bestUpdate.type, "minor",
"the update type attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.name, "Minor Test",
"the update name attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.displayVersion, "version 2.1a1pre",
"the update displayVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.appVersion, "2.1a1pre",
"the update appVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.platformVersion, "3.1a1pre",
"the update platformVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.buildID, "20080811053724",
"the update buildID attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.detailsURL, "http://details/",
"the update detailsURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.billboardURL, "http://billboard/",
"the update billboardURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.licenseURL, "http://license/",
"the update licenseURL attribute" + MSG_SHOULD_EQUAL);
Assert.ok(bestUpdate.showPrompt,
"the update showPrompt attribute" + MSG_SHOULD_EQUAL);
Assert.ok(bestUpdate.showNeverForVersion,
"the update showNeverForVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.promptWaitTime, "345600",
"the update promptWaitTime attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.serviceURL, URL_HOST + "/update.xml?force=1",
"the update serviceURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.channel, "test_channel",
"the update channel attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!bestUpdate.isCompleteUpdate,
"the update isCompleteUpdate attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!bestUpdate.isSecurityUpdate,
"the update isSecurityUpdate attribute" + MSG_SHOULD_EQUAL);
// Check that installDate is within 10 seconds of the current date.
do_check_true((Date.now() - bestUpdate.installDate) < 10000);
do_check_eq(bestUpdate.statusText, null);
Assert.ok((Date.now() - bestUpdate.installDate) < 10000,
"the update installDate attribute should be within 10 seconds of " +
"the current time");
Assert.ok(!bestUpdate.statusText,
"the update statusText attribute" + MSG_SHOULD_EQUAL);
// nsIUpdate:state returns an empty string when no action has been performed
// on an available update
do_check_eq(bestUpdate.state, "");
do_check_eq(bestUpdate.errorCode, 0);
do_check_eq(bestUpdate.patchCount, 2);
Assert.equal(bestUpdate.state, "",
"the update state attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.errorCode, 0,
"the update errorCode attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.patchCount, 2,
"the update patchCount attribute" + MSG_SHOULD_EQUAL);
//XXX TODO - test nsIUpdate:serialize
do_check_eq(bestUpdate.getProperty("custom1_attr"), "custom1 value");
do_check_eq(bestUpdate.getProperty("custom2_attr"), "custom2 value");
Assert.equal(bestUpdate.getProperty("custom1_attr"), "custom1 value",
"the update custom1_attr property" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.getProperty("custom2_attr"), "custom2 value",
"the update custom2_attr property" + MSG_SHOULD_EQUAL);
let patch = bestUpdate.getPatchAt(0);
do_check_eq(patch.type, "complete");
do_check_eq(patch.URL, "http://complete/");
do_check_eq(patch.hashFunction, "SHA1");
do_check_eq(patch.hashValue, "98db9dad8e1d80eda7e1170d0187d6f53e477059");
do_check_eq(patch.size, 9856459);
Assert.equal(patch.type, "complete",
"the update patch type attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.URL, "http://complete/",
"the update patch URL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.hashFunction, "SHA1",
"the update patch hashFunction attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.hashValue, "98db9dad8e1d80eda7e1170d0187d6f53e477059",
"the update patch hashValue attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.size, 9856459,
"the update patch size attribute" + MSG_SHOULD_EQUAL);
// The value for patch.state can be the string 'null' as a valid value. This
// is confusing if it returns null which is an invalid value since the test
// failure output will show a failure for null == null. To lessen the
// confusion first check that the typeof for patch.state is string.
do_check_eq(typeof(patch.state), "string");
do_check_eq(patch.state, STATE_NONE);
do_check_false(patch.selected);
Assert.equal(typeof(patch.state), "string",
"the update patch state typeof value should equal |string|");
Assert.equal(patch.state, STATE_NONE,
"the update patch state attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!patch.selected,
"the update patch selected attribute" + MSG_SHOULD_EQUAL);
//XXX TODO - test nsIUpdatePatch:serialize
patch = bestUpdate.getPatchAt(1);
do_check_eq(patch.type, "partial");
do_check_eq(patch.URL, "http://partial/");
do_check_eq(patch.hashFunction, "SHA1");
do_check_eq(patch.hashValue, "e6678ca40ae7582316acdeddf3c133c9c8577de4");
do_check_eq(patch.size, 1316138);
do_check_eq(patch.state, STATE_NONE);
do_check_false(patch.selected);
Assert.equal(patch.type, "partial",
"the update patch type attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.URL, "http://partial/",
"the update patch URL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.hashFunction, "SHA1",
"the update patch hashFunction attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.hashValue, "e6678ca40ae7582316acdeddf3c133c9c8577de4",
"the update patch hashValue attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.size, 1316138,
"the update patch size attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.state, STATE_NONE,
"the update patch state attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!patch.selected,
"the update patch selected attribute" + MSG_SHOULD_EQUAL);
//XXX TODO - test nsIUpdatePatch:serialize
run_test_pt03();
@ -180,47 +221,78 @@ function run_test_pt03() {
}
function check_test_pt03() {
do_check_eq(gUpdateCount, 1);
Assert.equal(gUpdateCount, 1,
"the update count" + MSG_SHOULD_EQUAL);
let bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
do_check_eq(bestUpdate.type, "major");
do_check_eq(bestUpdate.name, "Major Test");
do_check_eq(bestUpdate.displayVersion, "version 4.1a1pre");
do_check_eq(bestUpdate.appVersion, "4.1a1pre");
do_check_eq(bestUpdate.platformVersion, "5.1a1pre");
do_check_eq(bestUpdate.buildID, "20080811053724");
do_check_eq(bestUpdate.detailsURL, "http://details/");
do_check_eq(bestUpdate.billboardURL, "http://details/");
do_check_eq(bestUpdate.licenseURL, null);
do_check_true(bestUpdate.showPrompt);
do_check_true(bestUpdate.showNeverForVersion);
do_check_eq(bestUpdate.promptWaitTime, "691200");
do_check_eq(bestUpdate.serviceURL, URL_HOST + "/update.xml?force=1");
do_check_eq(bestUpdate.channel, "test_channel");
do_check_false(bestUpdate.isCompleteUpdate);
do_check_false(bestUpdate.isSecurityUpdate);
Assert.equal(bestUpdate.type, "major",
"the update type attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.name, "Major Test",
"the update name attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.displayVersion, "version 4.1a1pre",
"the update displayVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.appVersion, "4.1a1pre",
"the update appVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.platformVersion, "5.1a1pre",
"the update platformVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.buildID, "20080811053724",
"the update buildID attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.detailsURL, "http://details/",
"the update detailsURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.billboardURL, "http://details/",
"the update billboardURL attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!bestUpdate.licenseURL,
"the update licenseURL attribute" + MSG_SHOULD_EQUAL);
Assert.ok(bestUpdate.showPrompt,
"the update showPrompt attribute" + MSG_SHOULD_EQUAL);
Assert.ok(bestUpdate.showNeverForVersion,
"the update showNeverForVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.promptWaitTime, "691200",
"the update promptWaitTime attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.serviceURL, URL_HOST + "/update.xml?force=1",
"the update serviceURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.channel, "test_channel",
"the update channel attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!bestUpdate.isCompleteUpdate,
"the update isCompleteUpdate attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!bestUpdate.isSecurityUpdate,
"the update isSecurityUpdate attribute" + MSG_SHOULD_EQUAL);
// Check that installDate is within 10 seconds of the current date.
do_check_true((Date.now() - bestUpdate.installDate) < 10000);
do_check_eq(bestUpdate.statusText, null);
Assert.ok((Date.now() - bestUpdate.installDate) < 10000,
"the update installDate attribute should be within 10 seconds of " +
"the current time");
Assert.ok(!bestUpdate.statusText,
"the update statusText attribute" + MSG_SHOULD_EQUAL);
// nsIUpdate:state returns an empty string when no action has been performed
// on an available update
do_check_eq(bestUpdate.state, "");
do_check_eq(bestUpdate.errorCode, 0);
do_check_eq(bestUpdate.patchCount, 1);
Assert.equal(bestUpdate.state, "",
"the update state attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.errorCode, 0,
"the update errorCode attribute" + MSG_SHOULD_EQUAL);
Assert.equal(bestUpdate.patchCount, 1,
"the update patchCount attribute" + MSG_SHOULD_EQUAL);
//XXX TODO - test nsIUpdate:serialize
let patch = bestUpdate.getPatchAt(0);
do_check_eq(patch.type, "complete");
do_check_eq(patch.URL, "http://complete/");
do_check_eq(patch.hashFunction, "SHA1");
do_check_eq(patch.hashValue, "98db9dad8e1d80eda7e1170d0187d6f53e477059");
do_check_eq(patch.size, 9856459);
Assert.equal(patch.type, "complete",
"the update patch type attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.URL, "http://complete/",
"the update patch URL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.hashFunction, "SHA1",
"the update patch hashFunction attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.hashValue, "98db9dad8e1d80eda7e1170d0187d6f53e477059",
"the update patch hashValue attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.size, 9856459,
"the update patch size attribute" + MSG_SHOULD_EQUAL);
// The value for patch.state can be the string 'null' as a valid value. This
// is confusing if it returns null which is an invalid value since the test
// failure output will show a failure for null == null. To lessen the
// confusion first check that the typeof for patch.state is string.
do_check_eq(typeof(patch.state), "string");
do_check_eq(patch.state, STATE_NONE);
do_check_false(patch.selected);
Assert.equal(typeof(patch.state), "string",
"the update patch state typeof value should equal |string|");
Assert.equal(patch.state, STATE_NONE,
"the update patch state attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!patch.selected,
"the update patch selected attribute" + MSG_SHOULD_EQUAL);
//XXX TODO - test nsIUpdatePatch:serialize
run_test_pt04();
@ -304,7 +376,7 @@ function run_test_pt11() {
function check_test_pt11() {
let bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
do_check_eq(bestUpdate, null);
Assert.ok(!bestUpdate);
run_test_pt12();
}
@ -320,8 +392,9 @@ function run_test_pt12() {
function check_test_pt12() {
let bestUpdate = gAUS.selectUpdate(gUpdates, gUpdateCount);
do_check_neq(bestUpdate, null);
do_check_eq(bestUpdate.displayVersion, "version 1.0");
Assert.ok(!!bestUpdate);
Assert.equal(bestUpdate.displayVersion, "version 1.0",
"the update displayVersion attribute" + MSG_SHOULD_EQUAL);
doTestFinish();
}

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

@ -41,7 +41,7 @@ function run_test() {
function check_status() {
let status = readStatusFile();
Assert.notEqual(status, STATE_DOWNLOADING,
"the update should not be downloading");
"the update state" + MSG_SHOULD_EQUAL);
// Pause the download and reload the Update Manager with an empty update so
// the Application Update Service doesn't write the update xml files during

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

@ -37,7 +37,8 @@ function run_test() {
gUP.showUpdateInstalled();
// Report a successful check after the call to showUpdateInstalled since it
// didn't throw and otherwise it would report no tests run.
do_check_true(true);
Assert.ok(true,
"calling showUpdateInstalled should not attempt to open a window");
debugDump("testing showUpdateAvailable should not call openWindow");
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
@ -53,7 +54,8 @@ function run_test() {
gUP.showUpdateAvailable(update);
// Report a successful check after the call to showUpdateAvailable since it
// didn't throw and otherwise it would report no tests run.
do_check_true(true);
Assert.ok(true,
"calling showUpdateAvailable should not attempt to open a window");
doTestFinish();
}

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

@ -34,7 +34,8 @@ function run_test() {
gUP.showUpdateInstalled();
// Report a successful check after the call to showUpdateInstalled since it
// didn't throw and otherwise it would report no tests run.
do_check_true(true);
Assert.ok(true,
"calling showUpdateInstalled should not attempt to open a window");
debugDump("testing showUpdateAvailable should not call openWindow");
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
@ -50,7 +51,8 @@ function run_test() {
gUP.showUpdateAvailable(update);
// Report a successful check after the call to showUpdateAvailable since it
// didn't throw and otherwise it would report no tests run.
do_check_true(true);
Assert.ok(true,
"calling showUpdateAvailable should not attempt to open a window");
debugDump("testing showUpdateError should not call getNewPrompter");
gCheckFunc = check_showUpdateError;
@ -58,7 +60,8 @@ function run_test() {
gUP.showUpdateError(update);
// Report a successful check after the call to showUpdateError since it
// didn't throw and otherwise it would report no tests run.
do_check_true(true);
Assert.ok(true,
"calling showUpdateError should not attempt to open a window");
doTestFinish();
}

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

@ -48,7 +48,8 @@ function check_test() {
do_execute_soon(check_test);
return;
}
do_check_true(true);
Assert.ok(true,
PREF_APP_UPDATE_BACKGROUNDERRORS + " preference should not exist");
doTestFinish();
}

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

@ -29,7 +29,7 @@ function run_test() {
// call the nsIDOMEventListener's handleEvent method for onload.
function callHandleEvent(aXHR) {
aXHR.status = gExpectedStatusCode;
var e = { target: aXHR };
let e = { target: aXHR };
aXHR.onload(e);
}
@ -45,9 +45,11 @@ function run_test_helper(aNextRunFunc, aExpectedStatusCode, aMsg) {
}
function check_test_helper() {
do_check_eq(gStatusCode, gExpectedStatusCode);
Assert.equal(gStatusCode, gExpectedStatusCode,
"the download status code" + MSG_SHOULD_EQUAL);
let expectedStatusText = getStatusText(gExpectedStatusCode);
do_check_eq(gStatusText, expectedStatusText);
Assert.equal(gStatusText, expectedStatusText,
"the update status text" + MSG_SHOULD_EQUAL);
gNextRunFunc();
}
@ -66,9 +68,11 @@ function run_test_pt1() {
}
function check_test_pt1() {
do_check_eq(gStatusCode, gExpectedStatusCode);
Assert.equal(gStatusCode, gExpectedStatusCode,
"the download status code" + MSG_SHOULD_EQUAL);
let expectedStatusText = getStatusText(404);
do_check_eq(gStatusText, expectedStatusText);
Assert.equal(gStatusText, expectedStatusText,
"the update status text" + MSG_SHOULD_EQUAL);
run_test_pt2();
}

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

@ -45,75 +45,133 @@ function run_test() {
standardInit();
do_check_eq(gUpdateManager.activeUpdate, null);
do_check_eq(gUpdateManager.updateCount, 2);
Assert.ok(!gUpdateManager.activeUpdate,
"the update manager activeUpdate attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.updateCount, 2,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
let update = gUpdateManager.getUpdateAt(0).QueryInterface(Ci.nsIPropertyBag);
do_check_eq(update.state, STATE_SUCCEEDED);
do_check_eq(update.type, "major");
do_check_eq(update.name, "New");
do_check_eq(update.displayVersion, "version 4");
do_check_eq(update.appVersion, "4.0");
do_check_eq(update.platformVersion, "4.0");
do_check_eq(update.buildID, "20070811053724");
do_check_eq(update.detailsURL, "http://details1/");
do_check_eq(update.billboardURL, "http://billboard1/");
do_check_eq(update.licenseURL, "http://license1/");
do_check_eq(update.serviceURL, "http://service1/");
do_check_eq(update.installDate, "1238441300314");
Assert.equal(update.state, STATE_SUCCEEDED,
"the update state attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.type, "major",
"the update type attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.name, "New",
"the update name attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.displayVersion, "version 4",
"the update displayVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.appVersion, "4.0",
"the update appVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.platformVersion, "4.0",
"the update platformVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.buildID, "20070811053724",
"the update buildID attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.detailsURL, "http://details1/",
"the update detailsURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.billboardURL, "http://billboard1/",
"the update billboardURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.licenseURL, "http://license1/",
"the update licenseURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.serviceURL, "http://service1/",
"the update serviceURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.installDate, "1238441300314",
"the update installDate attribute" + MSG_SHOULD_EQUAL);
// statusText is updated
do_check_eq(update.statusText, getString("installSuccess"));
do_check_false(update.isCompleteUpdate);
do_check_eq(update.channel, "test_channel");
do_check_true(update.showPrompt);
do_check_true(update.showNeverForVersion);
do_check_eq(update.promptWaitTime, "345600");
do_check_eq(update.previousAppVersion, "3.0");
Assert.equal(update.statusText, getString("installSuccess"),
"the update statusText attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!update.isCompleteUpdate,
"the update isCompleteUpdate attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.channel, "test_channel",
"the update channel attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!!update.showPrompt,
"the update showPrompt attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!!update.showNeverForVersion,
"the update showNeverForVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.promptWaitTime, "345600",
"the update promptWaitTime attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.previousAppVersion, "3.0",
"the update previousAppVersion attribute" + MSG_SHOULD_EQUAL);
// Custom attributes
do_check_eq(update.getProperty("custom1_attr"), "custom1 value");
do_check_eq(update.getProperty("custom2_attr"), "custom2 value");
Assert.equal(update.getProperty("custom1_attr"), "custom1 value",
"the update custom1_attr property" + MSG_SHOULD_EQUAL);
Assert.equal(update.getProperty("custom2_attr"), "custom2 value",
"the update custom2_attr property" + MSG_SHOULD_EQUAL);
let patch = update.selectedPatch;
do_check_eq(patch.type, "partial");
do_check_eq(patch.URL, "http://partial/");
do_check_eq(patch.hashFunction, "SHA256");
do_check_eq(patch.hashValue, "cd43");
do_check_eq(patch.size, "86");
do_check_true(patch.selected);
do_check_eq(patch.state, STATE_SUCCEEDED);
Assert.equal(patch.type, "partial",
"the update patch type attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.URL, "http://partial/",
"the update patch URL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.hashFunction, "SHA256",
"the update patch hashFunction attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.hashValue, "cd43",
"the update patch hashValue attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.size, "86",
"the update patch size attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!!patch.selected,
"the update patch selected attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.state, STATE_SUCCEEDED,
"the update patch state attribute" + MSG_SHOULD_EQUAL);
update = gUpdateManager.getUpdateAt(1).QueryInterface(Ci.nsIPropertyBag);
do_check_eq(update.state, STATE_FAILED);
do_check_eq(update.name, "Existing");
do_check_eq(update.type, "major");
do_check_eq(update.displayVersion, "version 3");
do_check_eq(update.appVersion, "3.0");
do_check_eq(update.platformVersion, "3.0");
do_check_eq(update.detailsURL, "http://details2/");
do_check_eq(update.billboardURL, "http://details2/");
do_check_eq(update.licenseURL, null);
do_check_eq(update.serviceURL, "http://service2/");
do_check_eq(update.installDate, "1238441400314");
do_check_eq(update.statusText, getString("patchApplyFailure"));
do_check_eq(update.buildID, "20080811053724");
do_check_true(update.isCompleteUpdate);
do_check_eq(update.channel, "test_channel");
do_check_true(update.showPrompt);
do_check_true(update.showNeverForVersion);
do_check_eq(update.promptWaitTime, "691200");
do_check_eq(update.previousAppVersion, null);
Assert.equal(update.state, STATE_FAILED,
"the update state attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.name, "Existing",
"the update name attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.type, "major",
"the update type attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.displayVersion, "version 3",
"the update displayVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.appVersion, "3.0",
"the update appVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.platformVersion, "3.0",
"the update platformVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.detailsURL, "http://details2/",
"the update detailsURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.billboardURL, "http://details2/",
"the update billboardURL attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!update.licenseURL,
"the update licenseURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.serviceURL, "http://service2/",
"the update serviceURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.installDate, "1238441400314",
"the update installDate attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.statusText, getString("patchApplyFailure"),
"the update statusText attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.buildID, "20080811053724",
"the update buildID attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!!update.isCompleteUpdate,
"the update isCompleteUpdate attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.channel, "test_channel",
"the update channel attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!!update.showPrompt,
"the update showPrompt attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!!update.showNeverForVersion,
"the update showNeverForVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.promptWaitTime, "691200",
"the update promptWaitTime attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.previousAppVersion, null,
"the update previousAppVersion attribute" + MSG_SHOULD_EQUAL);
// Custom attributes
do_check_eq(update.getProperty("custom3_attr"), "custom3 value");
do_check_eq(update.getProperty("custom4_attr"), "custom4 value");
Assert.equal(update.getProperty("custom3_attr"), "custom3 value",
"the update custom3_attr property" + MSG_SHOULD_EQUAL);
Assert.equal(update.getProperty("custom4_attr"), "custom4 value",
"the update custom4_attr property" + MSG_SHOULD_EQUAL);
patch = update.selectedPatch;
do_check_eq(patch.type, "complete");
do_check_eq(patch.URL, "http://complete/");
do_check_eq(patch.hashFunction, "SHA1");
do_check_eq(patch.hashValue, "6232");
do_check_eq(patch.size, "75");
do_check_true(patch.selected);
do_check_eq(patch.state, STATE_FAILED);
Assert.equal(patch.type, "complete",
"the update patch type attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.URL, "http://complete/",
"the update patch URL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.hashFunction, "SHA1",
"the update patch hashFunction attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.hashValue, "6232",
"the update patch hashValue attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.size, "75",
"the update patch size attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!!patch.selected,
"the update patch selected attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.state, STATE_FAILED,
"the update patch state attribute" + MSG_SHOULD_EQUAL);
removeUpdateDirsAndFiles();
@ -145,68 +203,122 @@ function run_test() {
reloadUpdateManagerData();
initUpdateServiceStub();
do_check_eq(gUpdateManager.activeUpdate, null);
do_check_eq(gUpdateManager.updateCount, 2);
Assert.ok(!gUpdateManager.activeUpdate,
"the update manager activeUpdate attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.updateCount, 2,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
update = gUpdateManager.getUpdateAt(0);
do_check_eq(update.state, STATE_SUCCEEDED);
do_check_eq(update.type, "major");
do_check_eq(update.name, "New");
do_check_eq(update.displayVersion, "version 4.0");
do_check_eq(update.appVersion, "4.0");
do_check_eq(update.platformVersion, "4.0");
do_check_eq(update.detailsURL, "http://details/");
do_check_eq(update.billboardURL, "http://billboard/");
do_check_eq(update.licenseURL, "http://license/");
do_check_eq(update.serviceURL, "http://service/");
do_check_eq(update.installDate, "1238441400314");
do_check_eq(update.statusText, getString("installSuccess"));
do_check_eq(update.buildID, "20080811053724");
do_check_true(update.isCompleteUpdate);
do_check_eq(update.channel, "test_channel");
do_check_true(update.showPrompt);
do_check_true(update.showNeverForVersion);
do_check_eq(update.promptWaitTime, "100");
do_check_eq(update.previousAppVersion, "3.0");
Assert.equal(update.state, STATE_SUCCEEDED,
"the update state attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.type, "major",
"the update type attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.name, "New",
"the update name attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.displayVersion, "version 4.0",
"the update displayVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.appVersion, "4.0",
"the update appVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.platformVersion, "4.0",
"the update platformVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.detailsURL, "http://details/",
"the update detailsURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.billboardURL, "http://billboard/",
"the update billboardURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.licenseURL, "http://license/",
"the update licenseURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.serviceURL, "http://service/",
"the update serviceURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.installDate, "1238441400314",
"the update installDate attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.statusText, getString("installSuccess"),
"the update statusText attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.buildID, "20080811053724",
"the update buildID attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!!update.isCompleteUpdate,
"the update isCompleteUpdate attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.channel, "test_channel",
"the update channel attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!!update.showPrompt,
"the update showPrompt attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!!update.showNeverForVersion,
"the update showNeverForVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.promptWaitTime, "100",
"the update promptWaitTime attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.previousAppVersion, "3.0",
"the update previousAppVersion attribute" + MSG_SHOULD_EQUAL);
patch = update.selectedPatch;
do_check_eq(patch.type, "complete");
do_check_eq(patch.URL, URL_HOST + "/" + FILE_SIMPLE_MAR);
do_check_eq(patch.hashFunction, "MD5");
do_check_eq(patch.hashValue, MD5_HASH_SIMPLE_MAR);
do_check_eq(patch.size, SIZE_SIMPLE_MAR);
do_check_true(patch.selected);
do_check_eq(patch.state, STATE_SUCCEEDED);
Assert.equal(patch.type, "complete",
"the update patch type attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.URL, URL_HOST + "/" + FILE_SIMPLE_MAR,
"the update patch URL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.hashFunction, "MD5",
"the update patch hashFunction attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.hashValue, MD5_HASH_SIMPLE_MAR,
"the update patch hashValue attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.size, SIZE_SIMPLE_MAR,
"the update patch size attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!!patch.selected,
"the update patch selected attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.state, STATE_SUCCEEDED,
"the update patch state attribute" + MSG_SHOULD_EQUAL);
update = gUpdateManager.getUpdateAt(1);
do_check_eq(update.state, STATE_FAILED);
do_check_eq(update.name, "Existing");
do_check_eq(update.type, "major");
do_check_eq(update.displayVersion, "version 3.0");
do_check_eq(update.appVersion, "3.0");
do_check_eq(update.platformVersion, "3.0");
do_check_eq(update.detailsURL, "http://details/");
do_check_eq(update.billboardURL, null);
do_check_eq(update.licenseURL, null);
do_check_eq(update.serviceURL, "http://service/");
do_check_eq(update.installDate, "1238441400314");
do_check_eq(update.statusText, getString("patchApplyFailure"));
do_check_eq(update.buildID, "20080811053724");
do_check_true(update.isCompleteUpdate);
do_check_eq(update.channel, "test_channel");
do_check_false(update.showPrompt);
do_check_false(update.showNeverForVersion);
do_check_eq(update.promptWaitTime, "200");
do_check_eq(update.previousAppVersion, null);
Assert.equal(update.state, STATE_FAILED,
"the update state attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.name, "Existing",
"the update name attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.type, "major",
"the update type attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.displayVersion, "version 3.0",
"the update displayVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.appVersion, "3.0",
"the update appVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.platformVersion, "3.0",
"the update platformVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.detailsURL, "http://details/",
"the update detailsURL attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!update.billboardURL,
"the update billboardURL attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!update.licenseURL,
"the update licenseURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.serviceURL, "http://service/",
"the update serviceURL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.installDate, "1238441400314",
"the update installDate attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.statusText, getString("patchApplyFailure"),
"the update statusText attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.buildID, "20080811053724",
"the update buildID attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!!update.isCompleteUpdate,
"the update isCompleteUpdate attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.channel, "test_channel",
"the update channel attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!update.showPrompt,
"the update showPrompt attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!update.showNeverForVersion,
"the update showNeverForVersion attribute" + MSG_SHOULD_EQUAL);
Assert.equal(update.promptWaitTime, "200",
"the update promptWaitTime attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!update.previousAppVersion,
"the update previousAppVersion attribute" + MSG_SHOULD_EQUAL);
patch = update.selectedPatch;
do_check_eq(patch.type, "complete");
do_check_eq(patch.URL, URL_HOST + "/" + FILE_SIMPLE_MAR);
do_check_eq(patch.hashFunction, "MD5");
do_check_eq(patch.hashValue, MD5_HASH_SIMPLE_MAR);
do_check_eq(patch.size, SIZE_SIMPLE_MAR);
do_check_true(patch.selected);
do_check_eq(patch.state, STATE_FAILED);
Assert.equal(patch.type, "complete",
"the update patch type attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.URL, URL_HOST + "/" + FILE_SIMPLE_MAR,
"the update patch URL attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.hashFunction, "MD5",
"the update patch hashFunction attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.hashValue, MD5_HASH_SIMPLE_MAR,
"the update patch hashValue attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.size, SIZE_SIMPLE_MAR,
"the update patch size attribute" + MSG_SHOULD_EQUAL);
Assert.ok(!!patch.selected,
"the update patch selected attribute" + MSG_SHOULD_EQUAL);
Assert.equal(patch.state, STATE_FAILED,
"the update patch state attribute" + MSG_SHOULD_EQUAL);
doTestFinish();
}

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

@ -5,8 +5,6 @@
/* General URL Construction Tests */
Cu.import("resource://gre/modules/ctypes.jsm")
const URL_PREFIX = URL_HOST + "/";
var gAppInfo;
@ -32,7 +30,7 @@ function callHandleEvent(aXHR) {
// The mock xmlhttprequest needs a status code to return to the consumer and
// the value is not important for this test.
aXHR.status = 404;
var e = { target: aXHR };
let e = { target: aXHR };
aXHR.onload(e);
}
@ -51,7 +49,8 @@ function run_test_pt1() {
}
function check_test_pt1() {
do_check_eq(getResult(gRequestURL), gAppInfo.name);
Assert.equal(getResult(gRequestURL), gAppInfo.name,
"the url param for %PRODUCT%" + MSG_SHOULD_EQUAL);
run_test_pt2();
}
@ -65,7 +64,8 @@ function run_test_pt2() {
}
function check_test_pt2() {
do_check_eq(getResult(gRequestURL), gAppInfo.version);
Assert.equal(getResult(gRequestURL), gAppInfo.version,
"the url param for %VERSION%" + MSG_SHOULD_EQUAL);
run_test_pt3();
}
@ -79,7 +79,8 @@ function run_test_pt3() {
}
function check_test_pt3() {
do_check_eq(getResult(gRequestURL), gAppInfo.appBuildID);
Assert.equal(getResult(gRequestURL), gAppInfo.appBuildID,
"the url param for %BUILD_ID%" + MSG_SHOULD_EQUAL);
run_test_pt4();
}
@ -113,7 +114,8 @@ function check_test_pt4() {
}
}
do_check_eq(getResult(gRequestURL), gAppInfo.OS + "_" + abi);
Assert.equal(getResult(gRequestURL), gAppInfo.OS + "_" + abi,
"the url param for %BUILD_TARGET%" + MSG_SHOULD_EQUAL);
run_test_pt5();
}
@ -139,7 +141,8 @@ function run_test_pt5() {
}
function check_test_pt5() {
do_check_eq(getResult(gRequestURL), INSTALL_LOCALE);
Assert.equal(getResult(gRequestURL), INSTALL_LOCALE,
"the url param for %LOCALE%" + MSG_SHOULD_EQUAL);
run_test_pt6();
}
@ -154,7 +157,8 @@ function run_test_pt6() {
}
function check_test_pt6() {
do_check_eq(getResult(gRequestURL), "test_channel");
Assert.equal(getResult(gRequestURL), "test_channel",
"the url param for %CHANNEL%" + MSG_SHOULD_EQUAL);
run_test_pt7();
}
@ -164,13 +168,17 @@ function run_test_pt7() {
let url = URL_PREFIX + "%CHANNEL%/";
debugDump("testing url constructed with %CHANNEL% - " + url);
setUpdateURLOverride(url);
gDefaultPrefBranch.setCharPref(PREF_APP_PARTNER_BRANCH + "test_partner1", "test_partner1");
gDefaultPrefBranch.setCharPref(PREF_APP_PARTNER_BRANCH + "test_partner2", "test_partner2");
gDefaultPrefBranch.setCharPref(PREF_APP_PARTNER_BRANCH + "test_partner1",
"test_partner1");
gDefaultPrefBranch.setCharPref(PREF_APP_PARTNER_BRANCH + "test_partner2",
"test_partner2");
gUpdateChecker.checkForUpdates(updateCheckListener, true);
}
function check_test_pt7() {
do_check_eq(getResult(gRequestURL), "test_channel-cck-test_partner1-test_partner2");
Assert.equal(getResult(gRequestURL),
"test_channel-cck-test_partner1-test_partner2",
"the url param for %CHANNEL%" + MSG_SHOULD_EQUAL);
run_test_pt8();
}
@ -184,7 +192,8 @@ function run_test_pt8() {
}
function check_test_pt8() {
do_check_eq(getResult(gRequestURL), gAppInfo.platformVersion);
Assert.equal(getResult(gRequestURL), gAppInfo.platformVersion,
"the url param for %PLATFORM_VERSION%" + MSG_SHOULD_EQUAL);
run_test_pt9();
}
@ -332,7 +341,8 @@ function check_test_pt9() {
osVersion = encodeURIComponent(osVersion);
}
do_check_eq(getResult(gRequestURL), osVersion);
Assert.equal(getResult(gRequestURL), osVersion,
"the url param for %OS_VERSION%" + MSG_SHOULD_EQUAL);
run_test_pt10();
}
@ -347,7 +357,8 @@ function run_test_pt10() {
}
function check_test_pt10() {
do_check_eq(getResult(gRequestURL), "test_distro");
Assert.equal(getResult(gRequestURL), "test_distro",
"the url param for %DISTRIBUTION%" + MSG_SHOULD_EQUAL);
run_test_pt11();
}
@ -362,7 +373,8 @@ function run_test_pt11() {
}
function check_test_pt11() {
do_check_eq(getResult(gRequestURL), "test_distro_version");
Assert.equal(getResult(gRequestURL), "test_distro_version",
"the url param for %DISTRIBUTION_VERSION%" + MSG_SHOULD_EQUAL);
run_test_pt12();
}
@ -377,7 +389,8 @@ function run_test_pt12() {
}
function check_test_pt12() {
do_check_eq(getResult(gRequestURL), "?force=1");
Assert.equal(getResult(gRequestURL), "?force=1",
"the url query string for force" + MSG_SHOULD_EQUAL);
run_test_pt13();
}
@ -391,7 +404,9 @@ function run_test_pt13() {
}
function check_test_pt13() {
do_check_eq(getResult(gRequestURL), "?extra=param&force=1");
Assert.equal(getResult(gRequestURL), "?extra=param&force=1",
"the url query string for force with an extra string" +
MSG_SHOULD_EQUAL);
run_test_pt14();
}
@ -405,6 +420,8 @@ function run_test_pt14() {
}
function check_test_pt14() {
do_check_eq(getResult(gRequestURL), "?custom=custom&force=1");
Assert.equal(getResult(gRequestURL), "?custom=custom&force=1",
"the url query string for force with a custom string" +
MSG_SHOULD_EQUAL);
doTestFinish();
}

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

@ -7,6 +7,9 @@
* apply it.
*/
const START_STATE = STATE_PENDING;
const END_STATE = STATE_PENDING;
function run_test() {
if (MOZ_APP_NAME == "xulrunner") {
logTestInfo("Unable to run this test on xulrunner");
@ -27,16 +30,17 @@ function run_test() {
let channel = Services.prefs.getCharPref(PREF_APP_UPDATE_CHANNEL);
let patches = getLocalPatchString(null, null, null, null, null, "true",
STATE_PENDING);
START_STATE);
let updates = getLocalUpdateString(patches, null, null, null, null, null,
null, null, null, null, null, null,
null, "true", channel);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeVersionFile(getAppVersion());
writeStatusFile(STATE_PENDING);
writeStatusFile(START_STATE);
reloadUpdateManagerData();
do_check_true(!!gUpdateManager.activeUpdate);
Assert.ok(!!gUpdateManager.activeUpdate,
"the active update should be defined");
lockDirectory(getAppBaseDir());
@ -44,16 +48,6 @@ function run_test() {
}
function setupAppFilesFinished() {
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on a successful
// update (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
stageUpdate();
}
@ -66,14 +60,14 @@ function end_test() {
*/
function checkUpdateApplied() {
// Don't proceed until the update has failed, and reset to pending.
if (gUpdateManager.activeUpdate.state != STATE_PENDING) {
if (gUpdateManager.activeUpdate.state != END_STATE) {
if (++gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for update to equal: " +
STATE_PENDING +
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the " +
"active update status state to equal: " +
END_STATE +
", current state: " + gUpdateManager.activeUpdate.state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
@ -81,12 +75,9 @@ function checkUpdateApplied() {
}
function finishTest() {
if (IS_WIN || IS_MACOSX) {
// Check that the post update process was not launched.
do_check_false(getPostUpdateFile(".running").exists());
}
do_check_eq(readStatusState(), STATE_PENDING);
checkPostUpdateRunningFile(false);
Assert.equal(readStatusState(), END_STATE,
"the status state" + MSG_SHOULD_EQUAL);
checkFilesAfterUpdateFailure(getApplyDirFile, false, false);
unlockDirectory(getAppBaseDir());
standardInit();

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

@ -7,7 +7,8 @@
* apply it.
*/
Cu.import("resource://gre/modules/ctypes.jsm");
const START_STATE = STATE_PENDING;
const END_STATE = STATE_APPLIED;
function run_test() {
if (MOZ_APP_NAME == "xulrunner") {
@ -28,31 +29,23 @@ function run_test() {
let channel = Services.prefs.getCharPref(PREF_APP_UPDATE_CHANNEL);
let patches = getLocalPatchString(null, null, null, null, null, "true",
STATE_PENDING);
START_STATE);
let updates = getLocalUpdateString(patches, null, null, null, null, null,
null, null, null, null, null, null,
null, "true", channel);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeVersionFile(getAppVersion());
writeStatusFile(STATE_PENDING);
writeStatusFile(START_STATE);
reloadUpdateManagerData();
do_check_true(!!gUpdateManager.activeUpdate);
Assert.ok(!!gUpdateManager.activeUpdate,
"the active update should be defined");
setupAppFilesAsync();
}
function setupAppFilesFinished() {
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on a successful
// update (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
stageUpdate();
}
@ -74,7 +67,8 @@ function customLaunchAppToApplyUpdate() {
gHandle = CreateFile(getAppBaseDir().path, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, LPVOID(0),
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, LPVOID(0));
do_check_neq(gHandle.toString(), INVALID_HANDLE_VALUE.toString());
Assert.notEqual(gHandle.toString(), INVALID_HANDLE_VALUE.toString(),
"the handle should not equal INVALID_HANDLE_VALUE");
kernel32.close();
debugDump("finish - locking installation directory");
}
@ -85,28 +79,27 @@ function customLaunchAppToApplyUpdate() {
function checkUpdateApplied() {
gTimeoutRuns++;
// Don't proceed until the active update's state is the expected value.
if (gUpdateManager.activeUpdate.state != STATE_APPLIED) {
if (gUpdateManager.activeUpdate.state != END_STATE) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for update to equal: " +
STATE_APPLIED +
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the " +
"active update status state to equal: " +
END_STATE +
", current state: " + gUpdateManager.activeUpdate.state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
// Don't proceed until the update's status state is the expected value.
let state = readStatusState();
if (state != STATE_APPLIED) {
if (state != END_STATE) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update " +
"status state to equal: " +
STATE_APPLIED +
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update" +
"status file state to equal: " +
END_STATE +
", current status state: " + state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
@ -123,60 +116,42 @@ function checkUpdateApplied() {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update log " +
"to be created. Path: " + log.path);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
if (IS_WIN || IS_MACOSX) {
// Check that the post update process was not launched when staging an
// update.
do_check_false(getPostUpdateFile(".running").exists());
}
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true, false);
log = getUpdatesPatchDir();
log.append(FILE_UPDATE_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
log = getUpdatesDir();
log.append(FILE_LAST_LOG);
if (IS_WIN || IS_MACOSX) {
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
} else {
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
}
log = getUpdatesDir();
log.append(FILE_BACKUP_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
let updatesDir = getStageDirFile(DIR_UPDATES + "/0", true);
debugDump("testing " + updatesDir.path + " shouldn't exist");
do_check_false(updatesDir.exists());
log = getStageDirFile(DIR_UPDATES + "/0/" + FILE_UPDATE_LOG, true);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
let updatesDir = getStageDirFile(DIR_UPDATES + "/" + DIR_PATCH, true);
Assert.ok(!updatesDir.exists(), MSG_SHOULD_NOT_EXIST);
log = getStageDirFile(DIR_UPDATES + "/" + FILE_LAST_LOG, true);
if (IS_WIN || IS_MACOSX) {
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
} else {
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
}
log = getStageDirFile(DIR_UPDATES + "/" + FILE_BACKUP_LOG, true);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
// Switch the application to the staged application that was updated by
// launching the application.
@ -206,13 +181,12 @@ function finishCheckUpdateFinished() {
let state = readStatusState();
if (state != STATE_SUCCEEDED) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update " +
"status state to equal: " +
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the " +
"update status file state to equal: " +
STATE_SUCCEEDED +
", current status state: " + state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
@ -221,11 +195,10 @@ function finishCheckUpdateFinished() {
let updatedDir = getStageDirFile(null, true);
if (updatedDir.exists()) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded while waiting for updated dir to not exist. Path: " +
updatedDir.path);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the updated " +
"directory to not exist. Path: " + updatedDir.path);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
@ -235,9 +208,9 @@ function finishCheckUpdateFinished() {
updater.append(FILE_UPDATER_BIN);
if (updater.exists()) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded while waiting for updater binary to no longer be " +
"in use");
} else {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the " +
"updater binary to no longer be in use");
}
try {
updater.remove(false);
} catch (e) {
@ -246,17 +219,9 @@ function finishCheckUpdateFinished() {
}
}
}
}
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
checkPostUpdateRunningFile(true);
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
checkCallbackAppLog();
@ -264,26 +229,23 @@ function finishCheckUpdateFinished() {
standardInit();
let update = gUpdateManager.getUpdateAt(0);
do_check_eq(update.state, STATE_SUCCEEDED);
Assert.equal(update.state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
let updatesDir = getUpdatesPatchDir();
debugDump("testing " + updatesDir.path + " should exist");
do_check_true(updatesDir.exists());
Assert.ok(updatesDir.exists(), MSG_SHOULD_EXIST);
let log = getUpdatesPatchDir();
log.append(FILE_UPDATE_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
log = getUpdatesDir();
log.append(FILE_LAST_LOG);
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
log = getUpdatesDir();
log.append(FILE_BACKUP_LOG);
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
waitForFilesInUse();
}

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

@ -7,6 +7,9 @@
* apply it.
*/
const START_STATE = STATE_PENDING;
const END_STATE = STATE_APPLIED;
function run_test() {
if (MOZ_APP_NAME == "xulrunner") {
logTestInfo("Unable to run this test on xulrunner");
@ -26,31 +29,23 @@ function run_test() {
let channel = Services.prefs.getCharPref(PREF_APP_UPDATE_CHANNEL);
let patches = getLocalPatchString(null, null, null, null, null, "true",
STATE_PENDING);
START_STATE);
let updates = getLocalUpdateString(patches, null, null, null, null, null,
null, null, null, null, null, null,
null, "true", channel);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeVersionFile(getAppVersion());
writeStatusFile(STATE_PENDING);
writeStatusFile(START_STATE);
reloadUpdateManagerData();
do_check_true(!!gUpdateManager.activeUpdate);
Assert.ok(!!gUpdateManager.activeUpdate,
"the active update should be defined");
setupAppFilesAsync();
}
function setupAppFilesFinished() {
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on a successful
// update (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
stageUpdate();
}
@ -60,28 +55,27 @@ function setupAppFilesFinished() {
function checkUpdateApplied() {
gTimeoutRuns++;
// Don't proceed until the active update's state is the expected value.
if (gUpdateManager.activeUpdate.state != STATE_APPLIED) {
if (gUpdateManager.activeUpdate.state != END_STATE) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for update to equal: " +
STATE_APPLIED +
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the " +
"active update status state to equal: " +
END_STATE +
", current state: " + gUpdateManager.activeUpdate.state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
// Don't proceed until the update's status state is the expected value.
let state = readStatusState();
if (state != STATE_APPLIED) {
if (state != END_STATE) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update " +
"status state to equal: " +
STATE_APPLIED +
END_STATE +
", current status state: " + state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
@ -98,60 +92,42 @@ function checkUpdateApplied() {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update log " +
"to be created. Path: " + log.path);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
if (IS_WIN || IS_MACOSX) {
// Check that the post update process was not launched when staging an
// update.
do_check_false(getPostUpdateFile(".running").exists());
}
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true, false);
log = getUpdatesPatchDir();
log.append(FILE_UPDATE_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
log = getUpdatesDir();
log.append(FILE_LAST_LOG);
if (IS_WIN || IS_MACOSX) {
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
} else {
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
}
log = getUpdatesDir();
log.append(FILE_BACKUP_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
let updatesDir = getStageDirFile(DIR_UPDATES + "/0", true);
debugDump("testing " + updatesDir.path + " shouldn't exist");
do_check_false(updatesDir.exists());
log = getStageDirFile(DIR_UPDATES + "/0/" + FILE_UPDATE_LOG, true);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
let updatesDir = getStageDirFile(DIR_UPDATES + "/" + DIR_PATCH, true);
Assert.ok(!updatesDir.exists(), MSG_SHOULD_NOT_EXIST);
log = getStageDirFile(DIR_UPDATES + "/" + FILE_LAST_LOG, true);
if (IS_WIN || IS_MACOSX) {
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
} else {
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
}
log = getStageDirFile(DIR_UPDATES + "/" + FILE_BACKUP_LOG, true);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
// Switch the application to the staged application that was updated by
// launching the application.
@ -181,12 +157,12 @@ function finishCheckUpdateApplied() {
let state = readStatusState();
if (state != STATE_SUCCEEDED) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update " +
"status state to equal: " + STATE_SUCCEEDED +
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the " +
"update status file state to equal: " +
STATE_SUCCEEDED +
", current status state: " + state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
@ -195,11 +171,10 @@ function finishCheckUpdateApplied() {
let updatedDir = getStageDirFile(null, true);
if (updatedDir.exists()) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded while waiting for updated dir to not exist. Path: " +
updatedDir.path);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the updated " +
"directory to not exist. Path: " + updatedDir.path);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
@ -209,9 +184,9 @@ function finishCheckUpdateApplied() {
updater.append(FILE_UPDATER_BIN);
if (updater.exists()) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded while waiting for updater binary to no longer be " +
"in use");
} else {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the " +
"updater binary to no longer be in use");
}
try {
updater.remove(false);
} catch (e) {
@ -220,17 +195,9 @@ function finishCheckUpdateApplied() {
}
}
}
}
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
checkPostUpdateRunningFile(true);
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
gSwitchApp = true;
checkUpdateLogContents();
@ -240,30 +207,26 @@ function finishCheckUpdateApplied() {
standardInit();
let update = gUpdateManager.getUpdateAt(0);
do_check_eq(update.state, STATE_SUCCEEDED);
Assert.equal(update.state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
let updatesDir = getUpdatesPatchDir();
debugDump("testing " + updatesDir.path + " should exist");
do_check_true(updatesDir.exists());
Assert.ok(updatesDir.exists(), MSG_SHOULD_EXIST);
let log = getUpdatesPatchDir();
log.append(FILE_UPDATE_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
log = getUpdatesDir();
log.append(FILE_LAST_LOG);
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
log = getUpdatesDir();
log.append(FILE_BACKUP_LOG);
if (IS_WIN || IS_MACOSX) {
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
} else {
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
}
waitForFilesInUse();

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

@ -7,6 +7,9 @@
* apply it.
*/
const START_STATE = STATE_PENDING;
const END_STATE = STATE_SUCCEEDED;
function run_test() {
if (MOZ_APP_NAME == "xulrunner") {
logTestInfo("Unable to run this test on xulrunner");
@ -19,26 +22,17 @@ function run_test() {
setupUpdaterTest(FILE_COMPLETE_MAR);
createUpdaterINI();
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on a successful
// update (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
let channel = Services.prefs.getCharPref(PREF_APP_UPDATE_CHANNEL);
let patches = getLocalPatchString(null, null, null, null, null, "true",
STATE_PENDING);
START_STATE);
let updates = getLocalUpdateString(patches, null, null, null, null, null,
null, null, null, null, null, null,
null, "true", channel);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeVersionFile(getAppVersion());
writeStatusFile(STATE_PENDING);
writeStatusFile(START_STATE);
setupAppFilesAsync();
}
@ -68,10 +62,10 @@ function finishCheckUpdateFinished() {
gTimeoutRuns++;
// Don't proceed until the update's status state is the expected value.
let state = readStatusState();
if (state != STATE_SUCCEEDED) {
if (state != END_STATE) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update " +
"status state to equal: " + STATE_SUCCEEDED +
"status state to equal: " + END_STATE +
", current status state: " + state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
@ -86,9 +80,8 @@ function finishCheckUpdateFinished() {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update log " +
"to be created. Path: " + log.path);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
@ -100,7 +93,7 @@ function finishCheckUpdateFinished() {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded while waiting for updater binary to no longer be " +
"in use");
} else {
}
try {
updater.remove(false);
} catch (e) {
@ -109,17 +102,8 @@ function finishCheckUpdateFinished() {
}
}
}
}
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
checkCallbackAppLog();
@ -127,26 +111,23 @@ function finishCheckUpdateFinished() {
standardInit();
let update = gUpdateManager.getUpdateAt(0);
do_check_eq(update.state, STATE_SUCCEEDED);
Assert.equal(update.state, END_STATE,
"the update state" + MSG_SHOULD_EQUAL);
let updatesPatchDir = getUpdatesPatchDir();
debugDump("testing " + updatesPatchDir.path + " should exist");
do_check_true(updatesPatchDir.exists());
let updatesDir = getUpdatesPatchDir();
Assert.ok(updatesDir.exists(), MSG_SHOULD_EXIST);
log = getUpdatesPatchDir();
log.append(FILE_UPDATE_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
log = getUpdatesDir();
log.append(FILE_LAST_LOG);
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
log = getUpdatesDir();
log.append(FILE_BACKUP_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
waitForFilesInUse();
}

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

@ -4,6 +4,9 @@
/* Application in use complete MAR file staged patch apply failure fallback test */
const START_STATE = STATE_APPLIED;
const END_STATE = STATE_PENDING;
function run_test() {
gStageUpdate = true;
setupTestCommon();
@ -25,12 +28,12 @@ function run_test() {
}
function doUpdate() {
runUpdate(0, STATE_APPLIED, null);
runUpdate(0, START_STATE, null);
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(1, STATE_PENDING);
runUpdate(1, END_STATE, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -4,6 +4,9 @@
/* Application in use complete MAR file staged patch apply failure test */
const START_STATE = STATE_APPLIED;
const END_STATE = STATE_FAILED_WRITE_ERROR;
function run_test() {
gStageUpdate = true;
setupTestCommon();
@ -25,13 +28,13 @@ function run_test() {
}
function doUpdate() {
runUpdate(0, STATE_APPLIED, null);
runUpdate(0, START_STATE, null);
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
gDisableReplaceFallback = true;
runUpdate(1, STATE_FAILED_WRITE_ERROR);
runUpdate(1, END_STATE, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -15,16 +15,7 @@ function run_test() {
setupUpdaterTest(FILE_COMPLETE_MAR);
createUpdaterINI(false);
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on a successful
// update (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
if (IS_UNIX) {
removeSymlink();
@ -62,18 +53,13 @@ function doUpdate() {
checkFilesAfterUpdateSuccess(getStageDirFile, true, false);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
if (IS_WIN || IS_MACOSX) {
// Check that the post update process was not launched when staging an
// update.
do_check_false(getPostUpdateFile(".running").exists());
}
checkPostUpdateRunningFile(false);
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
do_timeout(TEST_CHECK_TIMEOUT, function() {
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateApplied);
});
}
@ -95,15 +81,7 @@ function checkUpdateApplied() {
* the test.
*/
function finishCheckUpdateApplied() {
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
setupHelperFinish();
}
@ -124,7 +102,8 @@ function runHelperProcess(args) {
process.init(helperBin);
debugDump("Running " + helperBin.path + " " + args.join(" "));
process.run(true, args, args.length);
do_check_eq(process.exitValue, 0);
Assert.equal(process.exitValue, 0,
"the helper process exit value should be 0");
}
function createSymlink() {

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

@ -24,33 +24,16 @@ function run_test() {
}
function doUpdate() {
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on a successful
// update (bug 600098).
if (IS_MACOSX) {
let applyToDir = getApplyDirFile();
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
applyToDir.lastModifiedTime = yesterday;
}
runUpdate(0, STATE_SUCCEEDED);
setAppBundleModTime();
runUpdate(0, STATE_SUCCEEDED, checkUpdateFinished);
}
function checkUpdateApplied() {
function checkUpdateFinished() {
setupHelperFinish();
}
function checkUpdate() {
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
standardInit();

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

@ -18,7 +18,7 @@ function run_test() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -18,7 +18,7 @@ function run_test() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -12,10 +12,10 @@ function run_test() {
gCallbackBinFile = "exe0.exe";
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateFinished);
}
function checkUpdateApplied() {
function checkUpdateFinished() {
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
standardInit();
checkCallbackAppLog();

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

@ -12,10 +12,10 @@ function run_test() {
gCallbackBinFile = "exe0.exe";
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateFinished);
}
function checkUpdateApplied() {
function checkUpdateFinished() {
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
standardInit();
checkCallbackAppLog();

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

@ -14,40 +14,20 @@ function run_test() {
setupUpdaterTest(FILE_PARTIAL_MAR);
createUpdaterINI();
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on all updates since
// the precomplete file in the root of the bundle is renamed, etc. (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
// Note that on platforms where we use execv, we cannot trust the return code.
runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_LOADSOURCE_ERROR_WRONG_SIZE);
runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_LOADSOURCE_ERROR_WRONG_SIZE,
checkUpdateFinished);
}
/**
* Checks if the update has finished and if it has finished performs checks for
* the test.
*/
function checkUpdateApplied() {
if (IS_WIN || IS_MACOSX) {
// Check that the post update process was not launched.
do_check_false(getPostUpdateFile(".running").exists());
}
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
function checkUpdateFinished() {
checkPostUpdateRunningFile(false);
checkAppBundleModTime();
checkFilesAfterUpdateFailure(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_PARTIAL_FAILURE);
standardInit();

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

@ -31,7 +31,7 @@ function doUpdate() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(1, STATE_PENDING);
runUpdate(1, STATE_PENDING, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -31,7 +31,7 @@ function doUpdate() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(1, STATE_PENDING);
runUpdate(1, STATE_PENDING, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -32,7 +32,7 @@ function doUpdate() {
gStageUpdate = false;
gSwitchApp = true;
gDisableReplaceFallback = true;
runUpdate(1, STATE_FAILED_WRITE_ERROR);
runUpdate(1, STATE_FAILED_WRITE_ERROR, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -32,7 +32,7 @@ function doUpdate() {
gStageUpdate = false;
gSwitchApp = true;
gDisableReplaceFallback = true;
runUpdate(1, STATE_FAILED_WRITE_ERROR);
runUpdate(1, STATE_FAILED_WRITE_ERROR, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -24,10 +24,10 @@ function run_test() {
}
function doUpdate() {
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateFinished);
}
function checkUpdateApplied() {
function checkUpdateFinished() {
setupHelperFinish();
}

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

@ -24,10 +24,10 @@ function run_test() {
}
function doUpdate() {
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateFinished);
}
function checkUpdateApplied() {
function checkUpdateFinished() {
setupHelperFinish();
}

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

@ -34,10 +34,10 @@ function run_test() {
}
function doUpdate() {
runUpdate(1, STATE_FAILED_WRITE_ERROR);
runUpdate(1, STATE_FAILED_WRITE_ERROR, checkUpdateFinished);
}
function checkUpdateApplied() {
function checkUpdateFinished() {
setupHelperFinish();
}

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

@ -34,10 +34,10 @@ function run_test() {
}
function doUpdate() {
runUpdate(1, STATE_FAILED_READ_ERROR);
runUpdate(1, STATE_FAILED_READ_ERROR, checkUpdateFinished);
}
function checkUpdateApplied() {
function checkUpdateFinished() {
setupHelperFinish();
}

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

@ -40,7 +40,7 @@ function doUpdate() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(1, STATE_PENDING);
runUpdate(1, STATE_PENDING, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -40,7 +40,7 @@ function doUpdate() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(1, STATE_PENDING);
runUpdate(1, STATE_PENDING, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -41,7 +41,7 @@ function doUpdate() {
gStageUpdate = false;
gSwitchApp = true;
gDisableReplaceFallback = true;
runUpdate(1, STATE_FAILED_WRITE_ERROR);
runUpdate(1, STATE_FAILED_WRITE_ERROR, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -41,7 +41,7 @@ function doUpdate() {
gStageUpdate = false;
gSwitchApp = true;
gDisableReplaceFallback = true;
runUpdate(1, STATE_FAILED_WRITE_ERROR);
runUpdate(1, STATE_FAILED_WRITE_ERROR, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -42,7 +42,7 @@ function doUpdate() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(1, STATE_PENDING);
runUpdate(1, STATE_PENDING, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -40,7 +40,7 @@ function doUpdate() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(1, STATE_PENDING);
runUpdate(1, STATE_PENDING, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -43,7 +43,7 @@ function doUpdate() {
gStageUpdate = false;
gSwitchApp = true;
gDisableReplaceFallback = true;
runUpdate(1, STATE_FAILED_WRITE_ERROR);
runUpdate(1, STATE_FAILED_WRITE_ERROR, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -41,7 +41,7 @@ function doUpdate() {
gStageUpdate = false;
gSwitchApp = true;
gDisableReplaceFallback = true;
runUpdate(1, STATE_FAILED_WRITE_ERROR);
runUpdate(1, STATE_FAILED_WRITE_ERROR, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -34,10 +34,10 @@ function run_test() {
}
function doUpdate() {
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateFinished);
}
function checkUpdateApplied() {
function checkUpdateFinished() {
setupHelperFinish();
}

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

@ -32,10 +32,10 @@ function run_test() {
}
function doUpdate() {
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateFinished);
}
function checkUpdateApplied() {
function checkUpdateFinished() {
setupHelperFinish();
}

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

@ -16,29 +16,15 @@ function run_test() {
createUpdaterINI(true);
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on all updates since
// the precomplete file in the root of the bundle is renamed, etc. (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
runUpdate(1, STATE_FAILED_LOADSOURCE_ERROR_WRONG_SIZE);
runUpdate(1, STATE_FAILED_LOADSOURCE_ERROR_WRONG_SIZE, checkUpdateFinished);
}
/**
* Checks if the update has finished and if it has finished performs checks for
* the test.
*/
function checkUpdateApplied() {
if (IS_WIN || IS_MACOSX) {
// Check that the post update process was not launched.
do_check_false(getPostUpdateFile(".running").exists());
}
function checkUpdateFinished() {
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile, true, false);
checkUpdateLogContents(LOG_PARTIAL_FAILURE);
standardInit();

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

@ -25,16 +25,7 @@ function run_test() {
}
createUpdaterINI(false);
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on a successful
// update (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
// Don't test symlinks on Mac OS X in this test since it tends to timeout.
// It is tested on Mac OS X in marAppInUseStageSuccessComplete_unix.js
@ -60,18 +51,13 @@ function run_test() {
checkFilesAfterUpdateSuccess(getStageDirFile, true, false);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
if (IS_WIN || IS_MACOSX) {
// Check that the post update process was not launched when staging an
// update.
do_check_false(getPostUpdateFile(".running").exists());
}
checkPostUpdateRunningFile(false);
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
do_timeout(TEST_CHECK_TIMEOUT, function() {
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateApplied);
});
}
@ -93,29 +79,18 @@ function checkUpdateApplied() {
* the test.
*/
function finishCheckUpdateApplied() {
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
checkPostUpdateRunningFile(true);
if (IS_MACOSX) {
debugDump("testing that the distribution directory is removed from the " +
"old location when there is a distribution directory in the " +
"new location");
let distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
debugDump("testing " + distributionDir.path + " shouldn't exist");
do_check_false(distributionDir.exists());
Assert.ok(!distributionDir.exists(), MSG_SHOULD_NOT_EXIST);
checkUpdateLogContains("removing old distribution directory");
}
if (IS_UNIX && !IS_MACOSX) {
checkSymlink();
}
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
standardInit();
@ -129,7 +104,8 @@ function runHelperProcess(args) {
process.init(helperBin);
debugDump("Running " + helperBin.path + " " + args.join(" "));
process.run(true, args, args.length);
do_check_eq(process.exitValue, 0);
Assert.equal(process.exitValue, 0,
"the helper process exit value should be 0");
}
function createSymlink() {

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

@ -25,33 +25,19 @@ function run_test() {
}
createUpdaterINI(false);
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on all updates since
// the precomplete file in the root of the bundle is renamed, etc. (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
runUpdate(0, STATE_APPLIED, null);
checkFilesAfterUpdateSuccess(getStageDirFile, true, false);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS, true);
if (IS_WIN || IS_MACOSX) {
// Check that the post update process was not launched when staging an
// update.
do_check_false(getPostUpdateFile(".running").exists());
}
checkPostUpdateRunningFile(false);
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
do_timeout(TEST_CHECK_TIMEOUT, function() {
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateApplied);
});
}
@ -73,42 +59,29 @@ function checkUpdateApplied() {
* the test.
*/
function finishCheckUpdateApplied() {
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
checkPostUpdateRunningFile(true);
let distributionDir = getApplyDirFile(DIR_RESOURCES + "distribution", true);
if (IS_MACOSX) {
debugDump("testing that the distribution directory is moved from the " +
"old location to the new location");
debugDump("testing " + distributionDir.path + " should exist");
do_check_true(distributionDir.exists());
Assert.ok(distributionDir.exists(), MSG_SHOULD_EXIST);
let testFile = getApplyDirFile(DIR_RESOURCES + "distribution/testFile", true);
debugDump("testing " + testFile.path + " should exist");
do_check_true(testFile.exists());
Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
testFile = getApplyDirFile(DIR_RESOURCES + "distribution/test/testFile", true);
debugDump("testing " + testFile.path + " should exist");
do_check_true(testFile.exists());
Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
debugDump("testing " + distributionDir.path + " shouldn't exist");
do_check_false(distributionDir.exists());
Assert.ok(!distributionDir.exists(), MSG_SHOULD_NOT_EXIST);
checkUpdateLogContains("Moving old distribution directory to new location");
} else {
debugDump("testing that files aren't added with an add-if instruction " +
"when the file's destination directory doesn't exist");
debugDump("testing " + distributionDir.path + " shouldn't exist");
do_check_false(distributionDir.exists());
Assert.ok(!distributionDir.exists(), MSG_SHOULD_NOT_EXIST);
}
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS, true);
standardInit();

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

@ -21,30 +21,21 @@ function run_test() {
}
createUpdaterINI();
setAppBundleModTime();
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on a successful
// update (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateFinished);
}
/**
* Checks if the post update binary was properly launched for the platforms that
* support launching post update process.
*/
function checkUpdateApplied() {
function checkUpdateFinished() {
if (IS_WIN || IS_MACOSX) {
gCheckFunc = finishCheckUpdateApplied;
gCheckFunc = finishCheckUpdateFinished;
checkPostUpdateAppLog();
} else {
finishCheckUpdateApplied();
finishCheckUpdateFinished();
}
}
@ -52,43 +43,28 @@ function checkUpdateApplied() {
* Checks if the update has finished and if it has finished performs checks for
* the test.
*/
function finishCheckUpdateApplied() {
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
function finishCheckUpdateFinished() {
let distributionDir = getApplyDirFile(DIR_RESOURCES + "distribution", true);
if (IS_MACOSX) {
debugDump("testing that the distribution directory is moved from the " +
"old location to the new location");
debugDump("testing " + distributionDir.path + " should exist");
do_check_true(distributionDir.exists());
Assert.ok(distributionDir.exists(), MSG_SHOULD_EXIST);
let testFile = getApplyDirFile(DIR_RESOURCES + "distribution/testFile", true);
debugDump("testing " + testFile.path + " should exist");
do_check_true(testFile.exists());
Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
testFile = getApplyDirFile(DIR_RESOURCES + "distribution/test/testFile", true);
debugDump("testing " + testFile.path + " should exist");
do_check_true(testFile.exists());
Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
debugDump("testing " + distributionDir.path + " shouldn't exist");
do_check_false(distributionDir.exists());
Assert.ok(!distributionDir.exists(), MSG_SHOULD_NOT_EXIST);
checkUpdateLogContains("Moving old distribution directory to new location");
} else {
debugDump("testing that files aren't added with an add-if instruction " +
"when the file's destination directory doesn't exist");
debugDump("testing " + distributionDir.path + " shouldn't exist");
do_check_false(distributionDir.exists());
Assert.ok(!distributionDir.exists(), MSG_SHOULD_NOT_EXIST);
}
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS, true);
standardInit();

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

@ -27,30 +27,21 @@ function run_test() {
}
createUpdaterINI(true);
setAppBundleModTime();
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on all updates since
// the precomplete file in the root of the bundle is renamed, etc. (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateFinished);
}
/**
* Checks if the post update binary was properly launched for the platforms that
* support launching post update process.
*/
function checkUpdateApplied() {
function checkUpdateFinished() {
if (IS_WIN || IS_MACOSX) {
gCheckFunc = finishCheckUpdateApplied;
gCheckFunc = finishCheckUpdateFinished;
checkPostUpdateAppLog();
} else {
finishCheckUpdateApplied();
finishCheckUpdateFinished();
}
}
@ -58,27 +49,14 @@ function checkUpdateApplied() {
* Checks if the update has finished and if it has finished performs checks for
* the test.
*/
function finishCheckUpdateApplied() {
function finishCheckUpdateFinished() {
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
if (IS_MACOSX) {
debugDump("testing that the distribution directory is removed from the " +
"old location when there is a distribution directory in the " +
"new location");
let distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
debugDump("testing " + distributionDir.path + " shouldn't exist");
do_check_false(distributionDir.exists());
Assert.ok(!distributionDir.exists(), MSG_SHOULD_NOT_EXIST);
checkUpdateLogContains("removing old distribution directory");
}
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS);
standardInit();

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

@ -23,7 +23,8 @@ function run_test() {
// Note that if execv is used, the updater process will turn into the
// callback process, so its return code will be that of the callback
// app.
runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_VERSION_DOWNGRADE_ERROR);
runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_VERSION_DOWNGRADE_ERROR,
checkUpdateApplied);
}
/**
@ -31,11 +32,7 @@ function run_test() {
* the test.
*/
function checkUpdateApplied() {
if (IS_WIN || IS_MACOSX) {
// Check that the post update process was not launched.
do_check_false(getPostUpdateFile(".running").exists());
}
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
standardInit();
doTestFinish();

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

@ -23,7 +23,8 @@ function run_test() {
// Note that if execv is used, the updater process will turn into the
// callback process, so its return code will be that of the callback
// app.
runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_CHANNEL_MISMATCH_ERROR);
runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_CHANNEL_MISMATCH_ERROR,
checkUpdateApplied);
}
/**
@ -31,11 +32,7 @@ function run_test() {
* the test.
*/
function checkUpdateApplied() {
if (IS_WIN || IS_MACOSX) {
// Check that the post update process was not launched.
do_check_false(getPostUpdateFile(".running").exists());
}
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
standardInit();
doTestFinish();

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

@ -19,7 +19,7 @@ function run_test() {
let updaterBin = binDir.clone();
updaterBin.append(FILE_UPDATER_BIN);
logTestInfo("Launching maintenance service bin: " +
debugDump("Launching maintenance service bin: " +
maintenanceServiceBin.path + " to check updater: " +
updaterBin.path + " signature.");
@ -36,5 +36,6 @@ function run_test() {
maintenanceServiceBinProcess.init(maintenanceServiceBin);
maintenanceServiceBinProcess.run(true, maintenanceServiceBinArgs,
maintenanceServiceBinArgs.length);
do_check_eq(maintenanceServiceBinProcess.exitValue, 0);
Assert.equal(maintenanceServiceBinProcess.exitValue, 0,
"the maintenance service exit value should be 0");
}

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

@ -7,6 +7,9 @@
* apply it.
*/
const START_STATE = STATE_PENDING_SVC;
const END_STATE = STATE_PENDING;
function run_test() {
if (MOZ_APP_NAME == "xulrunner") {
logTestInfo("Unable to run this test on xulrunner");
@ -31,16 +34,17 @@ function run_test() {
let channel = Services.prefs.getCharPref(PREF_APP_UPDATE_CHANNEL);
let patches = getLocalPatchString(null, null, null, null, null, "true",
STATE_PENDING_SVC);
START_STATE);
let updates = getLocalUpdateString(patches, null, null, null, null, null,
null, null, null, null, null, null,
null, "true", channel);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeVersionFile(getAppVersion());
writeStatusFile(STATE_PENDING_SVC);
writeStatusFile(START_STATE);
reloadUpdateManagerData();
do_check_true(!!gUpdateManager.activeUpdate);
Assert.ok(!!gUpdateManager.activeUpdate,
"the active update should be defined");
lockDirectory(getAppBaseDir());
@ -48,16 +52,6 @@ function run_test() {
}
function setupAppFilesFinished() {
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on a successful
// update (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
stageUpdate();
}
@ -70,14 +64,14 @@ function end_test() {
*/
function checkUpdateApplied() {
// Don't proceed until the update has failed, and reset to pending.
if (gUpdateManager.activeUpdate.state != STATE_PENDING) {
if (gUpdateManager.activeUpdate.state != END_STATE) {
if (++gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for update to equal: " +
STATE_PENDING +
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the " +
"active update status state to equal: " +
END_STATE +
", current state: " + gUpdateManager.activeUpdate.state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
@ -85,14 +79,9 @@ function checkUpdateApplied() {
}
function finishTest() {
if (IS_WIN || IS_MACOSX) {
let running = getPostUpdateFile(".running");
debugDump("checking that the post update process running file doesn't " +
"exist. Path: " + running.path);
do_check_false(running.exists());
}
do_check_eq(readStatusState(), STATE_PENDING);
checkPostUpdateRunningFile(false);
Assert.equal(readStatusState(), END_STATE,
"the status state" + MSG_SHOULD_EQUAL);
checkFilesAfterUpdateFailure(getApplyDirFile, false, false);
unlockDirectory(getAppBaseDir());
standardInit();

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

@ -7,7 +7,8 @@
* apply it.
*/
Cu.import("resource://gre/modules/ctypes.jsm");
const START_STATE = STATE_PENDING_SVC;
const END_STATE = STATE_APPLIED_SVC;
function run_test() {
if (MOZ_APP_NAME == "xulrunner") {
@ -32,31 +33,23 @@ function run_test() {
let channel = Services.prefs.getCharPref(PREF_APP_UPDATE_CHANNEL);
let patches = getLocalPatchString(null, null, null, null, null, "true",
STATE_PENDING_SVC);
START_STATE);
let updates = getLocalUpdateString(patches, null, null, null, null, null,
null, null, null, null, null, null,
null, "true", channel);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeVersionFile(getAppVersion());
writeStatusFile(STATE_PENDING_SVC);
writeStatusFile(START_STATE);
reloadUpdateManagerData();
do_check_true(!!gUpdateManager.activeUpdate);
Assert.ok(!!gUpdateManager.activeUpdate,
"the active update should be defined");
setupAppFilesAsync();
}
function setupAppFilesFinished() {
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on a successful
// update (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
stageUpdate();
}
@ -78,7 +71,8 @@ function customLaunchAppToApplyUpdate() {
gHandle = CreateFile(getAppBaseDir().path, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, LPVOID(0),
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, LPVOID(0));
do_check_neq(gHandle.toString(), INVALID_HANDLE_VALUE.toString());
Assert.notEqual(gHandle.toString(), INVALID_HANDLE_VALUE.toString(),
"the handle should not equal INVALID_HANDLE_VALUE");
kernel32.close();
debugDump("finish - locking installation directory");
}
@ -89,28 +83,27 @@ function customLaunchAppToApplyUpdate() {
function checkUpdateApplied() {
gTimeoutRuns++;
// Don't proceed until the active update's state is the expected value.
if (gUpdateManager.activeUpdate.state != STATE_APPLIED_SVC) {
if (gUpdateManager.activeUpdate.state != END_STATE) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for update to equal: " +
STATE_APPLIED_SVC +
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the " +
"active update status state to equal: " +
END_STATE +
", current state: " + gUpdateManager.activeUpdate.state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
// Don't proceed until the update's status state is the expected value.
let state = readStatusState();
if (state != STATE_APPLIED_SVC) {
if (state != END_STATE) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update " +
"status state to equal: " +
STATE_APPLIED_SVC +
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update" +
"status file state to equal: " +
END_STATE +
", current status state: " + state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
@ -127,61 +120,42 @@ function checkUpdateApplied() {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update log " +
"to be created. Path: " + log.path);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
if (IS_WIN || IS_MACOSX) {
let running = getPostUpdateFile(".running");
debugDump("checking that the post update process running file doesn't " +
"exist. Path: " + running.path);
do_check_false(running.exists());
}
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true, false);
log = getUpdatesPatchDir();
log.append(FILE_UPDATE_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
log = getUpdatesDir();
log.append(FILE_LAST_LOG);
if (IS_WIN || IS_MACOSX) {
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
} else {
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
}
log = getUpdatesDir();
log.append(FILE_BACKUP_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
let updatesDir = getStageDirFile(DIR_UPDATES + "/0", true);
debugDump("testing " + updatesDir.path + " shouldn't exist");
do_check_false(updatesDir.exists());
log = getStageDirFile(DIR_UPDATES + "/0/" + FILE_UPDATE_LOG, true);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
let updatesDir = getStageDirFile(DIR_UPDATES + "/" + DIR_PATCH, true);
Assert.ok(!updatesDir.exists(), MSG_SHOULD_NOT_EXIST);
log = getStageDirFile(DIR_UPDATES + "/" + FILE_LAST_LOG, true);
if (IS_WIN || IS_MACOSX) {
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
} else {
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
}
log = getStageDirFile(DIR_UPDATES + "/" + FILE_BACKUP_LOG, true);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
// Switch the application to the staged application that was updated by
// launching the application.
@ -211,13 +185,12 @@ function finishCheckUpdateFinished() {
let state = readStatusState();
if (state != STATE_SUCCEEDED) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update " +
"status state to equal: " +
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the " +
"update status file state to equal: " +
STATE_SUCCEEDED +
", current status state: " + state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
@ -226,11 +199,10 @@ function finishCheckUpdateFinished() {
let updatedDir = getStageDirFile(null, true);
if (updatedDir.exists()) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded while waiting for updated dir to not exist. Path: " +
updatedDir.path);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the updated " +
"directory to not exist. Path: " + updatedDir.path);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
@ -240,9 +212,9 @@ function finishCheckUpdateFinished() {
updater.append(FILE_UPDATER_BIN);
if (updater.exists()) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded while waiting for updater binary to no longer be " +
"in use");
} else {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the " +
"updater binary to no longer be in use");
}
try {
updater.remove(false);
} catch (e) {
@ -251,24 +223,9 @@ function finishCheckUpdateFinished() {
}
}
}
}
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
if (IS_WIN || IS_MACOSX) {
let running = getPostUpdateFile(".running");
debugDump("checking that the post update process running file exists. " +
"Path: " + running.path);
do_check_true(running.exists());
}
checkPostUpdateRunningFile(true);
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
checkCallbackAppLog();
@ -276,26 +233,23 @@ function finishCheckUpdateFinished() {
standardInit();
let update = gUpdateManager.getUpdateAt(0);
do_check_eq(update.state, STATE_SUCCEEDED);
Assert.equal(update.state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
let updatesDir = getUpdatesPatchDir();
debugDump("testing " + updatesDir.path + " should exist");
do_check_true(updatesDir.exists());
Assert.ok(updatesDir.exists(), MSG_SHOULD_EXIST);
let log = getUpdatesPatchDir();
log.append(FILE_UPDATE_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
log = getUpdatesDir();
log.append(FILE_LAST_LOG);
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
log = getUpdatesDir();
log.append(FILE_BACKUP_LOG);
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
waitForFilesInUse();
}

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

@ -7,6 +7,9 @@
* apply it.
*/
const START_STATE = STATE_PENDING_SVC;
const END_STATE = STATE_APPLIED_SVC;
function run_test() {
if (MOZ_APP_NAME == "xulrunner") {
logTestInfo("Unable to run this test on xulrunner");
@ -30,31 +33,23 @@ function run_test() {
let channel = Services.prefs.getCharPref(PREF_APP_UPDATE_CHANNEL);
let patches = getLocalPatchString(null, null, null, null, null, "true",
STATE_PENDING_SVC);
START_STATE);
let updates = getLocalUpdateString(patches, null, null, null, null, null,
null, null, null, null, null, null,
null, "true", channel);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeVersionFile(getAppVersion());
writeStatusFile(STATE_PENDING_SVC);
writeStatusFile(START_STATE);
reloadUpdateManagerData();
do_check_true(!!gUpdateManager.activeUpdate);
Assert.ok(!!gUpdateManager.activeUpdate,
"the active update should be defined");
setupAppFilesAsync();
}
function setupAppFilesFinished() {
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on a successful
// update (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
stageUpdate();
}
@ -64,28 +59,27 @@ function setupAppFilesFinished() {
function checkUpdateApplied() {
gTimeoutRuns++;
// Don't proceed until the active update's state is the expected value.
if (gUpdateManager.activeUpdate.state != STATE_APPLIED_SVC) {
if (gUpdateManager.activeUpdate.state != END_STATE) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for update to equal: " +
STATE_APPLIED_SVC +
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the " +
"active update status state to equal: " +
END_STATE +
", current state: " + gUpdateManager.activeUpdate.state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
// Don't proceed until the update's status state is the expected value.
let state = readStatusState();
if (state != STATE_APPLIED_SVC) {
if (state != END_STATE) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update " +
"status state to equal: " +
STATE_APPLIED_SVC +
END_STATE +
", current status state: " + state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
@ -102,61 +96,42 @@ function checkUpdateApplied() {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update log " +
"to be created. Path: " + log.path);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateApplied);
return;
}
if (IS_WIN || IS_MACOSX) {
let running = getPostUpdateFile(".running");
debugDump("checking that the post update process running file doesn't " +
"exist. Path: " + running.path);
do_check_false(running.exists());
}
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true, false);
log = getUpdatesPatchDir();
log.append(FILE_UPDATE_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
log = getUpdatesDir();
log.append(FILE_LAST_LOG);
if (IS_WIN || IS_MACOSX) {
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
} else {
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
}
log = getUpdatesDir();
log.append(FILE_BACKUP_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
let updatesDir = getStageDirFile(DIR_UPDATES + "/0", true);
debugDump("testing " + updatesDir.path + " shouldn't exist");
do_check_false(updatesDir.exists());
log = getStageDirFile(DIR_UPDATES + "/0/" + FILE_UPDATE_LOG, true);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
let updatesDir = getStageDirFile(DIR_UPDATES + "/" + DIR_PATCH, true);
Assert.ok(!updatesDir.exists(), MSG_SHOULD_NOT_EXIST);
log = getStageDirFile(DIR_UPDATES + "/" + FILE_LAST_LOG, true);
if (IS_WIN || IS_MACOSX) {
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
} else {
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
}
log = getStageDirFile(DIR_UPDATES + "/" + FILE_BACKUP_LOG, true);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
// Switch the application to the staged application that was updated by
// launching the application.
@ -186,12 +161,12 @@ function finishCheckUpdateApplied() {
let state = readStatusState();
if (state != STATE_SUCCEEDED) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update " +
"status state to equal: " + STATE_SUCCEEDED +
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the " +
"update status file state to equal: " +
STATE_SUCCEEDED +
", current status state: " + state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
@ -200,11 +175,10 @@ function finishCheckUpdateApplied() {
let updatedDir = getStageDirFile(null, true);
if (updatedDir.exists()) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded while waiting for updated dir to not exist. Path: " +
updatedDir.path);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the updated " +
"directory to not exist. Path: " + updatedDir.path);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
@ -214,9 +188,9 @@ function finishCheckUpdateApplied() {
updater.append(FILE_UPDATER_BIN);
if (updater.exists()) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded while waiting for updater binary to no longer be " +
"in use");
} else {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the " +
"updater binary to no longer be in use");
}
try {
updater.remove(false);
} catch (e) {
@ -225,24 +199,9 @@ function finishCheckUpdateApplied() {
}
}
}
}
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
if (IS_WIN || IS_MACOSX) {
let running = getPostUpdateFile(".running");
debugDump("checking that the post update process running file exists. " +
"Path: " + running.path);
do_check_true(running.exists());
}
checkPostUpdateRunningFile(true);
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
gSwitchApp = true;
checkUpdateLogContents();
@ -252,30 +211,26 @@ function finishCheckUpdateApplied() {
standardInit();
let update = gUpdateManager.getUpdateAt(0);
do_check_eq(update.state, STATE_SUCCEEDED);
Assert.equal(update.state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
let updatesDir = getUpdatesPatchDir();
debugDump("testing " + updatesDir.path + " should exist");
do_check_true(updatesDir.exists());
Assert.ok(updatesDir.exists(), MSG_SHOULD_EXIST);
let log = getUpdatesPatchDir();
log.append(FILE_UPDATE_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
log = getUpdatesDir();
log.append(FILE_LAST_LOG);
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
log = getUpdatesDir();
log.append(FILE_BACKUP_LOG);
if (IS_WIN || IS_MACOSX) {
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
} else {
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
}
waitForFilesInUse();

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

@ -7,6 +7,9 @@
* apply it.
*/
const START_STATE = STATE_PENDING_SVC;
const END_STATE = STATE_SUCCEEDED;
function run_test() {
if (MOZ_APP_NAME == "xulrunner") {
logTestInfo("Unable to run this test on xulrunner");
@ -23,32 +26,23 @@ function run_test() {
setupUpdaterTest(FILE_COMPLETE_MAR);
createUpdaterINI();
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on a successful
// update (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
let channel = Services.prefs.getCharPref(PREF_APP_UPDATE_CHANNEL);
let patches = getLocalPatchString(null, null, null, null, null, "true",
STATE_PENDING);
START_STATE);
let updates = getLocalUpdateString(patches, null, null, null, null, null,
null, null, null, null, null, null,
null, "true", channel);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
writeVersionFile(getAppVersion());
writeStatusFile(STATE_PENDING_SVC);
writeStatusFile(START_STATE);
setupAppFilesAsync();
}
function setupAppFilesFinished() {
runUpdateUsingService(STATE_PENDING_SVC, STATE_SUCCEEDED);
runUpdateUsingService(START_STATE, END_STATE);
}
/**
@ -72,10 +66,10 @@ function finishCheckUpdateFinished() {
gTimeoutRuns++;
// Don't proceed until the update's status state is the expected value.
let state = readStatusState();
if (state != STATE_SUCCEEDED) {
if (state != END_STATE) {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update " +
"status state to equal: " + STATE_SUCCEEDED +
"status state to equal: " + END_STATE +
", current status state: " + state);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
@ -90,9 +84,8 @@ function finishCheckUpdateFinished() {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the update log " +
"to be created. Path: " + log.path);
} else {
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
}
do_timeout(TEST_CHECK_TIMEOUT, checkUpdateFinished);
return;
}
@ -104,7 +97,7 @@ function finishCheckUpdateFinished() {
if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
do_throw("Exceeded while waiting for updater binary to no longer be " +
"in use");
} else {
}
try {
updater.remove(false);
} catch (e) {
@ -113,17 +106,8 @@ function finishCheckUpdateFinished() {
}
}
}
}
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
checkCallbackAppLog();
@ -131,26 +115,23 @@ function finishCheckUpdateFinished() {
standardInit();
let update = gUpdateManager.getUpdateAt(0);
do_check_eq(update.state, STATE_SUCCEEDED);
Assert.equal(update.state, END_STATE,
"the update state" + MSG_SHOULD_EQUAL);
let updatesPatchDir = getUpdatesPatchDir();
debugDump("testing " + updatesPatchDir.path + " should exist");
do_check_true(updatesPatchDir.exists());
let updatesDir = getUpdatesPatchDir();
Assert.ok(updatesDir.exists(), MSG_SHOULD_EXIST);
log = getUpdatesPatchDir();
log.append(FILE_UPDATE_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
log = getUpdatesDir();
log.append(FILE_LAST_LOG);
debugDump("testing " + log.path + " should exist");
do_check_true(log.exists());
Assert.ok(log.exists(), MSG_SHOULD_EXIST);
log = getUpdatesDir();
log.append(FILE_BACKUP_LOG);
debugDump("testing " + log.path + " shouldn't exist");
do_check_false(log.exists());
Assert.ok(!log.exists(), MSG_SHOULD_NOT_EXIST);
waitForFilesInUse();
}

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

@ -4,6 +4,9 @@
/* Application in use complete MAR file staged patch apply failure fallback test */
const START_STATE = STATE_PENDING_SVC;
const END_STATE = STATE_PENDING;
function run_test() {
if (!shouldRunServiceTest()) {
return;
@ -33,14 +36,14 @@ function setupAppFilesFinished() {
}
function doUpdate() {
runUpdateUsingService(STATE_PENDING_SVC, STATE_APPLIED);
runUpdateUsingService(START_STATE, STATE_APPLIED);
}
function checkUpdateFinished() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(1, STATE_PENDING);
runUpdate(1, END_STATE, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -4,6 +4,9 @@
/* Application in use complete MAR file staged patch apply failure test */
const START_STATE = STATE_PENDING_SVC;
const END_STATE = STATE_FAILED_WRITE_ERROR;
function run_test() {
if (!shouldRunServiceTest()) {
return;
@ -33,7 +36,7 @@ function setupAppFilesFinished() {
}
function doUpdate() {
runUpdateUsingService(STATE_PENDING_SVC, STATE_APPLIED);
runUpdateUsingService(START_STATE, STATE_APPLIED);
}
function checkUpdateFinished() {
@ -41,7 +44,7 @@ function checkUpdateFinished() {
gStageUpdate = false;
gSwitchApp = true;
gDisableReplaceFallback = true;
runUpdate(1, STATE_FAILED_WRITE_ERROR);
runUpdate(1, END_STATE, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -32,16 +32,7 @@ function setupAppFilesFinished() {
}
function doUpdate() {
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on a successful
// update (bug 600098).
if (IS_MACOSX) {
let applyToDir = getApplyDirFile();
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
runUpdateUsingService(STATE_PENDING_SVC, STATE_SUCCEEDED);
}
@ -50,15 +41,7 @@ function checkUpdateFinished() {
}
function checkUpdate() {
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
standardInit();

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

@ -28,7 +28,7 @@ function checkUpdateFinished() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -28,7 +28,7 @@ function checkUpdateFinished() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -18,16 +18,7 @@ function run_test() {
setupUpdaterTest(FILE_PARTIAL_MAR);
createUpdaterINI();
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on all updates since
// the precomplete file in the root of the bundle is renamed, etc. (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
setupAppFilesAsync();
}
@ -42,22 +33,8 @@ function setupAppFilesFinished() {
* the test.
*/
function checkUpdateFinished() {
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
if (IS_WIN || IS_MACOSX) {
let running = getPostUpdateFile(".running");
debugDump("checking that the post update process running file doesn't " +
"exist. Path: " + running.path);
do_check_false(running.exists());
}
checkPostUpdateRunningFile(false);
checkAppBundleModTime();
checkFilesAfterUpdateFailure(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_PARTIAL_FAILURE);
standardInit();

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

@ -41,7 +41,7 @@ function checkUpdateFinished() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(1, STATE_PENDING);
runUpdate(1, STATE_PENDING, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -41,7 +41,7 @@ function checkUpdateFinished() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(1, STATE_PENDING);
runUpdate(1, STATE_PENDING, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -42,7 +42,7 @@ function checkUpdateFinished() {
gStageUpdate = false;
gSwitchApp = true;
gDisableReplaceFallback = true;
runUpdate(1, STATE_FAILED_WRITE_ERROR);
runUpdate(1, STATE_FAILED_WRITE_ERROR, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -42,7 +42,7 @@ function checkUpdateFinished() {
gStageUpdate = false;
gSwitchApp = true;
gDisableReplaceFallback = true;
runUpdate(1, STATE_FAILED_WRITE_ERROR);
runUpdate(1, STATE_FAILED_WRITE_ERROR, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -50,7 +50,7 @@ function checkUpdateFinished() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(1, STATE_PENDING);
runUpdate(1, STATE_PENDING, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -50,7 +50,7 @@ function checkUpdateFinished() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(1, STATE_PENDING);
runUpdate(1, STATE_PENDING, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -51,7 +51,7 @@ function checkUpdateFinished() {
gStageUpdate = false;
gSwitchApp = true;
gDisableReplaceFallback = true;
runUpdate(1, STATE_FAILED_WRITE_ERROR);
runUpdate(1, STATE_FAILED_WRITE_ERROR, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -51,7 +51,7 @@ function checkUpdateFinished() {
gStageUpdate = false;
gSwitchApp = true;
gDisableReplaceFallback = true;
runUpdate(1, STATE_FAILED_WRITE_ERROR);
runUpdate(1, STATE_FAILED_WRITE_ERROR, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -52,7 +52,7 @@ function checkUpdateFinished() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(1, STATE_PENDING);
runUpdate(1, STATE_PENDING, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -50,7 +50,7 @@ function checkUpdateFinished() {
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
runUpdate(1, STATE_PENDING);
runUpdate(1, STATE_PENDING, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -53,7 +53,7 @@ function checkUpdateFinished() {
gStageUpdate = false;
gSwitchApp = true;
gDisableReplaceFallback = true;
runUpdate(1, STATE_FAILED_WRITE_ERROR);
runUpdate(1, STATE_FAILED_WRITE_ERROR, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -51,7 +51,7 @@ function checkUpdateFinished() {
gStageUpdate = false;
gSwitchApp = true;
gDisableReplaceFallback = true;
runUpdate(1, STATE_FAILED_WRITE_ERROR);
runUpdate(1, STATE_FAILED_WRITE_ERROR, checkUpdateApplied);
}
function checkUpdateApplied() {

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

@ -20,16 +20,6 @@ function run_test() {
createUpdaterINI(true);
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on all updates since
// the precomplete file in the root of the bundle is renamed, etc. (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setupAppFilesAsync();
}
@ -43,13 +33,7 @@ function setupAppFilesFinished() {
* the test.
*/
function checkUpdateFinished() {
if (IS_WIN || IS_MACOSX) {
let running = getPostUpdateFile(".running");
debugDump("checking that the post update process running file doesn't " +
"exist. Path: " + running.path);
do_check_false(running.exists());
}
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile, true, false);
checkUpdateLogContents(LOG_PARTIAL_FAILURE);
standardInit();

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

@ -18,18 +18,18 @@ function run_test() {
gTestFiles[gTestFiles.length - 1].comparePerms = 0o644;
gTestDirs = gTestDirsCompleteSuccess;
setupUpdaterTest(FILE_COMPLETE_MAR);
if (IS_MACOSX) {
// Create files in the old distribution directory location to verify that
// the directory and its contents are removed when there is a distribution
// directory in the new location.
let testFile = getApplyDirFile(DIR_MACOS + "distribution/testFile", true);
writeFile(testFile, "test\n");
testFile = getApplyDirFile(DIR_MACOS + "distribution/test1/testFile", true);
writeFile(testFile, "test\n");
}
createUpdaterINI(false);
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on a successful
// update (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
// Don't test symlinks on Mac OS X in this test since it tends to timeout.
// It is tested on Mac OS X in marAppInUseStageSuccessComplete_unix.js
@ -61,19 +61,13 @@ function setupAppFilesFinished() {
function checkUpdateFinished() {
checkFilesAfterUpdateSuccess(getStageDirFile, true, false);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
if (IS_WIN || IS_MACOSX) {
let running = getPostUpdateFile(".running");
debugDump("checking that the post update process running file doesn't " +
"exist. Path: " + running.path);
do_check_false(running.exists());
}
checkPostUpdateRunningFile(false);
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
do_timeout(TEST_CHECK_TIMEOUT, function() {
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateApplied);
});
}
@ -95,25 +89,18 @@ function checkUpdateApplied() {
* the test.
*/
function finishCheckUpdateApplied() {
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
checkPostUpdateRunningFile(true);
if (IS_WIN || IS_MACOSX) {
let running = getPostUpdateFile(".running");
debugDump("checking that the post update process running file exists. " +
"Path: " + running.path);
do_check_true(running.exists());
if (IS_MACOSX) {
let distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
Assert.ok(!distributionDir.exists(), MSG_SHOULD_NOT_EXIST);
checkUpdateLogContains("removing old distribution directory");
}
if (IS_UNIX && !IS_MACOSX) {
checkSymlink();
}
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
standardInit();
@ -127,7 +114,8 @@ function runHelperProcess(args) {
process.init(helperBin);
debugDump("Running " + helperBin.path + " " + args.join(" "));
process.run(true, args, args.length);
do_check_eq(process.exitValue, 0);
Assert.equal(process.exitValue, 0,
"the helper process exit value should be 0");
}
function createSymlink() {

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

@ -17,19 +17,19 @@ function run_test() {
gTestFiles[gTestFiles.length - 2].compareContents = "FromPartial\n";
gTestFiles[gTestFiles.length - 2].comparePerms = 0o644;
gTestDirs = gTestDirsPartialSuccess;
preventDistributionFiles();
setupUpdaterTest(FILE_PARTIAL_MAR);
if (IS_MACOSX) {
// Create files in the old distribution directory location to verify that
// the directory and its contents are moved to the new location on update.
let testFile = getApplyDirFile(DIR_MACOS + "distribution/testFile", true);
writeFile(testFile, "test\n");
testFile = getApplyDirFile(DIR_MACOS + "distribution/test/testFile", true);
writeFile(testFile, "test\n");
}
createUpdaterINI(false);
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on all updates since
// the precomplete file in the root of the bundle is renamed, etc. (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
setupAppFilesAsync();
}
@ -40,20 +40,14 @@ function setupAppFilesFinished() {
function checkUpdateFinished() {
checkFilesAfterUpdateSuccess(getStageDirFile, true, false);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS);
if (IS_WIN || IS_MACOSX) {
let running = getPostUpdateFile(".running");
debugDump("checking that the post update process running file doesn't " +
"exist. Path: " + running.path);
do_check_false(running.exists());
}
checkUpdateLogContents(LOG_PARTIAL_SUCCESS, true);
checkPostUpdateRunningFile(false);
// Switch the application to the staged application that was updated.
gStageUpdate = false;
gSwitchApp = true;
do_timeout(TEST_CHECK_TIMEOUT, function() {
runUpdate(0, STATE_SUCCEEDED);
runUpdate(0, STATE_SUCCEEDED, checkUpdateApplied);
});
}
@ -75,24 +69,31 @@ function checkUpdateApplied() {
* the test.
*/
function finishCheckUpdateApplied() {
checkPostUpdateRunningFile(true);
let distributionDir = getApplyDirFile(DIR_RESOURCES + "distribution", true);
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
}
if (IS_WIN || IS_MACOSX) {
let running = getPostUpdateFile(".running");
debugDump("checking that the post update process running file exists. " +
"Path: " + running.path);
do_check_true(running.exists());
Assert.ok(distributionDir.exists(), MSG_SHOULD_EXIST);
let testFile = getApplyDirFile(DIR_RESOURCES + "distribution/testFile", true);
Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
testFile = getApplyDirFile(DIR_RESOURCES + "distribution/test/testFile", true);
Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
Assert.ok(!distributionDir.exists(), MSG_SHOULD_NOT_EXIST);
checkUpdateLogContains("Moving old distribution directory to new location");
} else {
debugDump("testing that files aren't added with an add-if instruction " +
"when the file's destination directory doesn't exist");
Assert.ok(!distributionDir.exists(), MSG_SHOULD_NOT_EXIST);
}
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS, true);
standardInit();
checkCallbackAppLog();
}

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

@ -13,19 +13,19 @@ function run_test() {
setupTestCommon();
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
preventDistributionFiles();
setupUpdaterTest(FILE_COMPLETE_MAR);
if (IS_MACOSX) {
// Create files in the old distribution directory location to verify that
// the directory and its contents are moved to the new location on update.
let testFile = getApplyDirFile(DIR_MACOS + "distribution/testFile", true);
writeFile(testFile, "test\n");
testFile = getApplyDirFile(DIR_MACOS + "distribution/test/testFile", true);
writeFile(testFile, "test\n");
}
createUpdaterINI();
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on a successful
// update (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
setupAppFilesAsync();
}
@ -52,17 +52,29 @@ function checkUpdateFinished() {
* the test.
*/
function finishCheckUpdateFinished() {
let distributionDir = getApplyDirFile(DIR_RESOURCES + "distribution", true);
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
Assert.ok(distributionDir.exists(), MSG_SHOULD_EXIST);
let testFile = getApplyDirFile(DIR_RESOURCES + "distribution/testFile", true);
Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
testFile = getApplyDirFile(DIR_RESOURCES + "distribution/test/testFile", true);
Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
Assert.ok(!distributionDir.exists(), MSG_SHOULD_NOT_EXIST);
checkUpdateLogContains("Moving old distribution directory to new location");
} else {
debugDump("testing that files aren't added with an add-if instruction " +
"when the file's destination directory doesn't exist");
Assert.ok(!distributionDir.exists(), MSG_SHOULD_NOT_EXIST);
}
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS, true);
standardInit();
checkCallbackServiceLog();
}

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

@ -20,18 +20,18 @@ function run_test() {
gTestFiles[gTestFiles.length - 2].comparePerms = 0o644;
gTestDirs = gTestDirsPartialSuccess;
setupUpdaterTest(FILE_PARTIAL_MAR);
if (IS_MACOSX) {
// Create files in the old distribution directory location to verify that
// the directory and its contents are removed when there is a distribution
// directory in the new location.
let testFile = getApplyDirFile(DIR_MACOS + "distribution/testFile", true);
writeFile(testFile, "test\n");
testFile = getApplyDirFile(DIR_MACOS + "distribution/test/testFile", true);
writeFile(testFile, "test\n");
}
createUpdaterINI(true);
// For Mac OS X set the last modified time for the root directory to a date in
// the past to test that the last modified time is updated on all updates since
// the precomplete file in the root of the bundle is renamed, etc. (bug 600098).
if (IS_MACOSX) {
let now = Date.now();
let yesterday = now - (1000 * 60 * 60 * 24);
let applyToDir = getApplyDirFile();
applyToDir.lastModifiedTime = yesterday;
}
setAppBundleModTime();
setupAppFilesAsync();
}
@ -59,14 +59,12 @@ function checkUpdateFinished() {
*/
function finishCheckUpdateFinished() {
if (IS_MACOSX) {
debugDump("testing last modified time on the apply to directory has " +
"changed after a successful update (bug 600098)");
let now = Date.now();
let applyToDir = getApplyDirFile();
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
let distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
Assert.ok(!distributionDir.exists(), MSG_SHOULD_NOT_EXIST);
checkUpdateLogContains("removing old distribution directory");
}
checkAppBundleModTime();
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS);
standardInit();