diff -r 000000000000 -r 6474c204b198 toolkit/mozapps/update/tests/unit_base_updater/marFailurePartial.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFailurePartial.js Wed Dec 31 06:09:35 2014 +0100 @@ -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() { + setupTestCommon(); + gTestFiles = gTestFilesPartialSuccess; + gTestFiles[11].originalFile = "partial.png"; + gTestDirs = gTestDirsPartialSuccess; + setTestFilesAndDirsForFailure(); + setupUpdaterTest(FILE_PARTIAL_MAR, false, false); + + // For Mac OS X set the last modified time for the root directory to a date in + // the past to test that the last modified time is updated on all updates since + // the precomplete file in the root of the bundle is renamed, etc. (bug 600098). + if (IS_MACOSX) { + let now = Date.now(); + let yesterday = now - (1000 * 60 * 60 * 24); + let applyToDir = getApplyDirFile(); + applyToDir.lastModifiedTime = yesterday; + } + + // Note that on platforms where we use execv, we cannot trust the return code. + runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_UNEXPECTED_FILE_OPERATION_ERROR); +} + +function checkUpdateApplied() { + if (IS_MACOSX) { + logTestInfo("testing last modified time on the apply to directory has " + + "changed after a successful update (bug 600098)"); + let now = Date.now(); + let applyToDir = getApplyDirFile(); + let timeDiff = Math.abs(applyToDir.lastModifiedTime - now); + do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE); + } + + checkFilesAfterUpdateFailure(); + // Sorting on Linux is different so skip this check for now. + if (!IS_UNIX) { + checkUpdateLogContents(LOG_PARTIAL_FAILURE); + } + + checkCallbackAppLog(); +}