|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
4 */ |
|
5 |
|
6 /* General Partial MAR File Patch Apply Failure Test */ |
|
7 |
|
8 function run_test() { |
|
9 setupTestCommon(); |
|
10 gTestFiles = gTestFilesPartialSuccess; |
|
11 gTestFiles[11].originalFile = "partial.png"; |
|
12 gTestDirs = gTestDirsPartialSuccess; |
|
13 setTestFilesAndDirsForFailure(); |
|
14 setupUpdaterTest(FILE_PARTIAL_MAR, false, false); |
|
15 |
|
16 // For Mac OS X set the last modified time for the root directory to a date in |
|
17 // the past to test that the last modified time is updated on all updates since |
|
18 // the precomplete file in the root of the bundle is renamed, etc. (bug 600098). |
|
19 if (IS_MACOSX) { |
|
20 let now = Date.now(); |
|
21 let yesterday = now - (1000 * 60 * 60 * 24); |
|
22 let applyToDir = getApplyDirFile(); |
|
23 applyToDir.lastModifiedTime = yesterday; |
|
24 } |
|
25 |
|
26 // Note that on platforms where we use execv, we cannot trust the return code. |
|
27 runUpdate((USE_EXECV ? 0 : 1), STATE_FAILED_UNEXPECTED_FILE_OPERATION_ERROR); |
|
28 } |
|
29 |
|
30 function checkUpdateApplied() { |
|
31 if (IS_MACOSX) { |
|
32 logTestInfo("testing last modified time on the apply to directory has " + |
|
33 "changed after a successful update (bug 600098)"); |
|
34 let now = Date.now(); |
|
35 let applyToDir = getApplyDirFile(); |
|
36 let timeDiff = Math.abs(applyToDir.lastModifiedTime - now); |
|
37 do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE); |
|
38 } |
|
39 |
|
40 checkFilesAfterUpdateFailure(); |
|
41 // Sorting on Linux is different so skip this check for now. |
|
42 if (!IS_UNIX) { |
|
43 checkUpdateLogContents(LOG_PARTIAL_FAILURE); |
|
44 } |
|
45 |
|
46 checkCallbackAppLog(); |
|
47 } |