2009-04-09 18:11:56 -07:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
2010-11-18 17:20:58 -08:00
|
|
|
* The Original Code is mozilla.org code.
|
2009-04-09 18:11:56 -07:00
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
2010-11-18 17:20:58 -08:00
|
|
|
* the Mozilla Foundation.
|
2009-04-09 18:11:56 -07:00
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2008
|
2010-11-18 17:20:58 -08:00
|
|
|
* the Initial Developer. All Rights Reserved.
|
2009-04-09 18:11:56 -07:00
|
|
|
*
|
|
|
|
* Contributor(s):
|
2010-11-18 17:20:58 -08:00
|
|
|
* Robert Strong <robert.bugzilla@gmail.com> (Original Author)
|
2009-04-09 18:11:56 -07:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2009-07-29 23:01:43 -07:00
|
|
|
/* General Partial MAR File Patch Apply Test */
|
2010-11-06 23:41:49 -07:00
|
|
|
|
2010-11-18 17:20:58 -08:00
|
|
|
const TEST_ID = "0111";
|
2010-11-06 23:41:49 -07:00
|
|
|
// All we care about is that the last modified time has changed so that Mac OS
|
|
|
|
// X Launch Services invalidates its cache so the test allows up to one minute
|
|
|
|
// difference in the last modified time.
|
|
|
|
const MAX_TIME_DIFFERENCE = 60000;
|
2009-04-09 18:11:56 -07:00
|
|
|
|
2011-04-11 21:24:06 -07:00
|
|
|
// The files are listed in the same order as they are applied from the mar's
|
|
|
|
// update.manifest. Complete updates have remove file and rmdir directory
|
|
|
|
// operations located in the precomplete file performed first.
|
2010-11-18 17:20:58 -08:00
|
|
|
const TEST_FILES = [
|
2009-08-07 13:19:58 -07:00
|
|
|
{
|
2011-04-11 21:24:06 -07:00
|
|
|
description : "Only added by update.manifest for complete updates " +
|
|
|
|
"when there is a channel change (add-cc)",
|
|
|
|
fileName : "channel-prefs.js",
|
|
|
|
relPathDir : "a/b/defaults/pref/",
|
|
|
|
originalContents : "ShouldNotBeReplaced\n",
|
|
|
|
compareContents : "ShouldNotBeReplaced\n",
|
|
|
|
originalFile : null,
|
|
|
|
compareFile : null,
|
|
|
|
originalPerms : 0644,
|
|
|
|
comparePerms : null
|
|
|
|
}, {
|
|
|
|
description : "Added by update.manifest (add)",
|
|
|
|
fileName : "precomplete",
|
|
|
|
relPathDir : "",
|
|
|
|
originalContents : null,
|
|
|
|
compareContents : null,
|
|
|
|
originalFile : "data/complete_precomplete",
|
|
|
|
compareFile : "data/partial_precomplete",
|
|
|
|
originalPerms : 0666,
|
|
|
|
comparePerms : 0644
|
|
|
|
}, {
|
|
|
|
description : "Added by update.manifest (add)",
|
|
|
|
fileName : "searchpluginstext0",
|
|
|
|
relPathDir : "a/b/searchplugins/",
|
|
|
|
originalContents : "ToBeReplacedWithFromPartial\n",
|
|
|
|
compareContents : "FromPartial\n",
|
|
|
|
originalFile : null,
|
|
|
|
compareFile : null,
|
|
|
|
originalPerms : 0775,
|
|
|
|
comparePerms : 0644
|
|
|
|
}, {
|
|
|
|
description : "Patched by update.manifest if the file exists " +
|
|
|
|
"(patch-if)",
|
|
|
|
fileName : "searchpluginspng1.png",
|
|
|
|
relPathDir : "a/b/searchplugins/",
|
2009-08-07 13:19:58 -07:00
|
|
|
originalContents : null,
|
|
|
|
compareContents : null,
|
2010-11-18 17:20:58 -08:00
|
|
|
originalFile : "data/complete.png",
|
|
|
|
compareFile : "data/partial.png",
|
2011-04-11 21:24:06 -07:00
|
|
|
originalPerms : 0666,
|
|
|
|
comparePerms : 0666
|
2009-08-07 13:19:58 -07:00
|
|
|
}, {
|
2011-04-11 21:24:06 -07:00
|
|
|
description : "Patched by update.manifest if the file exists " +
|
|
|
|
"(patch-if)",
|
|
|
|
fileName : "searchpluginspng0.png",
|
|
|
|
relPathDir : "a/b/searchplugins/",
|
|
|
|
originalContents : null,
|
|
|
|
compareContents : null,
|
|
|
|
originalFile : "data/complete.png",
|
|
|
|
compareFile : "data/partial.png",
|
|
|
|
originalPerms : 0666,
|
|
|
|
comparePerms : 0666
|
|
|
|
}, {
|
|
|
|
description : "Added by update.manifest if the parent directory " +
|
|
|
|
"exists (add-if)",
|
|
|
|
fileName : "extensions1text0",
|
|
|
|
relPathDir : "a/b/extensions/extensions1/",
|
|
|
|
originalContents : null,
|
|
|
|
compareContents : "FromPartial\n",
|
2009-08-07 13:19:58 -07:00
|
|
|
originalFile : null,
|
|
|
|
compareFile : null,
|
2011-04-11 21:24:06 -07:00
|
|
|
originalPerms : null,
|
|
|
|
comparePerms : 0644
|
2009-08-07 13:19:58 -07:00
|
|
|
}, {
|
2011-04-11 21:24:06 -07:00
|
|
|
description : "Patched by update.manifest if the parent directory " +
|
|
|
|
"exists (patch-if)",
|
|
|
|
fileName : "extensions1png1.png",
|
|
|
|
relPathDir : "a/b/extensions/extensions1/",
|
|
|
|
originalContents : null,
|
|
|
|
compareContents : null,
|
|
|
|
originalFile : "data/complete.png",
|
|
|
|
compareFile : "data/partial.png",
|
|
|
|
originalPerms : 0666,
|
|
|
|
comparePerms : 0666
|
|
|
|
}, {
|
|
|
|
description : "Patched by update.manifest if the parent directory " +
|
|
|
|
"exists (patch-if)",
|
|
|
|
fileName : "extensions1png0.png",
|
|
|
|
relPathDir : "a/b/extensions/extensions1/",
|
|
|
|
originalContents : null,
|
2009-08-07 13:19:58 -07:00
|
|
|
compareContents : null,
|
2011-04-11 21:24:06 -07:00
|
|
|
originalFile : "data/complete.png",
|
|
|
|
compareFile : "data/partial.png",
|
|
|
|
originalPerms : 0666,
|
|
|
|
comparePerms : 0666
|
|
|
|
}, {
|
|
|
|
description : "Added by update.manifest if the parent directory " +
|
|
|
|
"exists (add-if)",
|
|
|
|
fileName : "extensions0text0",
|
|
|
|
relPathDir : "a/b/extensions/extensions0/",
|
|
|
|
originalContents : "ToBeReplacedWithFromPartial\n",
|
|
|
|
compareContents : "FromPartial\n",
|
2009-08-07 13:19:58 -07:00
|
|
|
originalFile : null,
|
|
|
|
compareFile : null,
|
2011-04-11 22:58:01 -07:00
|
|
|
originalPerms : 0644,
|
2011-04-11 21:24:06 -07:00
|
|
|
comparePerms : 0644
|
|
|
|
}, {
|
|
|
|
description : "Patched by update.manifest if the parent directory " +
|
|
|
|
"exists (patch-if)",
|
|
|
|
fileName : "extensions0png1.png",
|
|
|
|
relPathDir : "a/b/extensions/extensions0/",
|
|
|
|
originalContents : null,
|
|
|
|
compareContents : null,
|
|
|
|
originalFile : "data/complete.png",
|
|
|
|
compareFile : "data/partial.png",
|
2011-04-11 22:58:01 -07:00
|
|
|
originalPerms : 0644,
|
2011-04-11 21:24:06 -07:00
|
|
|
comparePerms : 0644
|
|
|
|
}, {
|
|
|
|
description : "Patched by update.manifest if the parent directory " +
|
|
|
|
"exists (patch-if)",
|
|
|
|
fileName : "extensions0png0.png",
|
|
|
|
relPathDir : "a/b/extensions/extensions0/",
|
|
|
|
originalContents : null,
|
|
|
|
compareContents : null,
|
|
|
|
originalFile : "data/complete.png",
|
|
|
|
compareFile : "data/partial.png",
|
2011-04-11 22:58:01 -07:00
|
|
|
originalPerms : 0644,
|
2011-04-11 21:24:06 -07:00
|
|
|
comparePerms : 0644
|
|
|
|
}, {
|
|
|
|
description : "Patched by update.manifest (patch)",
|
|
|
|
fileName : "exe0.exe",
|
|
|
|
relPathDir : "a/b/",
|
|
|
|
originalContents : null,
|
|
|
|
compareContents : null,
|
|
|
|
originalFile : "data/complete.png",
|
|
|
|
compareFile : "data/partial.png",
|
|
|
|
originalPerms : 0755,
|
2011-04-11 22:58:01 -07:00
|
|
|
comparePerms : 0755
|
2009-08-07 13:19:58 -07:00
|
|
|
}, {
|
2011-04-11 21:24:06 -07:00
|
|
|
description : "Patched by update.manifest (patch)",
|
2011-04-11 21:23:36 -07:00
|
|
|
fileName : "0exe0.exe",
|
2011-04-11 21:24:06 -07:00
|
|
|
relPathDir : "a/b/0/",
|
2009-08-07 13:19:58 -07:00
|
|
|
originalContents : null,
|
2010-11-18 17:20:58 -08:00
|
|
|
compareContents : null,
|
|
|
|
originalFile : "data/complete.png",
|
|
|
|
compareFile : "data/partial.png",
|
|
|
|
originalPerms : 0755,
|
2011-04-11 22:58:01 -07:00
|
|
|
comparePerms : 0755
|
2009-08-07 13:19:58 -07:00
|
|
|
}, {
|
2011-04-11 21:24:06 -07:00
|
|
|
description : "Added by update.manifest (add)",
|
|
|
|
fileName : "00text0",
|
|
|
|
relPathDir : "a/b/0/00/",
|
|
|
|
originalContents : "ToBeReplacedWithFromPartial\n",
|
|
|
|
compareContents : "FromPartial\n",
|
2009-08-07 13:19:58 -07:00
|
|
|
originalFile : null,
|
|
|
|
compareFile : null,
|
2011-04-11 21:24:06 -07:00
|
|
|
originalPerms : 0644,
|
2011-04-11 22:58:01 -07:00
|
|
|
comparePerms : 0644
|
2010-11-18 17:20:58 -08:00
|
|
|
}, {
|
2011-04-11 21:24:06 -07:00
|
|
|
description : "Patched by update.manifest (patch)",
|
|
|
|
fileName : "00png0.png",
|
|
|
|
relPathDir : "a/b/0/00/",
|
|
|
|
originalContents : null,
|
|
|
|
compareContents : null,
|
|
|
|
originalFile : "data/complete.png",
|
|
|
|
compareFile : "data/partial.png",
|
|
|
|
originalPerms : 0666,
|
|
|
|
comparePerms : 0666
|
|
|
|
}, {
|
|
|
|
description : "Added by update.manifest (add)",
|
|
|
|
fileName : "20text0",
|
|
|
|
relPathDir : "a/b/2/20/",
|
2010-11-18 17:20:58 -08:00
|
|
|
originalContents : null,
|
2011-04-11 21:24:06 -07:00
|
|
|
compareContents : "FromPartial\n",
|
2010-11-18 17:20:58 -08:00
|
|
|
originalFile : null,
|
|
|
|
compareFile : null,
|
|
|
|
originalPerms : null,
|
|
|
|
comparePerms : 0644
|
2009-08-07 13:19:58 -07:00
|
|
|
}, {
|
2011-04-11 21:24:06 -07:00
|
|
|
description : "Added by update.manifest (add)",
|
|
|
|
fileName : "20png0.png",
|
|
|
|
relPathDir : "a/b/2/20/",
|
2009-08-07 13:19:58 -07:00
|
|
|
originalContents : null,
|
2011-04-11 21:24:06 -07:00
|
|
|
compareContents : null,
|
2009-08-07 13:19:58 -07:00
|
|
|
originalFile : null,
|
2011-04-11 21:24:06 -07:00
|
|
|
compareFile : "data/partial.png",
|
2009-08-07 13:19:58 -07:00
|
|
|
originalPerms : null,
|
|
|
|
comparePerms : 0644
|
2011-04-11 21:23:36 -07:00
|
|
|
}, {
|
2011-04-11 21:24:06 -07:00
|
|
|
description : "Added by update.manifest (add)",
|
|
|
|
fileName : "00text2",
|
|
|
|
relPathDir : "a/b/0/00/",
|
2011-04-11 21:23:36 -07:00
|
|
|
originalContents : null,
|
2011-04-11 21:24:06 -07:00
|
|
|
compareContents : "FromPartial\n",
|
|
|
|
originalFile : null,
|
|
|
|
compareFile : null,
|
|
|
|
originalPerms : null,
|
|
|
|
comparePerms : 0644
|
|
|
|
}, {
|
|
|
|
description : "Removed by update.manifest (remove)",
|
|
|
|
fileName : "10text0",
|
|
|
|
relPathDir : "a/b/1/10/",
|
|
|
|
originalContents : "ToBeDeleted\n",
|
2011-04-11 21:23:36 -07:00
|
|
|
compareContents : null,
|
2011-04-11 21:24:06 -07:00
|
|
|
originalFile : null,
|
|
|
|
compareFile : null,
|
|
|
|
originalPerms : null,
|
2011-04-11 21:23:36 -07:00
|
|
|
comparePerms : null
|
2011-04-11 21:24:06 -07:00
|
|
|
}, {
|
|
|
|
description : "Removed by update.manifest (remove)",
|
|
|
|
fileName : "00text1",
|
|
|
|
relPathDir : "a/b/0/00/",
|
|
|
|
originalContents : "ToBeDeleted\n",
|
|
|
|
compareContents : null,
|
|
|
|
originalFile : null,
|
|
|
|
compareFile : null,
|
|
|
|
originalPerms : null,
|
|
|
|
comparePerms : null
|
|
|
|
}];
|
|
|
|
|
|
|
|
ADDITIONAL_TEST_DIRS = [
|
|
|
|
{
|
|
|
|
description : "Removed by update.manifest (rmdir)",
|
|
|
|
relPathDir : "a/b/1/10/",
|
|
|
|
dirRemoved : true
|
|
|
|
}, {
|
|
|
|
description : "Removed by update.manifest (rmdir)",
|
|
|
|
relPathDir : "a/b/1/",
|
|
|
|
dirRemoved : true
|
2009-08-07 13:19:58 -07:00
|
|
|
}];
|
|
|
|
|
2009-04-09 18:11:56 -07:00
|
|
|
function run_test() {
|
2010-10-19 21:28:29 -07:00
|
|
|
if (IS_ANDROID) {
|
|
|
|
logTestInfo("this test is not applicable to Android... returning early");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
do_test_pending();
|
2011-04-11 21:23:36 -07:00
|
|
|
do_register_cleanup(cleanupUpdaterTest);
|
2010-11-06 23:41:49 -07:00
|
|
|
|
2011-04-11 21:23:36 -07:00
|
|
|
setupUpdaterTest(MAR_PARTIAL_FILE);
|
2010-11-06 23:41:49 -07:00
|
|
|
|
2010-11-18 17:20:58 -08:00
|
|
|
let updatesDir = do_get_file(TEST_ID + UPDATES_DIR_SUFFIX);
|
2011-04-11 21:23:36 -07:00
|
|
|
let applyToDir = getApplyDirFile();
|
2010-11-06 23:41:49 -07:00
|
|
|
|
2011-04-11 21:24:06 -07:00
|
|
|
// Check that trying to change channels for a partial update doesn't change
|
|
|
|
// the update channel (the channel-prefs.js file should not be updated).
|
|
|
|
let force = updatesDir.clone();
|
|
|
|
force.append(CHANNEL_CHANGE_FILE);
|
|
|
|
force.create(AUS_Ci.nsIFile.FILE_TYPE, PERMS_FILE);
|
|
|
|
|
2010-10-19 21:28:29 -07:00
|
|
|
// For Mac OS X set the last modified time for the root directory to a date in
|
2011-04-11 21:24:06 -07:00
|
|
|
// the past to test that the last modified time is updated on all updates since
|
|
|
|
// the precomplete file in the root of the bundle is renamed, etc. (bug 600098).
|
2010-10-19 21:28:29 -07:00
|
|
|
if (IS_MACOSX) {
|
2010-11-18 17:20:58 -08:00
|
|
|
let now = Date.now();
|
|
|
|
let yesterday = now - (1000 * 60 * 60 * 24);
|
2010-10-19 21:28:29 -07:00
|
|
|
applyToDir.lastModifiedTime = yesterday;
|
|
|
|
}
|
|
|
|
|
2010-11-18 17:20:58 -08:00
|
|
|
// apply the partial mar
|
2011-04-11 21:23:36 -07:00
|
|
|
let exitValue = runUpdate();
|
2010-10-19 21:28:29 -07:00
|
|
|
logTestInfo("testing updater binary process exitValue for success when " +
|
|
|
|
"applying a partial mar");
|
2009-04-09 18:11:56 -07:00
|
|
|
do_check_eq(exitValue, 0);
|
|
|
|
|
2010-10-19 21:28:29 -07:00
|
|
|
logTestInfo("testing update.status should be " + STATE_SUCCEEDED);
|
|
|
|
do_check_eq(readStatusFile(updatesDir), STATE_SUCCEEDED);
|
|
|
|
|
|
|
|
// For Mac OS X check that the last modified time for a directory has been
|
|
|
|
// updated after a successful update (bug 600098).
|
|
|
|
if (IS_MACOSX) {
|
|
|
|
logTestInfo("testing last modified time on the apply to directory has " +
|
|
|
|
"changed after a successful update (bug 600098)");
|
2010-11-18 17:20:58 -08:00
|
|
|
let now = Date.now();
|
|
|
|
let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
|
2010-10-19 21:28:29 -07:00
|
|
|
do_check_true(timeDiff < MAX_TIME_DIFFERENCE);
|
|
|
|
}
|
2009-07-29 23:01:43 -07:00
|
|
|
|
2011-04-11 21:23:36 -07:00
|
|
|
checkFilesAfterUpdateSuccess();
|
2011-04-11 22:58:01 -07:00
|
|
|
// Sorting on Linux is different so skip this check for now.
|
|
|
|
if (!IS_UNIX) {
|
|
|
|
checkUpdateLogContents(LOG_PARTIAL_SUCCESS);
|
|
|
|
}
|
2010-11-06 23:41:49 -07:00
|
|
|
|
2010-11-18 17:20:58 -08:00
|
|
|
logTestInfo("testing tobedeleted directory doesn't exist");
|
2011-04-11 21:24:06 -07:00
|
|
|
let toBeDeletedDir = getApplyDirFile("tobedeleted", true);
|
2010-11-18 17:20:58 -08:00
|
|
|
do_check_false(toBeDeletedDir.exists());
|
2010-11-06 23:41:49 -07:00
|
|
|
|
2011-04-11 21:23:36 -07:00
|
|
|
checkCallbackAppLog();
|
2010-11-06 23:41:49 -07:00
|
|
|
}
|