toolkit/mozapps/update/tests/unit_service_updater/marAppInUseSuccessCompleteSvc.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   if (!shouldRunServiceTest()) {
     9     return;
    10   }
    12   setupTestCommon();
    13   gTestFiles = gTestFilesCompleteSuccess;
    14   gTestDirs = gTestDirsCompleteSuccess;
    15   setupUpdaterTest(FILE_COMPLETE_MAR, false, false);
    17   // Launch the callback helper application so it is in use during the update.
    18   let callbackApp = getApplyDirFile("a/b/" + gCallbackBinFile);
    19   callbackApp.permissions = PERMS_DIRECTORY;
    20   let args = [getApplyDirPath() + "a/b/", "input", "output", "-s",
    21               HELPER_SLEEP_TIMEOUT];
    22   let callbackAppProcess = AUS_Cc["@mozilla.org/process/util;1"].
    23                            createInstance(AUS_Ci.nsIProcess);
    24   callbackAppProcess.init(callbackApp);
    25   callbackAppProcess.run(false, args, args.length);
    27   setupAppFilesAsync();
    28 }
    30 function setupAppFilesFinished() {
    31   do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
    32 }
    34 function doUpdate() {
    35   // For Mac OS X set the last modified time for the root directory to a date in
    36   // the past to test that the last modified time is updated on a successful
    37   // update (bug 600098).
    38   if (IS_MACOSX) {
    39     let applyToDir = getApplyDirFile();
    40     let now = Date.now();
    41     let yesterday = now - (1000 * 60 * 60 * 24);
    42     applyToDir.lastModifiedTime = yesterday;
    43   }
    45   runUpdateUsingService(STATE_PENDING_SVC, STATE_SUCCEEDED);
    46 }
    48 function checkUpdateFinished() {
    49   setupHelperFinish();
    50 }
    52 function checkUpdate() {
    53   if (IS_MACOSX) {
    54     logTestInfo("testing last modified time on the apply to directory has " +
    55                 "changed after a successful update (bug 600098)");
    56     let now = Date.now();
    57     let applyToDir = getApplyDirFile();
    58     let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
    59     do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
    60   }
    62   checkFilesAfterUpdateSuccess();
    63   // Sorting on Linux is different so skip this check for now.
    64   if (!IS_UNIX) {
    65     checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
    66   }
    68   checkCallbackServiceLog();
    69 }

mercurial