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,8 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const IS_SERVICE_TEST = false;
/* import-globals-from ../data/xpcshellUtilsAUS.js */
load("../data/xpcshellUtilsAUS.js");

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/.
*/
/* Callback file not in install directory or a sub-directory of the install
directory failure */
const STATE_AFTER_RUNUPDATE = STATE_FAILED_INVALID_CALLBACK_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 = getTestDirFile(FILE_HELPER_BIN).path;
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, null, path);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

View file

@ -0,0 +1,45 @@
/* 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 callback file path failure test */
const STATE_AFTER_RUNUPDATE = STATE_FAILED_INVALID_CALLBACK_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, null, null, path);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
standardInit();
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
waitForFilesInUse();
}

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,88 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* Test a replace request for a staged update with a version file that specifies
* an older version failure. The same check is used in nsUpdateDriver.cpp for
* all update types which is why there aren't tests for the maintenance service
* as well as for other update types.
*/
const STATE_AFTER_STAGE = STATE_APPLIED;
function run_test() {
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setupUpdaterTest(FILE_COMPLETE_MAR);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
stageUpdate(false);
}
/**
* Called after the call to stageUpdate finishes.
*/
function stageUpdateFinished() {
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateSuccess(getStageDirFile, true);
checkUpdateLogContents(LOG_COMPLETE_SUCCESS, true);
// Change the active update to an older version to simulate installing a new
// version of the application while there is an update that has been staged.
let channel = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_CHANNEL);
let patches = getLocalPatchString(null, null, null, null, null, "true",
STATE_AFTER_STAGE);
let updates = getLocalUpdateString(patches, null, null, null, "1.0", null,
null, null, null, null, "true", channel);
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
// Change the version file to an older version to simulate installing a new
// version of the application while there is an update that has been staged.
writeVersionFile("1.0");
reloadUpdateManagerData();
// Try to switch the application to the staged application that was updated.
runUpdateUsingApp(STATE_AFTER_STAGE);
}
/**
* Called after the call to runUpdateUsingApp finishes.
*/
function runUpdateFinished() {
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_STAGE,
"the update state" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
setTestFilesAndDirsForFailure();
checkFilesAfterUpdateFailure(getApplyDirFile, IS_MACOSX ? false : true, false);
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,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,113 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* Application in use complete MAR file staged patch apply success test */
const START_STATE = STATE_PENDING;
const STATE_AFTER_STAGE = 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;
setupUpdaterTest(FILE_COMPLETE_MAR, true);
}
/**
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
setupSymLinks();
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_SUCCEEDED, true, 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();
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);
checkUpdateLogContents(LOG_REPLACE_SUCCESS, false, true);
checkCallbackLog();
}
/**
* Setup symlinks for the test.
*/
function setupSymLinks() {
if (IS_UNIX) {
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() {
if (IS_UNIX) {
checkSymlink();
}
}

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,51 @@
/* 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/.
*/
/* Test version downgrade MAR security check */
function run_test() {
if (!MOZ_VERIFY_MAR_SIGNATURE) {
return;
}
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_OLD_VERSION_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_VERSION_DOWNGRADE_ERROR, false, (USE_EXECV ? 0 : 1),
false);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
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_FAILED,
"the update state" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).errorCode, VERSION_DOWNGRADE_ERROR,
"the update errorCode" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
checkUpdateLogContains(STATE_FAILED_VERSION_DOWNGRADE_ERROR);
waitForFilesInUse();
}

View file

@ -0,0 +1,51 @@
/* 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/.
*/
/* Test product/channel MAR security check */
function run_test() {
if (!MOZ_VERIFY_MAR_SIGNATURE) {
return;
}
if (!setupTestCommon()) {
return;
}
gTestFiles = gTestFilesCompleteSuccess;
gTestDirs = gTestDirsCompleteSuccess;
setTestFilesAndDirsForFailure();
setupUpdaterTest(FILE_WRONG_CHANNEL_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_MAR_CHANNEL_MISMATCH_ERROR, false, (USE_EXECV ? 0 : 1),
false);
}
/**
* Called after the call to runUpdateUsingUpdater finishes.
*/
function runUpdateFinished() {
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_FAILED,
"the update state" + MSG_SHOULD_EQUAL);
Assert.equal(gUpdateManager.getUpdateAt(0).errorCode, MAR_CHANNEL_MISMATCH_ERROR,
"the update errorCode" + MSG_SHOULD_EQUAL);
checkPostUpdateRunningFile(false);
checkFilesAfterUpdateFailure(getApplyDirFile);
checkUpdateLogContains(STATE_FAILED_MAR_CHANNEL_MISMATCH_ERROR);
waitForFilesInUse();
}

View file

@ -0,0 +1,136 @@
; 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. These tests should never run on Android
; which doesn't use the updater binary as other applications do and are excluded
; from running the tests in the moz.build file.
[DEFAULT]
tags = appupdate
head = head_update.js
tail =
[invalidArgCallbackFileNotInInstallDirFailure.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
[invalidArgCallbackFilePathTooLongFailure.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
[invalidArgInstallDirPathTooLongFailure.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
[invalidArgInstallDirPathTraversalFailure.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
[invalidArgInstallWorkingDirPathNotSameFailure_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[invalidArgPatchDirPathTraversalFailure.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
[invalidArgStageDirNotInInstallDirFailure_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[invalidArgWorkingDirPathLocalUNCFailure_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[invalidArgWorkingDirPathRelativeFailure.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
[marSuccessComplete.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
[marSuccessPartial.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
[marFailurePartial.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
[marStageSuccessComplete.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
[marStageSuccessPartial.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
[marVersionDowngrade.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985 and mar signing
[marWrongChannel.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985 and mar signing
[marStageFailurePartial.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
[marCallbackAppSuccessComplete_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marCallbackAppSuccessPartial_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marCallbackAppStageSuccessComplete_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marCallbackAppStageSuccessPartial_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marAppInUseSuccessComplete.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
[marAppInUseStageSuccessComplete_unix.js]
skip-if = os == 'win'
reason = not a Windows test
[marAppInUseStageFailureComplete_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marFileLockedFailureComplete_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marFileLockedFailurePartial_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marFileLockedStageFailureComplete_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marFileLockedStageFailurePartial_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marFileInUseSuccessComplete_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marFileInUseSuccessPartial_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marRMRFDirFileInUseSuccessComplete_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marRMRFDirFileInUseSuccessPartial_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marFileInUseStageFailureComplete_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marFileInUseStageFailurePartial_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marRMRFDirFileInUseStageFailureComplete_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marRMRFDirFileInUseStageFailurePartial_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marAppApplyDirLockedStageFailure_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marAppApplyUpdateAppBinInUseStageSuccess_win.js]
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
reason = Windows only test and bug 1291985
[marAppApplyUpdateSuccess.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
[marAppApplyUpdateStageSuccess.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985
[marAppApplyUpdateStageOldVersionFailure.js]
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2')
reason = bug 1291985