1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/update/tests/unit_base_updater/marFailurePartial.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,47 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + */ 1.8 + 1.9 +/* General Partial MAR File Patch Apply Failure Test */ 1.10 + 1.11 +function run_test() { 1.12 + setupTestCommon(); 1.13 + gTestFiles = gTestFilesPartialSuccess; 1.14 + gTestFiles[11].originalFile = "partial.png"; 1.15 + gTestDirs = gTestDirsPartialSuccess; 1.16 + setTestFilesAndDirsForFailure(); 1.17 + setupUpdaterTest(FILE_PARTIAL_MAR, false, false); 1.18 + 1.19 + // For Mac OS X set the last modified time for the root directory to a date in 1.20 + // the past to test that the last modified time is updated on all updates since 1.21 + // the precomplete file in the root of the bundle is renamed, etc. (bug 600098). 1.22 + if (IS_MACOSX) { 1.23 + let now = Date.now(); 1.24 + let yesterday = now - (1000 * 60 * 60 * 24); 1.25 + let applyToDir = getApplyDirFile(); 1.26 + applyToDir.lastModifiedTime = yesterday; 1.27 + } 1.28 + 1.29 + // Note that on platforms where we use execv, we cannot trust the return code. 1.30 + runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_UNEXPECTED_FILE_OPERATION_ERROR); 1.31 +} 1.32 + 1.33 +function checkUpdateApplied() { 1.34 + if (IS_MACOSX) { 1.35 + logTestInfo("testing last modified time on the apply to directory has " + 1.36 + "changed after a successful update (bug 600098)"); 1.37 + let now = Date.now(); 1.38 + let applyToDir = getApplyDirFile(); 1.39 + let timeDiff = Math.abs(applyToDir.lastModifiedTime - now); 1.40 + do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE); 1.41 + } 1.42 + 1.43 + checkFilesAfterUpdateFailure(); 1.44 + // Sorting on Linux is different so skip this check for now. 1.45 + if (!IS_UNIX) { 1.46 + checkUpdateLogContents(LOG_PARTIAL_FAILURE); 1.47 + } 1.48 + 1.49 + checkCallbackAppLog(); 1.50 +}