toolkit/mozapps/update/tests/unit_service_updater/marFailurePartialSvc.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:4536cc24e616
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 if (!shouldRunServiceTest()) {
10 return;
11 }
12
13 setupTestCommon();
14 gTestFiles = gTestFilesPartialSuccess;
15 gTestFiles[11].originalFile = "partial.png";
16 gTestDirs = gTestDirsPartialSuccess;
17 setTestFilesAndDirsForFailure();
18 setupUpdaterTest(FILE_PARTIAL_MAR, false, false);
19
20 // For Mac OS X set the last modified time for the root directory to a date in
21 // the past to test that the last modified time is updated on all updates since
22 // the precomplete file in the root of the bundle is renamed, etc. (bug 600098).
23 if (IS_MACOSX) {
24 let now = Date.now();
25 let yesterday = now - (1000 * 60 * 60 * 24);
26 let applyToDir = getApplyDirFile();
27 applyToDir.lastModifiedTime = yesterday;
28 }
29
30 setupAppFilesAsync();
31 }
32
33 function setupAppFilesFinished() {
34 runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED);
35 }
36
37 function checkUpdateFinished() {
38 if (IS_MACOSX) {
39 logTestInfo("testing last modified time on the apply to directory has " +
40 "changed after a successful update (bug 600098)");
41 let now = Date.now();
42 let applyToDir = getApplyDirFile();
43 let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
44 do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
45 }
46
47 checkFilesAfterUpdateFailure();
48 // Sorting on Linux is different so skip this check for now.
49 if (!IS_UNIX) {
50 checkUpdateLogContents(LOG_PARTIAL_FAILURE);
51 }
52
53 checkCallbackServiceLog();
54 }

mercurial