import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo

This commit is contained in:
Roy Tam 2018-01-19 03:59:58 +08:00
commit dcd9973243
150858 changed files with 23884658 additions and 0 deletions

View file

@ -0,0 +1,7 @@
"use strict";
module.exports = {
"extends": [
"../../../../../testing/xpcshell/xpcshell.eslintrc.js"
]
};

View file

@ -0,0 +1,35 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* Bootstrap the tests using the service by installing our own version of the service */
function run_test() {
if (!setupTestCommon()) {
return;
}
// We don't actually care if the MAR has any data, we only care about the
// application return code and update.status result.
gTestFiles = gTestFilesCommon;
gTestDirs = [];
setupUpdaterTest(FILE_COMPLETE_MAR, null);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runUpdate(STATE_SUCCEEDED, false, 0, true);
}
/**
* Called after the call to runUpdateUsingService finishes.
*/
function runUpdateFinished() {
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
// We need to check the service log even though this is a bootstrap
// because the app bin could be in use by this test by the time the next
// test runs.
checkCallbackLog();
}

View file

@ -0,0 +1,39 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* We skip authenticode cert checks from the service udpates
* so that we can use updater-xpcshell with the wrong certs for testing.
* This tests that code path. */
function run_test() {
if (!IS_AUTHENTICODE_CHECK_ENABLED) {
return;
}
let binDir = getGREBinDir();
let maintenanceServiceBin = binDir.clone();
maintenanceServiceBin.append(FILE_MAINTENANCE_SERVICE_BIN);
let updaterBin = binDir.clone();
updaterBin.append(FILE_UPDATER_BIN);
debugDump("Launching maintenance service bin: " +
maintenanceServiceBin.path + " to check updater: " +
updaterBin.path + " signature.");
// Bypass the manifest and run as invoker
gEnv.set("__COMPAT_LAYER", "RunAsInvoker");
let dummyInstallPath = "---";
let maintenanceServiceBinArgs = ["check-cert", dummyInstallPath,
updaterBin.path];
let maintenanceServiceBinProcess = Cc["@mozilla.org/process/util;1"].
createInstance(Ci.nsIProcess);
maintenanceServiceBinProcess.init(maintenanceServiceBin);
maintenanceServiceBinProcess.run(true, maintenanceServiceBinArgs,
maintenanceServiceBinArgs.length);
Assert.equal(maintenanceServiceBinProcess.exitValue, 0,
"the maintenance service exit value should be 0");
}

View file

@ -0,0 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const IS_SERVICE_TEST = true;
/* import-globals-from ../data/xpcshellUtilsAUS.js */
load("../data/xpcshellUtilsAUS.js");

View file

@ -0,0 +1,47 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Too long install directory path failure test */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_INSTALL_DIR_PATH_ERROR
: STATE_FAILED_INVALID_INSTALL_DIR_PATH_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = "123456789";
if (IS_WIN) {
path = "\\" + path;
path = path.repeat(30); // 300 characters
path = "C:" + path;
} else {
path = "/" + path;
path = path.repeat(1000); // 10000 characters
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null, null);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

View file

@ -0,0 +1,44 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Install directory path traversal failure test */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_INSTALL_DIR_PATH_ERROR
: STATE_FAILED_INVALID_INSTALL_DIR_PATH_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = "123456789";
if (IS_WIN) {
path = "C:\\" + path + "\\..\\" + path;
} else {
path = "/" + path + "/../" + path;
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null, null);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

View file

@ -0,0 +1,38 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Different install and working directories for a regular update failure */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_APPLYTO_DIR_ERROR
: STATE_FAILED_INVALID_APPLYTO_DIR_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = getApplyDirFile("..", false).path;
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path, null);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

View file

@ -0,0 +1,43 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Patch directory path traversal failure test */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_PENDING_SVC : STATE_PENDING;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = getUpdatesPatchDir();
if (IS_WIN) {
path = path + "\\..\\";
} else {
path = path + "/../";
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, path, null, null, null);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

View file

@ -0,0 +1,38 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Different install and working directories for a regular update failure */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_APPLYTO_DIR_STAGED_ERROR
: STATE_FAILED_INVALID_APPLYTO_DIR_STAGED_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = getApplyDirFile("..", false).path;
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true, null, null, path, null);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

View file

@ -0,0 +1,38 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Working directory path local UNC failure test */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_WORKING_DIR_PATH_ERROR
: STATE_FAILED_INVALID_WORKING_DIR_PATH_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
let path = "\\\\.\\" + getApplyDirFile(null, false).path;
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path, null);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

View file

@ -0,0 +1,37 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Relative working directory path failure test */
const STATE_AFTER_RUNUPDATE =
IS_SERVICE_TEST ? STATE_FAILED_SERVICE_INVALID_WORKING_DIR_PATH_ERROR
: STATE_FAILED_INVALID_WORKING_DIR_PATH_ERROR;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, "test", null);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

View file

@ -0,0 +1,41 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* Test applying an update by staging an update and launching an application to
* apply it.
*/
const STATE_AFTER_STAGE = STATE_PENDING;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
createUpdateInProgressLockFile(getAppBaseDir());
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
stageUpdate(false);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
removeUpdateInProgressLockFile(getAppBaseDir());
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
checkUpdateLogContains(PERFORMING_STAGED_UPDATE);
checkUpdateLogContains(ERR_UPDATE_IN_PROGRESS);
waitForFilesInUse();
}

View file

@ -0,0 +1,83 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* Test applying an update by staging an update and launching an application to
* apply it.
*/
const STATE_AFTER_STAGE = IS_SERVICE_TEST ? STATE_APPLIED_SVC : STATE_APPLIED;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setupUpdaterTest(FILE_COMPLETE_MAR, undefined);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
stageUpdate(true);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true, false);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS, true);
lockDirectory(getAppBaseDir().path);
// Switch the application to the staged application that was updated.
runUpdateUsingApp(STATE_SUCCEEDED);
}
/**
* Called after the call to runUpdateUsingApp finishes.
*/
function runUpdateFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
checkAppBundleModTime();
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
let updatesDir = getUpdatesPatchDir();
Assert.ok(updatesDir.exists(),
MSG_SHOULD_EXIST + getMsgPath(updatesDir.path));
let log = getUpdateLog(FILE_UPDATE_LOG);
Assert.ok(!log.exists(),
MSG_SHOULD_NOT_EXIST + getMsgPath(log.path));
log = getUpdateLog(FILE_LAST_UPDATE_LOG);
Assert.ok(log.exists(),
MSG_SHOULD_EXIST + getMsgPath(log.path));
log = getUpdateLog(FILE_BACKUP_UPDATE_LOG);
Assert.ok(log.exists(),
MSG_SHOULD_EXIST + getMsgPath(log.path));
waitForFilesInUse();
}

View file

@ -0,0 +1,82 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* Test applying an update by staging an update and launching an application to
* apply it.
*/
const STATE_AFTER_STAGE = IS_SERVICE_TEST ? STATE_APPLIED_SVC : STATE_APPLIED;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setupUpdaterTest(FILE_COMPLETE_MAR, true);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
stageUpdate(true);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS, true);
// Switch the application to the staged application that was updated.
runUpdateUsingApp(STATE_SUCCEEDED);
}
/**
* Called after the call to runUpdateUsingApp finishes.
*/
function runUpdateFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
checkAppBundleModTime();
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile, false, true);
checkUpdateLogContents(LOG_REPLACE_SUCCESS, false, true);
let updatesDir = getUpdatesPatchDir();
Assert.ok(updatesDir.exists(),
MSG_SHOULD_EXIST + getMsgPath(updatesDir.path));
let log = getUpdateLog(FILE_UPDATE_LOG);
Assert.ok(!log.exists(),
MSG_SHOULD_NOT_EXIST + getMsgPath(log.path));
log = getUpdateLog(FILE_LAST_UPDATE_LOG);
Assert.ok(log.exists(),
MSG_SHOULD_EXIST + getMsgPath(log.path));
log = getUpdateLog(FILE_BACKUP_UPDATE_LOG);
Assert.ok(log.exists(),
MSG_SHOULD_EXIST + getMsgPath(log.path));
waitForFilesInUse();
}

View file

@ -0,0 +1,65 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* Test applying an update by staging an update and launching an application to
* apply it.
*/
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
// The third parameter will test that a full path to the post update binary
// doesn't execute.
setupUpdaterTest(FILE_COMPLETE_MAR, undefined,
getApplyDirFile(null, true).path + "/");
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runUpdateUsingApp(STATE_SUCCEEDED);
}
/**
* Called after the call to runUpdateUsingApp finishes.
*/
function runUpdateFinished() {
checkAppBundleModTime();
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
let updatesDir = getUpdatesPatchDir();
Assert.ok(updatesDir.exists(),
MSG_SHOULD_EXIST + getMsgPath(updatesDir.path));
let log = getUpdateLog(FILE_UPDATE_LOG);
Assert.ok(!log.exists(),
MSG_SHOULD_NOT_EXIST + getMsgPath(log.path));
log = getUpdateLog(FILE_LAST_UPDATE_LOG);
Assert.ok(log.exists(),
MSG_SHOULD_EXIST + getMsgPath(log.path));
log = getUpdateLog(FILE_BACKUP_UPDATE_LOG);
Assert.ok(!log.exists(),
MSG_SHOULD_NOT_EXIST + getMsgPath(log.path));
waitForFilesInUse();
}

View file

@ -0,0 +1,70 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* Application in use complete MAR file staged patch apply failure test */
const STATE_AFTER_STAGE = IS_SERVICE_TEST ? STATE_APPLIED_SVC : STATE_APPLIED;
const STATE_AFTER_RUNUPDATE = IS_SERVICE_TEST ? STATE_PENDING_SVC : STATE_PENDING;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runHelperFileInUse(DIR_RESOURCES + gCallbackBinFile, false);
}
/**
* Called after the call to waitForHelperSleep finishes.
*/
function waitForHelperSleepFinished() {
stageUpdate(true);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS, true);
// Switch the application to the staged application that was updated.
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
waitForHelperExit();
}
/**
* Called after the call to waitForHelperExit finishes.
*/
function waitForHelperExitFinished() {
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_AFTER_RUNUPDATE,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
setTestFilesAndDirsForFailure();
checkFilesAfterUpdateFailure(getApplyDirFile);
checkUpdateLogContains(ERR_RENAME_FILE);
checkUpdateLogContains(ERR_MOVE_DESTDIR_7 + "\n" + CALL_QUIT);
checkCallbackLog();
}

View file

@ -0,0 +1,62 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* Application in use complete MAR file patch apply success test */
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runHelperFileInUse(DIR_RESOURCES + gCallbackBinFile, false);
}
/**
* Called after the call to waitForHelperSleep finishes.
*/
function waitForHelperSleepFinished() {
runUpdate(STATE_SUCCEEDED, false, 0, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
waitForHelperExit();
}
/**
* Called after the call to waitForHelperExit finishes.
*/
function waitForHelperExitFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
checkAppBundleModTime();
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
checkCallbackLog();
}

View file

@ -0,0 +1,61 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* Replace app binary complete MAR file staged patch apply success test */
const STATE_AFTER_STAGE = IS_SERVICE_TEST ? STATE_APPLIED_SVC : STATE_APPLIED;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
gCallbackBinFile = "exe0.exe";
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
stageUpdate(true);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS, true);
// Switch the application to the staged application that was updated.
runUpdate(STATE_SUCCEEDED, true, 0, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile, false, true);
checkUpdateLogContents(LOG_REPLACE_SUCCESS, false, true);
checkCallbackLog();
}

View file

@ -0,0 +1,61 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* Patch app binary partial MAR file staged patch apply success test */
const STATE_AFTER_STAGE = IS_SERVICE_TEST ? STATE_APPLIED_SVC : STATE_APPLIED;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesPartialSuccess;
gTestDirs = gTestDirsPartialSuccess;
gCallbackBinFile = "exe0.exe";
setupUpdaterTest(FILE_PARTIAL_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
stageUpdate(true);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS, true);
// Switch the application to the staged application that was updated.
runUpdate(STATE_SUCCEEDED, true, 0, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile, false, true);
checkUpdateLogContents(LOG_REPLACE_SUCCESS, false, true);
checkCallbackLog();
}

View file

@ -0,0 +1,48 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* Replace app binary complete MAR file patch apply success test */
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
gCallbackBinFile = "exe0.exe";
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runUpdate(STATE_SUCCEEDED, false, 0, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
checkCallbackLog();
}

View file

@ -0,0 +1,48 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* Patch app binary partial MAR file patch apply success test */
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesPartialSuccess;
gTestDirs = gTestDirsPartialSuccess;
gCallbackBinFile = "exe0.exe";
setupUpdaterTest(FILE_PARTIAL_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runUpdate(STATE_SUCCEEDED, false, 0, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS);
checkCallbackLog();
}

View file

@ -0,0 +1,47 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* General Partial MAR File Patch Apply Failure Test */
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesPartialSuccess;
gTestFiles[11].originalFile = "partial.png";
gTestDirs = gTestDirsPartialSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_PARTIAL_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
// If execv is used the updater process will turn into the callback process
// and the updater's return code will be that of the callback process.
runUpdate(STATE_FAILED_LOADSOURCE_ERROR_WRONG_SIZE, false, (USE_EXECV ? 0 : 1),
true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
checkAppBundleModTime();
standardInit();
Assert.equal(readStatusFile(), STATE_NONE,
"the status file failure code" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_FAILED,
"the update state" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).errorCode, LOADSOURCE_ERROR_WRONG_SIZE,
"the update errorCode" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
checkUpdateLogContents(LOG_PARTIAL_FAILURE);
checkCallbackLog();
}

View file

@ -0,0 +1,67 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* File in use complete MAR file staged patch apply failure test */
const STATE_AFTER_STAGE = IS_SERVICE_TEST ? STATE_APPLIED_SVC : STATE_APPLIED;
const STATE_AFTER_RUNUPDATE = IS_SERVICE_TEST ? STATE_PENDING_SVC : STATE_PENDING;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runHelperFileInUse(gTestFiles[13].relPathDir + gTestFiles[13].fileName,
false);
}
/**
* Called after the call to waitForHelperSleep finishes.
*/
function waitForHelperSleepFinished() {
stageUpdate(true);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS, true);
// Switch the application to the staged application that was updated.
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
waitForHelperExit();
}
/**
* Called after the call to waitForHelperExit finishes.
*/
function waitForHelperExitFinished() {
standardInit();
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_AFTER_RUNUPDATE,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
setTestFilesAndDirsForFailure();
checkFilesAfterUpdateFailure(getApplyDirFile);
checkUpdateLogContains(ERR_RENAME_FILE);
checkUpdateLogContains(ERR_MOVE_DESTDIR_7 + "\n" + CALL_QUIT);
checkCallbackLog();
}

View file

@ -0,0 +1,67 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* File in use partial MAR file staged patch apply failure test */
const STATE_AFTER_STAGE = IS_SERVICE_TEST ? STATE_APPLIED_SVC : STATE_APPLIED;
const STATE_AFTER_RUNUPDATE = IS_SERVICE_TEST ? STATE_PENDING_SVC : STATE_PENDING;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesPartialSuccess;
gTestDirs = gTestDirsPartialSuccess;
setupUpdaterTest(FILE_PARTIAL_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runHelperFileInUse(gTestFiles[11].relPathDir + gTestFiles[11].fileName,
false);
}
/**
* Called after the call to waitForHelperSleep finishes.
*/
function waitForHelperSleepFinished() {
stageUpdate(true);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS, true);
// Switch the application to the staged application that was updated.
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
waitForHelperExit();
}
/**
* Called after the call to waitForHelperExit finishes.
*/
function waitForHelperExitFinished() {
standardInit();
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_AFTER_RUNUPDATE,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
setTestFilesAndDirsForFailure();
checkFilesAfterUpdateFailure(getApplyDirFile);
checkUpdateLogContains(ERR_RENAME_FILE);
checkUpdateLogContains(ERR_MOVE_DESTDIR_7 + "\n" + CALL_QUIT);
checkCallbackLog();
}

View file

@ -0,0 +1,63 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* File in use complete MAR file patch apply success test */
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runHelperFileInUse(gTestFiles[13].relPathDir + gTestFiles[13].fileName,
false);
}
/**
* Called after the call to waitForHelperSleep finishes.
*/
function waitForHelperSleepFinished() {
runUpdate(STATE_SUCCEEDED, false, 0, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
waitForHelperExit();
}
/**
* Called after the call to waitForHelperExit finishes.
*/
function waitForHelperExitFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile, false, true);
checkUpdateLogContains(ERR_BACKUP_DISCARD);
checkUpdateLogContains(STATE_SUCCEEDED + "\n" + CALL_QUIT);
checkCallbackLog();
}

View file

@ -0,0 +1,63 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* File in use partial MAR file patch apply success test */
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesPartialSuccess;
gTestDirs = gTestDirsPartialSuccess;
setupUpdaterTest(FILE_PARTIAL_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runHelperFileInUse(gTestFiles[11].relPathDir + gTestFiles[11].fileName,
false);
}
/**
* Called after the call to waitForHelperSleep finishes.
*/
function waitForHelperSleepFinished() {
runUpdate(STATE_SUCCEEDED, false, 0, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
waitForHelperExit();
}
/**
* Called after the call to waitForHelperExit finishes.
*/
function waitForHelperExitFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile, false, true);
checkUpdateLogContains(ERR_BACKUP_DISCARD);
checkUpdateLogContains(STATE_SUCCEEDED + "\n" + CALL_QUIT);
checkCallbackLog();
}

View file

@ -0,0 +1,57 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* File locked complete MAR file patch apply failure test */
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runHelperLockFile(gTestFiles[3]);
}
/**
* Called after the call to waitForHelperSleep finishes.
*/
function waitForHelperSleepFinished() {
runUpdate(STATE_FAILED_WRITE_ERROR, false, 1, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
waitForHelperExit();
}
/**
* Called after the call to waitForHelperExit finishes.
*/
function waitForHelperExitFinished() {
standardInit();
Assert.equal(readStatusFile(), STATE_PENDING,
"the status file failure code" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_PENDING,
"the update state" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).errorCode, WRITE_ERROR,
"the update errorCode" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
checkUpdateLogContains(ERR_RENAME_FILE);
checkUpdateLogContains(ERR_BACKUP_CREATE_7);
checkUpdateLogContains(STATE_FAILED_WRITE_ERROR + "\n" + CALL_QUIT);
checkCallbackLog();
}

View file

@ -0,0 +1,56 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* File locked partial MAR file patch apply failure test */
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesPartialSuccess;
gTestDirs = gTestDirsPartialSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_PARTIAL_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runHelperLockFile(gTestFiles[2]);
}
/**
* Called after the call to waitForHelperSleep finishes.
*/
function waitForHelperSleepFinished() {
runUpdate(STATE_FAILED_READ_ERROR, false, 1, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
waitForHelperExit();
}
/**
* Called after the call to waitForHelperExit finishes.
*/
function waitForHelperExitFinished() {
standardInit();
Assert.equal(readStatusFile(), STATE_NONE,
"the status file failure code" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_FAILED,
"the update state" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).errorCode, READ_ERROR,
"the update errorCode" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
checkUpdateLogContains(ERR_UNABLE_OPEN_DEST);
checkUpdateLogContains(STATE_FAILED_READ_ERROR + "\n" + CALL_QUIT);
checkCallbackLog();
}

View file

@ -0,0 +1,71 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* File locked complete MAR file staged patch apply failure test */
const STATE_AFTER_STAGE = STATE_PENDING;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runHelperLockFile(gTestFiles[3]);
}
/**
* Called after the call to waitForHelperSleep finishes.
*/
function waitForHelperSleepFinished() {
stageUpdate(true);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
checkPostUpdateRunningFile(false);
// Files aren't checked after staging since this test locks a file which
// prevents reading the file.
checkUpdateLogContains(ERR_ENSURE_COPY);
// Switch the application to the staged application that was updated.
runUpdate(STATE_FAILED_WRITE_ERROR, false, 1, false);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
waitForHelperExit();
}
/**
* Called after the call to waitForHelperExit finishes.
*/
function waitForHelperExitFinished() {
standardInit();
Assert.equal(readStatusFile(), STATE_PENDING,
"the status file failure code" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.updateCount, 2,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_PENDING,
"the update state" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).errorCode, WRITE_ERROR,
"the update errorCode" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
checkUpdateLogContains(ERR_RENAME_FILE);
checkUpdateLogContains(ERR_BACKUP_CREATE_7);
checkUpdateLogContains(STATE_FAILED_WRITE_ERROR + "\n" + CALL_QUIT);
checkCallbackLog();
}

View file

@ -0,0 +1,70 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* File locked partial MAR file staged patch apply failure test */
const STATE_AFTER_STAGE = STATE_PENDING;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesPartialSuccess;
gTestDirs = gTestDirsPartialSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_PARTIAL_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runHelperLockFile(gTestFiles[2]);
}
/**
* Called after the call to waitForHelperSleep finishes.
*/
function waitForHelperSleepFinished() {
stageUpdate(true);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
checkPostUpdateRunningFile(false);
// Files aren't checked after staging since this test locks a file which
// prevents reading the file.
checkUpdateLogContains(ERR_ENSURE_COPY);
// Switch the application to the staged application that was updated.
runUpdate(STATE_FAILED_READ_ERROR, false, 1, false);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
waitForHelperExit();
}
/**
* Called after the call to waitForHelperExit finishes.
*/
function waitForHelperExitFinished() {
standardInit();
Assert.equal(readStatusFile(), STATE_NONE,
"the status file failure code" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.updateCount, 2,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_FAILED,
"the update state" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).errorCode, READ_ERROR,
"the update errorCode" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
checkUpdateLogContains(ERR_UNABLE_OPEN_DEST);
checkUpdateLogContains(STATE_FAILED_READ_ERROR + "\n" + CALL_QUIT);
checkCallbackLog();
}

View file

@ -0,0 +1,72 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* File in use inside removed dir complete MAR file staged patch apply failure
test */
const STATE_AFTER_STAGE = IS_SERVICE_TEST ? STATE_APPLIED_SVC : STATE_APPLIED;
const STATE_AFTER_RUNUPDATE = IS_SERVICE_TEST ? STATE_PENDING_SVC : STATE_PENDING;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runHelperFileInUse(gTestDirs[4].relPathDir + gTestDirs[4].subDirs[0] +
gTestDirs[4].subDirFiles[0], true);
}
/**
* Called after the call to waitForHelperSleep finishes.
*/
function waitForHelperSleepFinished() {
stageUpdate(true);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS, true);
// Switch the application to the staged application that was updated.
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
waitForHelperExit();
}
/**
* Called after the call to waitForHelperExit finishes.
*/
function waitForHelperExitFinished() {
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_AFTER_RUNUPDATE,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
setTestFilesAndDirsForFailure();
checkFilesAfterUpdateFailure(getApplyDirFile);
checkUpdateLogContains(ERR_RENAME_FILE);
checkUpdateLogContains(ERR_MOVE_DESTDIR_7 + "\n" + CALL_QUIT);
checkCallbackLog();
}

View file

@ -0,0 +1,71 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* File in use inside removed dir partial MAR file staged patch apply failure
test */
const STATE_AFTER_STAGE = IS_SERVICE_TEST ? STATE_APPLIED_SVC : STATE_APPLIED;
const STATE_AFTER_RUNUPDATE = IS_SERVICE_TEST ? STATE_PENDING_SVC : STATE_PENDING;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesPartialSuccess;
gTestDirs = gTestDirsPartialSuccess;
setupUpdaterTest(FILE_PARTIAL_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runHelperFileInUse(gTestDirs[2].relPathDir + gTestDirs[2].files[0], true);
}
/**
* Called after the call to waitForHelperSleep finishes.
*/
function waitForHelperSleepFinished() {
stageUpdate(true);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS, true);
// Switch the application to the staged application that was updated.
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
waitForHelperExit();
}
/**
* Called after the call to waitForHelperExit finishes.
*/
function waitForHelperExitFinished() {
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_AFTER_RUNUPDATE,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
setTestFilesAndDirsForFailure();
checkFilesAfterUpdateFailure(getApplyDirFile);
checkUpdateLogContains(ERR_RENAME_FILE);
checkUpdateLogContains(ERR_MOVE_DESTDIR_7 + "\n" + CALL_QUIT);
checkCallbackLog();
}

View file

@ -0,0 +1,63 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* File in use inside removed dir complete MAR file patch apply success test */
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runHelperFileInUse(gTestDirs[4].relPathDir + gTestDirs[4].subDirs[0] +
gTestDirs[4].subDirFiles[0], true);
}
/**
* Called after the call to waitForHelperSleep finishes.
*/
function waitForHelperSleepFinished() {
runUpdate(STATE_SUCCEEDED, false, 0, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
waitForHelperExit();
}
/**
* Called after the call to waitForHelperExit finishes.
*/
function waitForHelperExitFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile, false, true);
checkUpdateLogContains(ERR_BACKUP_DISCARD);
checkUpdateLogContains(STATE_SUCCEEDED + "\n" + CALL_QUIT);
checkCallbackLog();
}

View file

@ -0,0 +1,62 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* File in use inside removed dir partial MAR file patch apply success test */
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesPartialSuccess;
gTestDirs = gTestDirsPartialSuccess;
setupUpdaterTest(FILE_PARTIAL_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runHelperFileInUse(gTestDirs[2].relPathDir + gTestDirs[2].files[0], true);
}
/**
* Called after the call to waitForHelperSleep finishes.
*/
function waitForHelperSleepFinished() {
runUpdate(STATE_SUCCEEDED, false, 0, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
waitForHelperExit();
}
/**
* Called after the call to waitForHelperExit finishes.
*/
function waitForHelperExitFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile, false, true);
checkUpdateLogContains(ERR_BACKUP_DISCARD);
checkUpdateLogContains(STATE_SUCCEEDED + "\n" + CALL_QUIT);
checkCallbackLog();
}

View file

@ -0,0 +1,41 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* General Partial MAR File Staged Patch Apply Failure Test */
const STATE_AFTER_STAGE = STATE_FAILED;
gStagingRemovedUpdate = true;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesPartialSuccess;
gTestFiles[11].originalFile = "partial.png";
gTestDirs = gTestDirsPartialSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_PARTIAL_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
stageUpdate(true);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).errorCode, LOADSOURCE_ERROR_WRONG_SIZE,
"the update errorCode" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
checkUpdateLogContains(ERR_LOADSOURCEFILE_FAILED);
waitForFilesInUse();
}

View file

@ -0,0 +1,132 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* General Complete MAR File Staged Patch Apply Test */
const STATE_AFTER_STAGE = IS_SERVICE_TEST ? STATE_APPLIED_SVC : STATE_APPLIED;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestFiles[gTestFiles.length - 1].originalContents = null;
gTestFiles[gTestFiles.length - 1].compareContents = "FromComplete\n";
gTestFiles[gTestFiles.length - 1].comparePerms = 0o644;
gTestDirs = gTestDirsCompleteSuccess;
setupDistributionDir();
setupSymLinks();
setupUpdaterTest(FILE_COMPLETE_MAR, false);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
stageUpdate(true);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS, true);
// Switch the application to the staged application that was updated.
runUpdate(STATE_SUCCEEDED, true, 0, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
checkAppBundleModTime();
checkSymLinks();
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile, false, true);
checkUpdateLogContents(LOG_REPLACE_SUCCESS, false, true);
checkDistributionDir();
checkCallbackLog();
}
/**
* Setup the state of the distribution directory for the test.
*/
function setupDistributionDir() {
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");
}
}
/**
* Checks the state of the distribution directory for the test.
*/
function checkDistributionDir() {
if (IS_MACOSX) {
let distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
Assert.ok(!distributionDir.exists(),
MSG_SHOULD_NOT_EXIST + getMsgPath(distributionDir.path));
checkUpdateLogContains(REMOVE_OLD_DIST_DIR);
}
}
/**
* Setup symlinks for the test.
*/
function setupSymLinks() {
// 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
if (IS_UNIX && !IS_MACOSX) {
removeSymlink();
createSymlink();
do_register_cleanup(removeSymlink);
gTestFiles.splice(gTestFiles.length - 3, 0,
{
description: "Readable symlink",
fileName: "link",
relPathDir: DIR_RESOURCES,
originalContents: "test",
compareContents: "test",
originalFile: null,
compareFile: null,
originalPerms: 0o666,
comparePerms: 0o666
});
}
}
/**
* Checks the state of the symlinks for the test.
*/
function checkSymLinks() {
// 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
if (IS_UNIX && !IS_MACOSX) {
checkSymlink();
}
}

View file

@ -0,0 +1,112 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* General Partial MAR File Staged Patch Apply Test */
const STATE_AFTER_STAGE = IS_SERVICE_TEST ? STATE_APPLIED_SVC : STATE_APPLIED;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesPartialSuccess;
gTestFiles[gTestFiles.length - 2].originalContents = null;
gTestFiles[gTestFiles.length - 2].compareContents = "FromPartial\n";
gTestFiles[gTestFiles.length - 2].comparePerms = 0o644;
gTestDirs = gTestDirsPartialSuccess;
preventDistributionFiles();
setupDistributionDir();
setupUpdaterTest(FILE_PARTIAL_MAR, true);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
stageUpdate(true);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS, true, false, true);
// Switch the application to the staged application that was updated.
runUpdate(STATE_SUCCEEDED, true, 0, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
checkAppBundleModTime();
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile, false, true);
checkUpdateLogContents(LOG_REPLACE_SUCCESS, false, true, true);
checkDistributionDir();
checkCallbackLog();
}
/**
* Setup the state of the distribution directory for the test.
*/
function setupDistributionDir() {
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");
}
}
/**
* Checks the state of the distribution directory.
*/
function checkDistributionDir() {
let distributionDir = getApplyDirFile(DIR_RESOURCES + "distribution", true);
if (IS_MACOSX) {
Assert.ok(distributionDir.exists(),
MSG_SHOULD_EXIST + getMsgPath(distributionDir.path));
let testFile = getApplyDirFile(DIR_RESOURCES + "distribution/testFile", true);
Assert.ok(testFile.exists(),
MSG_SHOULD_EXIST + getMsgPath(testFile.path));
testFile = getApplyDirFile(DIR_RESOURCES + "distribution/test/testFile", true);
Assert.ok(testFile.exists(),
MSG_SHOULD_EXIST + getMsgPath(testFile.path));
distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
Assert.ok(!distributionDir.exists(),
MSG_SHOULD_NOT_EXIST + getMsgPath(distributionDir.path));
checkUpdateLogContains(MOVE_OLD_DIST_DIR);
} 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 + getMsgPath(distributionDir.path));
}
}

View file

@ -0,0 +1,96 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* General Complete MAR File Patch Apply Test */
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
preventDistributionFiles();
setupDistributionDir();
setupUpdaterTest(FILE_COMPLETE_MAR, true);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runUpdate(STATE_SUCCEEDED, false, 0, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
checkPostUpdateAppLog();
}
/**
* Called after the call to checkPostUpdateAppLog finishes.
*/
function checkPostUpdateAppLogFinished() {
checkAppBundleModTime();
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(true);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS, false, false, true);
checkDistributionDir();
checkCallbackLog();
}
/**
* Setup the state of the distribution directory for the test.
*/
function setupDistributionDir() {
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");
}
}
/**
* Checks the state of the distribution directory.
*/
function checkDistributionDir() {
let distributionDir = getApplyDirFile(DIR_RESOURCES + "distribution", true);
if (IS_MACOSX) {
Assert.ok(distributionDir.exists(),
MSG_SHOULD_EXIST + getMsgPath(distributionDir.path));
let testFile = getApplyDirFile(DIR_RESOURCES + "distribution/testFile", true);
Assert.ok(testFile.exists(),
MSG_SHOULD_EXIST + getMsgPath(testFile.path));
testFile = getApplyDirFile(DIR_RESOURCES + "distribution/test/testFile", true);
Assert.ok(testFile.exists(),
MSG_SHOULD_EXIST + getMsgPath(testFile.path));
distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
Assert.ok(!distributionDir.exists(),
MSG_SHOULD_NOT_EXIST + getMsgPath(distributionDir.path));
checkUpdateLogContains(MOVE_OLD_DIST_DIR);
} 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 + getMsgPath(distributionDir.path));
}
}

View file

@ -0,0 +1,79 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* General Partial MAR File Patch Apply Test */
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesPartialSuccess;
gTestFiles[gTestFiles.length - 1].originalContents = null;
gTestFiles[gTestFiles.length - 1].compareContents = "FromPartial\n";
gTestFiles[gTestFiles.length - 1].comparePerms = 0o644;
gTestFiles[gTestFiles.length - 2].originalContents = null;
gTestFiles[gTestFiles.length - 2].compareContents = "FromPartial\n";
gTestFiles[gTestFiles.length - 2].comparePerms = 0o644;
gTestDirs = gTestDirsPartialSuccess;
setupDistributionDir();
// The third parameter will test that a relative path that contains a
// directory traversal to the post update binary doesn't execute.
setupUpdaterTest(FILE_PARTIAL_MAR, false, "test/../");
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runUpdate(STATE_SUCCEEDED, false, 0, true);
}
/**
* Called after the call to runUpdate finishes.
*/
function runUpdateFinished() {
checkAppBundleModTime();
standardInit();
Assert.equal(readStatusState(), STATE_NONE,
"the status file state" + MSG_SHOULD_EQUAL);
Assert.ok(!gUpdateManager.activeUpdate,
"the active update should not be defined");
Assert.equal(gUpdateManager.updateCount, 1,
"the update manager updateCount attribute" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).state, STATE_SUCCEEDED,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getApplyDirFile);
checkUpdateLogContents(LOG_PARTIAL_SUCCESS);
checkDistributionDir();
checkCallbackLog();
}
/**
* Setup the state of the distribution directory for the test.
*/
function setupDistributionDir() {
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");
}
}
/**
* Checks the state of the distribution directory.
*/
function checkDistributionDir() {
if (IS_MACOSX) {
let distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
Assert.ok(!distributionDir.exists(),
MSG_SHOULD_NOT_EXIST + getMsgPath(distributionDir.path));
checkUpdateLogContains(REMOVE_OLD_DIST_DIR);
}
}

View file

@ -0,0 +1,156 @@
; This Source Code Form is subject to the terms of the Mozilla Public
; License, v. 2.0. If a copy of the MPL was not distributed with this
; file, You can obtain one at http://mozilla.org/MPL/2.0/.
; Tests that require the updater binary and the maintenance service.
[DEFAULT]
tags = appupdate
head = head_update.js
tail =
[bootstrapSvc.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[invalidArgInstallDirPathTooLongFailureSvc.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[invalidArgInstallDirPathTraversalFailureSvc.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[invalidArgInstallWorkingDirPathNotSameFailureSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[invalidArgPatchDirPathTraversalFailureSvc.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[invalidArgStageDirNotInInstallDirFailureSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[invalidArgWorkingDirPathLocalUNCFailureSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[invalidArgWorkingDirPathRelativeFailureSvc.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marSuccessCompleteSvc.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marSuccessPartialSvc.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marFailurePartialSvc.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marStageSuccessCompleteSvc.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marStageSuccessPartialSvc.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marStageFailurePartialSvc.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marCallbackAppSuccessCompleteSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marCallbackAppSuccessPartialSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marCallbackAppStageSuccessCompleteSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marCallbackAppStageSuccessPartialSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marAppInUseSuccessCompleteSvc.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marAppInUseStageFailureCompleteSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marFileLockedFailureCompleteSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marFileLockedFailurePartialSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marFileLockedStageFailureCompleteSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marFileLockedStageFailurePartialSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marFileInUseSuccessCompleteSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marFileInUseSuccessPartialSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marRMRFDirFileInUseSuccessCompleteSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marRMRFDirFileInUseSuccessPartialSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marFileInUseStageFailureCompleteSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marFileInUseStageFailurePartialSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marRMRFDirFileInUseStageFailureCompleteSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marRMRFDirFileInUseStageFailurePartialSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marAppApplyDirLockedStageFailureSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marAppApplyUpdateAppBinInUseStageSuccessSvc_win.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marAppApplyUpdateSuccessSvc.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[marAppApplyUpdateStageSuccessSvc.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
run-sequentially = Uses the Mozilla Maintenance Service.
[checkUpdaterSigSvc.js]