michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: */ michael@0: michael@0: /* General Partial MAR File Patch Apply Failure Test */ michael@0: michael@0: function run_test() { michael@0: setupTestCommon(); michael@0: gTestFiles = gTestFilesPartialSuccess; michael@0: gTestFiles[11].originalFile = "partial.png"; michael@0: gTestDirs = gTestDirsPartialSuccess; michael@0: setTestFilesAndDirsForFailure(); michael@0: setupUpdaterTest(FILE_PARTIAL_MAR, false, false); michael@0: michael@0: // For Mac OS X set the last modified time for the root directory to a date in michael@0: // the past to test that the last modified time is updated on all updates since michael@0: // the precomplete file in the root of the bundle is renamed, etc. (bug 600098). michael@0: if (IS_MACOSX) { michael@0: let now = Date.now(); michael@0: let yesterday = now - (1000 * 60 * 60 * 24); michael@0: let applyToDir = getApplyDirFile(); michael@0: applyToDir.lastModifiedTime = yesterday; michael@0: } michael@0: michael@0: // Note that on platforms where we use execv, we cannot trust the return code. michael@0: runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_UNEXPECTED_FILE_OPERATION_ERROR); michael@0: } michael@0: michael@0: function checkUpdateApplied() { michael@0: if (IS_MACOSX) { michael@0: logTestInfo("testing last modified time on the apply to directory has " + michael@0: "changed after a successful update (bug 600098)"); michael@0: let now = Date.now(); michael@0: let applyToDir = getApplyDirFile(); michael@0: let timeDiff = Math.abs(applyToDir.lastModifiedTime - now); michael@0: do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE); michael@0: } michael@0: michael@0: checkFilesAfterUpdateFailure(); michael@0: // Sorting on Linux is different so skip this check for now. michael@0: if (!IS_UNIX) { michael@0: checkUpdateLogContents(LOG_PARTIAL_FAILURE); michael@0: } michael@0: michael@0: checkCallbackAppLog(); michael@0: }