Test code - Bug 1348645 - check that the app update callback path is valid. r=mhowell

This commit is contained in:
Robert Strong 2017-04-28 16:37:26 -07:00
Родитель dc7f0c7c4c
Коммит d83fb7cf3d
19 изменённых файлов: 113 добавлений и 16 удалений

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

@ -52,6 +52,8 @@ const INVALID_APPLYTO_DIR_STAGED_ERROR = 72;
const INVALID_APPLYTO_DIR_ERROR = 74;
const INVALID_INSTALL_DIR_PATH_ERROR = 75;
const INVALID_WORKING_DIR_PATH_ERROR = 76;
const INVALID_CALLBACK_PATH_ERROR = 77;
const INVALID_CALLBACK_DIR_ERROR = 78;
const STATE_FAILED_DELIMETER = ": ";
@ -85,6 +87,10 @@ const STATE_FAILED_INVALID_INSTALL_DIR_PATH_ERROR =
STATE_FAILED + STATE_FAILED_DELIMETER + INVALID_INSTALL_DIR_PATH_ERROR;
const STATE_FAILED_INVALID_WORKING_DIR_PATH_ERROR =
STATE_FAILED + STATE_FAILED_DELIMETER + INVALID_WORKING_DIR_PATH_ERROR;
const STATE_FAILED_INVALID_CALLBACK_PATH_ERROR =
STATE_FAILED + STATE_FAILED_DELIMETER + INVALID_CALLBACK_PATH_ERROR;
const STATE_FAILED_INVALID_CALLBACK_DIR_ERROR =
STATE_FAILED + STATE_FAILED_DELIMETER + INVALID_CALLBACK_DIR_ERROR;
/**
* Constructs a string representing a remote update xml file.

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

@ -1668,10 +1668,15 @@ function readServiceLogFile() {
* @param aApplyToDirPath (optional)
* When specified the apply to / working directory path to use for
* invalid argument tests otherwise the normal path will be used.
* @param aCallbackPath (optional)
* When specified the callback path to use for invalid argument tests
* otherwise the normal path will be used.
*/
function runUpdate(aExpectedStatus, aSwitchApp, aExpectedExitValue, aCheckSvcLog,
aPatchDirPath, aInstallDirPath, aApplyToDirPath) {
let isInvalidArgTest = !!aPatchDirPath || !!aInstallDirPath || !!aApplyToDirPath;
aPatchDirPath, aInstallDirPath, aApplyToDirPath,
aCallbackPath) {
let isInvalidArgTest = !!aPatchDirPath || !!aInstallDirPath ||
!!aApplyToDirPath || aCallbackPath;
let svcOriginalLog;
if (IS_SERVICE_TEST) {
@ -1713,6 +1718,8 @@ function runUpdate(aExpectedStatus, aSwitchApp, aExpectedExitValue, aCheckSvcLog
args = args.concat(gCallbackArgs);
} else if (IS_SERVICE_TEST) {
args = ["launch-service", updateBin.path].concat(args);
} else if (aCallbackPath) {
args = args.concat([callbackApp.parent.path, aCallbackPath]);
}
debugDump("launching the program: " + launchBin.path + " " + args.join(" "));

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

@ -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();
}

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

@ -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();
}

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

@ -33,7 +33,7 @@ function setupUpdaterTestFinished() {
path = path.repeat(1000); // 10000 characters
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null);
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null, null);
}
/**

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

@ -30,7 +30,7 @@ function setupUpdaterTestFinished() {
path = "/" + path + "/../" + path;
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null);
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null, null);
}
/**

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

@ -24,7 +24,7 @@ function run_test() {
*/
function setupUpdaterTestFinished() {
let path = getApplyDirFile("..", false).path;
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path);
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path, null);
}
/**

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

@ -29,7 +29,7 @@ function setupUpdaterTestFinished() {
path = path + "/../";
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, path, null, null);
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, path, null, null, null);
}
/**

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

@ -24,7 +24,7 @@ function run_test() {
*/
function setupUpdaterTestFinished() {
let path = getApplyDirFile("..", false).path;
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true, null, null, path);
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true, null, null, path, null);
}
/**

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

@ -24,7 +24,7 @@ function run_test() {
*/
function setupUpdaterTestFinished() {
let path = "\\\\.\\" + getApplyDirFile(null, false).path;
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path);
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path, null);
}
/**

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

@ -23,7 +23,7 @@ function run_test() {
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, "test");
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, "test", null);
}
/**

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

@ -10,6 +10,8 @@
tags = appupdate
head = head_update.js
[invalidArgCallbackFileNotInInstallDirFailure.js]
[invalidArgCallbackFilePathTooLongFailure.js]
[invalidArgInstallDirPathTooLongFailure.js]
[invalidArgInstallDirPathTraversalFailure.js]
[invalidArgInstallWorkingDirPathNotSameFailure_win.js]

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

@ -33,7 +33,7 @@ function setupUpdaterTestFinished() {
path = path.repeat(1000); // 10000 characters
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null);
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null, null);
}
/**

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

@ -30,7 +30,7 @@ function setupUpdaterTestFinished() {
path = "/" + path + "/../" + path;
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null);
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null, null);
}
/**

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

@ -24,7 +24,7 @@ function run_test() {
*/
function setupUpdaterTestFinished() {
let path = getApplyDirFile("..", false).path;
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path);
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path, null);
}
/**

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

@ -29,7 +29,7 @@ function setupUpdaterTestFinished() {
path = path + "/../";
}
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, path, null, null);
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, path, null, null, null);
}
/**

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

@ -24,7 +24,7 @@ function run_test() {
*/
function setupUpdaterTestFinished() {
let path = getApplyDirFile("..", false).path;
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true, null, null, path);
runUpdate(STATE_AFTER_RUNUPDATE, true, 1, true, null, null, path, null);
}
/**

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

@ -24,7 +24,7 @@ function run_test() {
*/
function setupUpdaterTestFinished() {
let path = "\\\\.\\" + getApplyDirFile(null, false).path;
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path);
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, path, null);
}
/**

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

@ -23,7 +23,7 @@ function run_test() {
* Called after the call to setupUpdaterTest finishes.
*/
function setupUpdaterTestFinished() {
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, "test");
runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, null, "test", null);
}
/**