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