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 | /* Application in use 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, false); |
michael@0 | 16 | |
michael@0 | 17 | // Launch the callback helper application so it is in use during the update. |
michael@0 | 18 | let callbackApp = getApplyDirFile("a/b/" + gCallbackBinFile); |
michael@0 | 19 | callbackApp.permissions = PERMS_DIRECTORY; |
michael@0 | 20 | let args = [getApplyDirPath() + "a/b/", "input", "output", "-s", |
michael@0 | 21 | HELPER_SLEEP_TIMEOUT]; |
michael@0 | 22 | let callbackAppProcess = AUS_Cc["@mozilla.org/process/util;1"]. |
michael@0 | 23 | createInstance(AUS_Ci.nsIProcess); |
michael@0 | 24 | callbackAppProcess.init(callbackApp); |
michael@0 | 25 | callbackAppProcess.run(false, args, args.length); |
michael@0 | 26 | |
michael@0 | 27 | setupAppFilesAsync(); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | function setupAppFilesFinished() { |
michael@0 | 31 | do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | function doUpdate() { |
michael@0 | 35 | // For Mac OS X set the last modified time for the root directory to a date in |
michael@0 | 36 | // the past to test that the last modified time is updated on a successful |
michael@0 | 37 | // update (bug 600098). |
michael@0 | 38 | if (IS_MACOSX) { |
michael@0 | 39 | let applyToDir = getApplyDirFile(); |
michael@0 | 40 | let now = Date.now(); |
michael@0 | 41 | let yesterday = now - (1000 * 60 * 60 * 24); |
michael@0 | 42 | applyToDir.lastModifiedTime = yesterday; |
michael@0 | 43 | } |
michael@0 | 44 | |
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 | if (IS_MACOSX) { |
michael@0 | 54 | logTestInfo("testing last modified time on the apply to directory has " + |
michael@0 | 55 | "changed after a successful update (bug 600098)"); |
michael@0 | 56 | let now = Date.now(); |
michael@0 | 57 | let applyToDir = getApplyDirFile(); |
michael@0 | 58 | let timeDiff = Math.abs(applyToDir.lastModifiedTime - now); |
michael@0 | 59 | do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | checkFilesAfterUpdateSuccess(); |
michael@0 | 63 | // Sorting on Linux is different so skip this check for now. |
michael@0 | 64 | if (!IS_UNIX) { |
michael@0 | 65 | checkUpdateLogContents(LOG_COMPLETE_SUCCESS); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | checkCallbackServiceLog(); |
michael@0 | 69 | } |