|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
3 */ |
|
4 |
|
5 /* File in use inside removed dir partial MAR file patch apply success test */ |
|
6 |
|
7 function run_test() { |
|
8 if (!shouldRunServiceTest()) { |
|
9 return; |
|
10 } |
|
11 |
|
12 setupTestCommon(); |
|
13 gTestFiles = gTestFilesPartialSuccess; |
|
14 gTestDirs = gTestDirsPartialSuccess; |
|
15 setupUpdaterTest(FILE_PARTIAL_MAR, false, true); |
|
16 |
|
17 let fileInUseBin = getApplyDirFile(gTestDirs[2].relPathDir + |
|
18 gTestDirs[2].files[0]); |
|
19 // Remove the empty file created for the test so the helper application can |
|
20 // replace it. |
|
21 fileInUseBin.remove(false); |
|
22 |
|
23 let helperBin = getTestDirFile(FILE_HELPER_BIN); |
|
24 let fileInUseDir = getApplyDirFile(gTestDirs[2].relPathDir); |
|
25 helperBin.copyTo(fileInUseDir, gTestDirs[2].files[0]); |
|
26 |
|
27 // Launch an existing file so it is in use during the update. |
|
28 let args = [getApplyDirPath() + "a/b/", "input", "output", "-s", |
|
29 HELPER_SLEEP_TIMEOUT]; |
|
30 let fileInUseProcess = AUS_Cc["@mozilla.org/process/util;1"]. |
|
31 createInstance(AUS_Ci.nsIProcess); |
|
32 fileInUseProcess.init(fileInUseBin); |
|
33 fileInUseProcess.run(false, args, args.length); |
|
34 |
|
35 setupAppFilesAsync(); |
|
36 } |
|
37 |
|
38 function setupAppFilesFinished() { |
|
39 do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep); |
|
40 } |
|
41 |
|
42 function doUpdate() { |
|
43 runUpdateUsingService(STATE_PENDING_SVC, STATE_SUCCEEDED); |
|
44 } |
|
45 |
|
46 function checkUpdateFinished() { |
|
47 setupHelperFinish(); |
|
48 } |
|
49 |
|
50 function checkUpdate() { |
|
51 checkFilesAfterUpdateSuccess(); |
|
52 checkUpdateLogContains(ERR_BACKUP_DISCARD); |
|
53 checkCallbackServiceLog(); |
|
54 } |