toolkit/mozapps/update/tests/unit_base_updater/marAppInUseSuccessComplete.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/
     3  */
     5 /* Application in use complete MAR file patch apply success test */
     7 function run_test() {
     8   setupTestCommon();
     9   gTestFiles = gTestFilesCompleteSuccess;
    10   gTestDirs = gTestDirsCompleteSuccess;
    11   setupUpdaterTest(FILE_COMPLETE_MAR, false, false);
    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);
    23   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
    24 }
    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   }
    37   runUpdate(0, STATE_SUCCEEDED);
    38 }
    40 function checkUpdateApplied() {
    41   setupHelperFinish();
    42 }
    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   }
    54   checkFilesAfterUpdateSuccess();
    55   // Sorting on Linux is different so skip this check for now.
    56   if (!IS_UNIX) {
    57     checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
    58   }
    60   checkCallbackAppLog();
    61 }

mercurial