|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
3 */ |
|
4 |
|
5 /* Application in use complete MAR file patch apply success test */ |
|
6 |
|
7 function run_test() { |
|
8 setupTestCommon(); |
|
9 gTestFiles = gTestFilesCompleteSuccess; |
|
10 gTestDirs = gTestDirsCompleteSuccess; |
|
11 setupUpdaterTest(FILE_COMPLETE_MAR, false, false); |
|
12 |
|
13 // Launch the callback helper application so it is in use during the update. |
|
14 let callbackApp = getApplyDirFile("a/b/" + gCallbackBinFile); |
|
15 callbackApp.permissions = PERMS_DIRECTORY; |
|
16 let args = [getApplyDirPath() + "a/b/", "input", "output", "-s", |
|
17 HELPER_SLEEP_TIMEOUT]; |
|
18 let callbackAppProcess = AUS_Cc["@mozilla.org/process/util;1"]. |
|
19 createInstance(AUS_Ci.nsIProcess); |
|
20 callbackAppProcess.init(callbackApp); |
|
21 callbackAppProcess.run(false, args, args.length); |
|
22 |
|
23 do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep); |
|
24 } |
|
25 |
|
26 function doUpdate() { |
|
27 // For Mac OS X set the last modified time for the root directory to a date in |
|
28 // the past to test that the last modified time is updated on a successful |
|
29 // update (bug 600098). |
|
30 if (IS_MACOSX) { |
|
31 let applyToDir = getApplyDirFile(); |
|
32 let now = Date.now(); |
|
33 let yesterday = now - (1000 * 60 * 60 * 24); |
|
34 applyToDir.lastModifiedTime = yesterday; |
|
35 } |
|
36 |
|
37 runUpdate(0, STATE_SUCCEEDED); |
|
38 } |
|
39 |
|
40 function checkUpdateApplied() { |
|
41 setupHelperFinish(); |
|
42 } |
|
43 |
|
44 function checkUpdate() { |
|
45 if (IS_MACOSX) { |
|
46 logTestInfo("testing last modified time on the apply to directory has " + |
|
47 "changed after a successful update (bug 600098)"); |
|
48 let now = Date.now(); |
|
49 let applyToDir = getApplyDirFile(); |
|
50 let timeDiff = Math.abs(applyToDir.lastModifiedTime - now); |
|
51 do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE); |
|
52 } |
|
53 |
|
54 checkFilesAfterUpdateSuccess(); |
|
55 // Sorting on Linux is different so skip this check for now. |
|
56 if (!IS_UNIX) { |
|
57 checkUpdateLogContents(LOG_COMPLETE_SUCCESS); |
|
58 } |
|
59 |
|
60 checkCallbackAppLog(); |
|
61 } |