|
@@ -0,0 +1,2267 @@
|
|
|
+# HG changeset patch
|
|
|
+# User Robert Strong <robert.bugzilla@gmail.com>
|
|
|
+# Date 1549653574 0
|
|
|
+# Node ID 3c3b09d5cadd1ab4c93168f4062c6b2bc5c1310d
|
|
|
+# Parent 14327305d9bc8eef3c807f95717ff819fa2bd920
|
|
|
+Bug 1525858 - Use AppConstants and mozinfo where possible instead of the preprocessed test file. r=mhowell
|
|
|
+
|
|
|
+Removes INSTALL_LOCALE (@AB_CD@) since it is no longer used
|
|
|
+Replaces MOZ_APP_NAME (@MOZ_APP_NAME@) with AppConstants.MOZ_APP_NAME
|
|
|
+Replaces IS_WIN, IS_MACOSX, and IS_UNIX with values available from AppConstants.platform
|
|
|
+Replaces BIN_SUFFIX with mozinfo.bin_suffix
|
|
|
+
|
|
|
+Differential Revision: https://phabricator.services.mozilla.com/D19104
|
|
|
+
|
|
|
+diff --git a/toolkit/mozapps/update/tests/browser/head.js b/toolkit/mozapps/update/tests/browser/head.js
|
|
|
+--- a/toolkit/mozapps/update/tests/browser/head.js
|
|
|
++++ b/toolkit/mozapps/update/tests/browser/head.js
|
|
|
+@@ -1,47 +1,42 @@
|
|
|
+-ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
|
|
|
+-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
++/* Any copyright is dedicated to the Public Domain.
|
|
|
++ * http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
++
|
|
|
++"use strict";
|
|
|
++
|
|
|
++const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
|
|
+
|
|
|
+ ChromeUtils.defineModuleGetter(this, "AppMenuNotifications",
|
|
|
+ "resource://gre/modules/AppMenuNotifications.jsm");
|
|
|
+ ChromeUtils.defineModuleGetter(this, "UpdateListener",
|
|
|
+ "resource://gre/modules/UpdateListener.jsm");
|
|
|
+
|
|
|
+-const IS_MACOSX = ("nsILocalFileMac" in Ci);
|
|
|
+-const IS_WIN = ("@mozilla.org/windows-registry-key;1" in Cc);
|
|
|
+-
|
|
|
+-const BIN_SUFFIX = (IS_WIN ? ".exe" : "");
|
|
|
+-const FILE_UPDATER_BIN = "updater" + (IS_MACOSX ? ".app" : BIN_SUFFIX);
|
|
|
++const BIN_SUFFIX = (AppConstants.platform == "win" ? ".exe" : "");
|
|
|
++const FILE_UPDATER_BIN = "updater" + (AppConstants.platform == "macosx" ? ".app" : BIN_SUFFIX);
|
|
|
+ const FILE_UPDATER_BIN_BAK = FILE_UPDATER_BIN + ".bak";
|
|
|
+
|
|
|
+-const PREF_APP_UPDATE_INTERVAL = "app.update.interval";
|
|
|
+-const PREF_APP_UPDATE_LASTUPDATETIME = "app.update.lastUpdateTime.background-update-timer";
|
|
|
+-
|
|
|
+ let gRembemberedPrefs = [];
|
|
|
+
|
|
|
+-const DATA_URI_SPEC = "chrome://mochitests/content/browser/toolkit/mozapps/update/tests/browser/";
|
|
|
+-
|
|
|
+ var DEBUG_AUS_TEST = true;
|
|
|
+ var gUseTestUpdater = false;
|
|
|
+
|
|
|
+ const LOG_FUNCTION = info;
|
|
|
+
|
|
|
+ const MAX_UPDATE_COPY_ATTEMPTS = 10;
|
|
|
+
|
|
|
++const DATA_URI_SPEC = "chrome://mochitests/content/browser/toolkit/mozapps/update/tests/browser/";
|
|
|
+ /* import-globals-from testConstants.js */
|
|
|
+ Services.scriptloader.loadSubScript(DATA_URI_SPEC + "testConstants.js", this);
|
|
|
+-/* import-globals-from ../data/shared.js */
|
|
|
+-Services.scriptloader.loadSubScript(DATA_URI_SPEC + "shared.js", this);
|
|
|
+
|
|
|
+ var gURLData = URL_HOST + "/" + REL_PATH_DATA;
|
|
|
+ const URL_MANUAL_UPDATE = gURLData + "downloadPage.html";
|
|
|
+
|
|
|
+-const gEnv = Cc["@mozilla.org/process/environment;1"].
|
|
|
+- getService(Ci.nsIEnvironment);
|
|
|
++/* import-globals-from ../data/shared.js */
|
|
|
++Services.scriptloader.loadSubScript(DATA_URI_SPEC + "shared.js", this);
|
|
|
+
|
|
|
+ const NOTIFICATIONS = [
|
|
|
+ "update-available",
|
|
|
+ "update-manual",
|
|
|
+ "update-restart"
|
|
|
+ ];
|
|
|
+
|
|
|
+ /**
|
|
|
+diff --git a/toolkit/mozapps/update/tests/browser/head.js.1525858.later b/toolkit/mozapps/update/tests/browser/head.js.1525858.later
|
|
|
+new file mode 100644
|
|
|
+--- /dev/null
|
|
|
++++ b/toolkit/mozapps/update/tests/browser/head.js.1525858.later
|
|
|
+@@ -0,0 +1,40 @@
|
|
|
++--- head.js
|
|
|
+++++ head.js
|
|
|
++@@ -97,17 +92,17 @@ async function continueFileHandler(leafN
|
|
|
++ * when the user doesn't have write access to update. Since this is only
|
|
|
++ * possible on Windows the function throws when it is called on other platforms.
|
|
|
++ * This uses registerCleanupFunction to remove the lock and the file when the
|
|
|
++ * test completes.
|
|
|
++ *
|
|
|
++ * @throws If the function is called on a platform other than Windows.
|
|
|
++ */
|
|
|
++ function lockWriteTestFile() {
|
|
|
++- if (!IS_WIN) {
|
|
|
+++ if (AppConstants.platform != "win") {
|
|
|
++ throw new Error("Windows only test function called");
|
|
|
++ }
|
|
|
++ let file = getUpdatesRootDir();
|
|
|
++ file.append(FILE_UPDATE_TEST);
|
|
|
++ file.QueryInterface(Ci.nsILocalFileWin);
|
|
|
++ // Remove the file if it exists just in case.
|
|
|
++ if (file.exists()) {
|
|
|
++ file.fileAttributesWin |= file.WFA_READWRITE;
|
|
|
++@@ -120,17 +115,17 @@ function lockWriteTestFile() {
|
|
|
++ registerCleanupFunction(() => {
|
|
|
++ file.fileAttributesWin |= file.WFA_READWRITE;
|
|
|
++ file.fileAttributesWin &= ~file.WFA_READONLY;
|
|
|
++ file.remove(false);
|
|
|
++ });
|
|
|
++ }
|
|
|
++
|
|
|
++ function setOtherInstanceHandlingUpdates() {
|
|
|
++- if (!IS_WIN) {
|
|
|
+++ if (AppConstants.platform != "win") {
|
|
|
++ throw new Error("Windows only test function called");
|
|
|
++ }
|
|
|
++ gAUS.observe(null, "test-close-handle-update-mutex", "");
|
|
|
++ let handle = createMutex(getPerInstallationMutexName());
|
|
|
++ registerCleanupFunction(() => {
|
|
|
++ closeHandle(handle);
|
|
|
++ });
|
|
|
++ }
|
|
|
+diff --git a/toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul.1525858.later b/toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul.1525858.later
|
|
|
+new file mode 100644
|
|
|
+--- /dev/null
|
|
|
++++ b/toolkit/mozapps/update/tests/chrome/test_9999_cleanup.xul.1525858.later
|
|
|
+@@ -0,0 +1,30 @@
|
|
|
++--- test_9999_cleanup.xul
|
|
|
+++++ test_9999_cleanup.xul
|
|
|
++@@ -39,26 +39,25 @@ function runTest() {
|
|
|
++ if (DEBUG_AUS_TEST) {
|
|
|
++ Services.prefs.setBoolPref(PREF_APP_UPDATE_LOG, true);
|
|
|
++ }
|
|
|
++
|
|
|
++ closeUpdateWindow();
|
|
|
++
|
|
|
++ // Always disable updates and update staging when cleaning up.
|
|
|
++ Services.prefs.setBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, true);
|
|
|
++- Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true); // Needed to disable updates
|
|
|
++ Services.prefs.setBoolPref(PREF_APP_UPDATE_STAGING_ENABLED, false);
|
|
|
++
|
|
|
++ resetFiles();
|
|
|
++ reloadUpdateManagerData(true);
|
|
|
++ removeUpdateDirsAndFiles();
|
|
|
++
|
|
|
++ // The updates directory is located outside of the application directory and
|
|
|
++ // needs to be removed on Windows and Mac OS X.
|
|
|
++- if (IS_WIN || IS_MACOSX) {
|
|
|
+++ if (AppConstants.platform == "win" || AppConstants.platform == "macosx") {
|
|
|
++ let updatesDir = getUpdatesRootDir();
|
|
|
++ // Try to remove the directory used to apply updates. Since the test has
|
|
|
++ // already finished this is non-fatal for the test.
|
|
|
++ if (updatesDir.exists()) {
|
|
|
++ debugDump("attempting to remove directory. Path: " + updatesDir.path);
|
|
|
++ try {
|
|
|
++ removeDirRecursive(updatesDir);
|
|
|
++ } catch (e) {
|
|
|
+diff --git a/toolkit/mozapps/update/tests/chrome/utils.js b/toolkit/mozapps/update/tests/chrome/utils.js
|
|
|
+--- a/toolkit/mozapps/update/tests/chrome/utils.js
|
|
|
++++ b/toolkit/mozapps/update/tests/chrome/utils.js
|
|
|
+@@ -64,25 +64,26 @@
|
|
|
+ * prefHasUserValue (optional)
|
|
|
+ * For comparing the expected value defined by this property with the return
|
|
|
+ * value of prefHasUserValue using gPrefToCheck for the preference name in the
|
|
|
+ * checkPrefHasUserValue function.
|
|
|
+ */
|
|
|
+
|
|
|
+ "use strict";
|
|
|
+
|
|
|
++// Definitions needed to run eslint on this file.
|
|
|
+ /* globals TESTS, runTest, finishTest */
|
|
|
+
|
|
|
+-ChromeUtils.import("resource://gre/modules/Services.jsm", this);
|
|
|
++const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|
|
++const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
|
|
++
|
|
|
++const DATA_URI_SPEC = "chrome://mochitests/content/chrome/toolkit/mozapps/update/tests/chrome/";
|
|
|
+
|
|
|
+ /* import-globals-from testConstants.js */
|
|
|
+-Services.scriptloader.loadSubScript("chrome://mochitests/content/chrome/toolkit/mozapps/update/tests/chrome/testConstants.js", this);
|
|
|
+-
|
|
|
+-const IS_MACOSX = ("nsILocalFileMac" in Ci);
|
|
|
+-const IS_WIN = ("@mozilla.org/windows-registry-key;1" in Cc);
|
|
|
++Services.scriptloader.loadSubScript(DATA_URI_SPEC + "testConstants.js", this);
|
|
|
+
|
|
|
+ // The tests have to use the pageid instead of the pageIndex due to the
|
|
|
+ // app update wizard's access method being random.
|
|
|
+ const PAGEID_DUMMY = "dummy"; // Done
|
|
|
+ const PAGEID_CHECKING = "checking"; // Done
|
|
|
+ const PAGEID_NO_UPDATES_FOUND = "noupdatesfound"; // Done
|
|
|
+ const PAGEID_MANUAL_UPDATE = "manualUpdate"; // Done
|
|
|
+ const PAGEID_UNSUPPORTED = "unsupported"; // Done
|
|
|
+@@ -98,23 +99,20 @@ const UPDATE_WINDOW_NAME = "Update:Wizar
|
|
|
+
|
|
|
+ // These two URLs must not contain parameters since tests add their own
|
|
|
+ // test specific parameters.
|
|
|
+ const URL_HTTP_UPDATE_XML = URL_HTTP_UPDATE_SJS;
|
|
|
+ const URL_HTTPS_UPDATE_XML = "https://example.com" + URL_PATH_UPDATE_XML;
|
|
|
+
|
|
|
+ const URI_UPDATE_PROMPT_DIALOG = "chrome://mozapps/content/update/updates.xul";
|
|
|
+
|
|
|
+-const PREF_APP_UPDATE_INTERVAL = "app.update.interval";
|
|
|
+-const PREF_APP_UPDATE_LASTUPDATETIME = "app.update.lastUpdateTime.background-update-timer";
|
|
|
+-
|
|
|
+ const LOG_FUNCTION = info;
|
|
|
+
|
|
|
+-const BIN_SUFFIX = (IS_WIN ? ".exe" : "");
|
|
|
+-const FILE_UPDATER_BIN = "updater" + (IS_MACOSX ? ".app" : BIN_SUFFIX);
|
|
|
++const BIN_SUFFIX = (AppConstants.platform == "win" ? ".exe" : "");
|
|
|
++const FILE_UPDATER_BIN = "updater" + (AppConstants.platform == "macosx" ? ".app" : BIN_SUFFIX);
|
|
|
+ const FILE_UPDATER_BIN_BAK = FILE_UPDATER_BIN + ".bak";
|
|
|
+
|
|
|
+ var gURLData = URL_HOST + "/" + REL_PATH_DATA + "/";
|
|
|
+
|
|
|
+ var gTestTimeout = 240000; // 4 minutes
|
|
|
+ var gTimeoutTimer;
|
|
|
+
|
|
|
+ // The number of SimpleTest.executeSoon calls to perform when waiting on an
|
|
|
+@@ -137,17 +135,16 @@ var gDocElem;
|
|
|
+ var gPrefToCheck;
|
|
|
+ var gUseTestUpdater = false;
|
|
|
+
|
|
|
+ // Set to true to log additional information for debugging. To log additional
|
|
|
+ // information for an individual test set DEBUG_AUS_TEST to true in the test's
|
|
|
+ // onload function.
|
|
|
+ var DEBUG_AUS_TEST = true;
|
|
|
+
|
|
|
+-const DATA_URI_SPEC = "chrome://mochitests/content/chrome/toolkit/mozapps/update/tests/data/";
|
|
|
+ /* import-globals-from ../data/shared.js */
|
|
|
+ Services.scriptloader.loadSubScript(DATA_URI_SPEC + "shared.js", this);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * The current test in TESTS array.
|
|
|
+ */
|
|
|
+ this.__defineGetter__("gTest", function() {
|
|
|
+ return TESTS[gTestCounter];
|
|
|
+@@ -821,17 +818,17 @@ function resetFiles() {
|
|
|
+ if (updateSettingsIni.exists()) {
|
|
|
+ updateSettingsIni.moveTo(baseAppDir, FILE_UPDATE_SETTINGS_INI);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Not being able to remove the "updated" directory will not adversely affect
|
|
|
+ // subsequent tests so wrap it in a try block and don't test whether its
|
|
|
+ // removal was successful.
|
|
|
+ let updatedDir;
|
|
|
+- if (IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "macosx") {
|
|
|
+ updatedDir = getUpdatesDir();
|
|
|
+ updatedDir.append(DIR_PATCH);
|
|
|
+ } else {
|
|
|
+ updatedDir = getAppBaseDir();
|
|
|
+ }
|
|
|
+ updatedDir.append(DIR_UPDATED);
|
|
|
+ if (updatedDir.exists()) {
|
|
|
+ try {
|
|
|
+diff --git a/toolkit/mozapps/update/tests/chrome/utils.js.1525858.later b/toolkit/mozapps/update/tests/chrome/utils.js.1525858.later
|
|
|
+new file mode 100644
|
|
|
+--- /dev/null
|
|
|
++++ b/toolkit/mozapps/update/tests/chrome/utils.js.1525858.later
|
|
|
+@@ -0,0 +1,21 @@
|
|
|
++--- utils.js
|
|
|
+++++ utils.js
|
|
|
++@@ -815,17 +812,17 @@ function setupPrefs() {
|
|
|
++ Services.prefs.setIntPref(PREF_APP_UPDATE_LASTUPDATETIME, now);
|
|
|
++ Services.prefs.setIntPref(PREF_APP_UPDATE_INTERVAL, 43200);
|
|
|
++
|
|
|
++ if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_DISABLEDFORTESTING)) {
|
|
|
++ gAppUpdateDisabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING);
|
|
|
++ }
|
|
|
++ Services.prefs.setBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, false);
|
|
|
++
|
|
|
++- if (IS_WIN) {
|
|
|
+++ if (AppConstants.platform == "win") {
|
|
|
++ let configFile = getUpdateConfigFile();
|
|
|
++ if (configFile.exists()) {
|
|
|
++ let configData = JSON.parse(readFileBytes(configFile));
|
|
|
++ gAppUpdateAuto = !!configData[CONFIG_APP_UPDATE_AUTO];
|
|
|
++ }
|
|
|
++ } else if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_AUTO)) {
|
|
|
++ gAppUpdateAuto = Services.prefs.getBoolPref(PREF_APP_UPDATE_AUTO);
|
|
|
++ }
|
|
|
+diff --git a/toolkit/mozapps/update/tests/data/shared.js b/toolkit/mozapps/update/tests/data/shared.js
|
|
|
+--- a/toolkit/mozapps/update/tests/data/shared.js
|
|
|
++++ b/toolkit/mozapps/update/tests/data/shared.js
|
|
|
+@@ -1,29 +1,34 @@
|
|
|
+ /* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
+
|
|
|
+-/* Shared code for xpcshell and mochitests-chrome */
|
|
|
+-/* eslint-disable no-undef */
|
|
|
++/* Shared code for xpcshell, mochitests-chrome, and mochitest-browser-chrome. */
|
|
|
+
|
|
|
+-ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
|
|
|
+-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
++// Definitions needed to run eslint on this file.
|
|
|
++/* global AppConstants, DATA_URI_SPEC, LOG_FUNCTION */
|
|
|
++/* global Services, URL_HOST, DEBUG_AUS_TEST */
|
|
|
++
|
|
|
++const {FileUtils} = ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
|
|
|
++const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
+
|
|
|
+ const PREF_APP_UPDATE_AUTO = "app.update.auto";
|
|
|
+ const PREF_APP_UPDATE_BACKGROUNDERRORS = "app.update.backgroundErrors";
|
|
|
+ const PREF_APP_UPDATE_BACKGROUNDMAXERRORS = "app.update.backgroundMaxErrors";
|
|
|
+ const PREF_APP_UPDATE_CANCELATIONS = "app.update.cancelations";
|
|
|
+ const PREF_APP_UPDATE_CHANNEL = "app.update.channel";
|
|
|
+ const PREF_APP_UPDATE_DOORHANGER = "app.update.doorhanger";
|
|
|
+ const PREF_APP_UPDATE_DOWNLOADPROMPTATTEMPTS = "app.update.download.attempts";
|
|
|
+ const PREF_APP_UPDATE_DOWNLOADPROMPTMAXATTEMPTS = "app.update.download.maxAttempts";
|
|
|
+ const PREF_APP_UPDATE_DOWNLOADBACKGROUNDINTERVAL = "app.update.download.backgroundInterval";
|
|
|
+ const PREF_APP_UPDATE_ENABLED = "app.update.enabled";
|
|
|
+ const PREF_APP_UPDATE_IDLETIME = "app.update.idletime";
|
|
|
++const PREF_APP_UPDATE_INTERVAL = "app.update.interval";
|
|
|
++const PREF_APP_UPDATE_LASTUPDATETIME = "app.update.lastUpdateTime.background-update-timer";
|
|
|
+ const PREF_APP_UPDATE_LOG = "app.update.log";
|
|
|
+ const PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED = "app.update.notifiedUnsupported";
|
|
|
+ const PREF_APP_UPDATE_PROMPTWAITTIME = "app.update.promptWaitTime";
|
|
|
+ const PREF_APP_UPDATE_RETRYTIMEOUT = "app.update.socket.retryTimeout";
|
|
|
+ const PREF_APP_UPDATE_SERVICE_ENABLED = "app.update.service.enabled";
|
|
|
+ const PREF_APP_UPDATE_SILENT = "app.update.silent";
|
|
|
+ const PREF_APP_UPDATE_SOCKET_MAXERRORS = "app.update.socket.maxErrors";
|
|
|
+ const PREF_APP_UPDATE_STAGING_ENABLED = "app.update.staging.enabled";
|
|
|
+@@ -41,42 +46,43 @@ const NS_GRE_DIR = "Gr
|
|
|
+ const NS_GRE_BIN_DIR = "GreBinD";
|
|
|
+ const NS_XPCOM_CURRENT_PROCESS_DIR = "XCurProcD";
|
|
|
+ const XRE_EXECUTABLE_FILE = "XREExeF";
|
|
|
+ const XRE_UPDATE_ROOT_DIR = "UpdRootD";
|
|
|
+
|
|
|
+ const DIR_PATCH = "0";
|
|
|
+ const DIR_TOBEDELETED = "tobedeleted";
|
|
|
+ const DIR_UPDATES = "updates";
|
|
|
+-const DIR_UPDATED = IS_MACOSX ? "Updated.app" : "updated";
|
|
|
++const DIR_UPDATED = AppConstants.platform == "macosx" ? "Updated.app"
|
|
|
++ : "updated";
|
|
|
+
|
|
|
+ const FILE_ACTIVE_UPDATE_XML = "active-update.xml";
|
|
|
+ const FILE_APPLICATION_INI = "application.ini";
|
|
|
+ const FILE_BACKUP_UPDATE_LOG = "backup-update.log";
|
|
|
+ const FILE_LAST_UPDATE_LOG = "last-update.log";
|
|
|
++const FILE_UPDATE_LOG = "update.log";
|
|
|
++const FILE_UPDATE_MAR = "update.mar";
|
|
|
+ const FILE_UPDATE_SETTINGS_INI = "update-settings.ini";
|
|
|
+ const FILE_UPDATE_SETTINGS_INI_BAK = "update-settings.ini.bak";
|
|
|
+-const FILE_UPDATER_INI = "updater.ini";
|
|
|
+-const FILE_UPDATES_XML = "updates.xml";
|
|
|
+-const FILE_UPDATE_LOG = "update.log";
|
|
|
+-const FILE_UPDATE_MAR = "update.mar";
|
|
|
+ const FILE_UPDATE_STATUS = "update.status";
|
|
|
+ const FILE_UPDATE_TEST = "update.test";
|
|
|
+ const FILE_UPDATE_VERSION = "update.version";
|
|
|
++const FILE_UPDATER_INI = "updater.ini";
|
|
|
++const FILE_UPDATES_XML = "updates.xml";
|
|
|
+
|
|
|
+ const UPDATE_SETTINGS_CONTENTS = "[Settings]\n" +
|
|
|
+ "ACCEPTED_MAR_CHANNEL_IDS=xpcshell-test\n";
|
|
|
+
|
|
|
+ const PR_RDWR = 0x04;
|
|
|
+ const PR_CREATE_FILE = 0x08;
|
|
|
+ const PR_TRUNCATE = 0x20;
|
|
|
+
|
|
|
+ var gChannel;
|
|
|
+
|
|
|
+-/* import-globals-from ../data/sharedUpdateXML.js */
|
|
|
++/* import-globals-from sharedUpdateXML.js */
|
|
|
+ Services.scriptloader.loadSubScript(DATA_URI_SPEC + "sharedUpdateXML.js", this);
|
|
|
+
|
|
|
+ const PERMS_FILE = FileUtils.PERMS_FILE;
|
|
|
+ const PERMS_DIRECTORY = FileUtils.PERMS_DIRECTORY;
|
|
|
+
|
|
|
+ const MODE_WRONLY = FileUtils.MODE_WRONLY;
|
|
|
+ const MODE_CREATE = FileUtils.MODE_CREATE;
|
|
|
+ const MODE_APPEND = FileUtils.MODE_APPEND;
|
|
|
+diff --git a/toolkit/mozapps/update/tests/data/shared.js.1525858.later b/toolkit/mozapps/update/tests/data/shared.js.1525858.later
|
|
|
+new file mode 100644
|
|
|
+--- /dev/null
|
|
|
++++ b/toolkit/mozapps/update/tests/data/shared.js.1525858.later
|
|
|
+@@ -0,0 +1,146 @@
|
|
|
++--- shared.js
|
|
|
+++++ shared.js
|
|
|
++@@ -1,94 +1,100 @@
|
|
|
++ const PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED = "app.update.notifiedUnsupported";
|
|
|
++ const PREF_APP_UPDATE_PROMPTWAITTIME = "app.update.promptWaitTime";
|
|
|
++ const PREF_APP_UPDATE_RETRYTIMEOUT = "app.update.socket.retryTimeout";
|
|
|
++ const PREF_APP_UPDATE_SERVICE_ENABLED = "app.update.service.enabled";
|
|
|
++ const PREF_APP_UPDATE_SILENT = "app.update.silent";
|
|
|
++ const PREF_APP_UPDATE_SOCKET_MAXERRORS = "app.update.socket.maxErrors";
|
|
|
++ const PREF_APP_UPDATE_STAGING_ENABLED = "app.update.staging.enabled";
|
|
|
++ const PREF_APP_UPDATE_URL = "app.update.url";
|
|
|
++ const PREF_APP_UPDATE_URL_DETAILS = "app.update.url.details";
|
|
|
++ const PREF_APP_UPDATE_URL_MANUAL = "app.update.url.manual";
|
|
|
++
|
|
|
++ const PREFBRANCH_APP_PARTNER = "app.partner.";
|
|
|
++ const PREF_DISTRIBUTION_ID = "distribution.id";
|
|
|
++ const PREF_DISTRIBUTION_VERSION = "distribution.version";
|
|
|
++-const PREF_DISABLE_SECURITY = "security.turn_off_all_security_so_that_viruses_can_take_over_this_computer";
|
|
|
++
|
|
|
++ const CONFIG_APP_UPDATE_AUTO = "app.update.auto";
|
|
|
++
|
|
|
++ const NS_APP_PROFILE_DIR_STARTUP = "ProfDS";
|
|
|
++ const NS_APP_USER_PROFILE_50_DIR = "ProfD";
|
|
|
++ const NS_GRE_BIN_DIR = "GreBinD";
|
|
|
++ const NS_GRE_DIR = "GreD";
|
|
|
++ const NS_XPCOM_CURRENT_PROCESS_DIR = "XCurProcD";
|
|
|
++ const XRE_EXECUTABLE_FILE = "XREExeF";
|
|
|
++ const XRE_OLD_UPDATE_ROOT_DIR = "OldUpdRootD";
|
|
|
++ const XRE_UPDATE_ROOT_DIR = "UpdRootD";
|
|
|
++
|
|
|
++ const DIR_PATCH = "0";
|
|
|
++ const DIR_TOBEDELETED = "tobedeleted";
|
|
|
++ const DIR_UPDATES = "updates";
|
|
|
++ const DIR_UPDATED = AppConstants.platform == "macosx" ? "Updated.app"
|
|
|
++ : "updated";
|
|
|
++
|
|
|
++ const FILE_ACTIVE_UPDATE_XML = "active-update.xml";
|
|
|
++ const FILE_APPLICATION_INI = "application.ini";
|
|
|
++ const FILE_BACKUP_UPDATE_LOG = "backup-update.log";
|
|
|
++-const FILE_BT_RESULT = "update.bt";
|
|
|
+++const FILE_BT_RESULT = "bt.result";
|
|
|
++ const FILE_LAST_UPDATE_LOG = "last-update.log";
|
|
|
++ const FILE_PRECOMPLETE = "precomplete";
|
|
|
++ const FILE_PRECOMPLETE_BAK = "precomplete.bak";
|
|
|
+++const FILE_UPDATE_CONFIG_JSON = "update-config.json";
|
|
|
++ const FILE_UPDATE_LOG = "update.log";
|
|
|
++ const FILE_UPDATE_MAR = "update.mar";
|
|
|
++ const FILE_UPDATE_SETTINGS_INI = "update-settings.ini";
|
|
|
++ const FILE_UPDATE_SETTINGS_INI_BAK = "update-settings.ini.bak";
|
|
|
++-const FILE_UPDATE_CONFIG = "update-config.json";
|
|
|
++ const FILE_UPDATE_STATUS = "update.status";
|
|
|
++ const FILE_UPDATE_TEST = "update.test";
|
|
|
++ const FILE_UPDATE_VERSION = "update.version";
|
|
|
++ const FILE_UPDATER_INI = "updater.ini";
|
|
|
++ const FILE_UPDATES_XML = "updates.xml";
|
|
|
++
|
|
|
++ const UPDATE_SETTINGS_CONTENTS = "[Settings]\n" +
|
|
|
++ "ACCEPTED_MAR_CHANNEL_IDS=xpcshell-test\n";
|
|
|
++@@ -252,17 +258,17 @@ function writeVersionFile(aVersion) {
|
|
|
++ * Possible values are true, false, null, and undefined. When true or
|
|
|
++ * false this value will be written for app.update.auto in the update
|
|
|
++ * configuration file on Windows or to the user preference on other
|
|
|
++ * platforms. When null or undefined the update configuration file will
|
|
|
++ * be removed on Windows or the user preference will be removed on other
|
|
|
++ * platforms.
|
|
|
++ */
|
|
|
++ function setAppUpdateAutoSync(aEnabled) {
|
|
|
++- if (IS_WIN) {
|
|
|
+++ if (AppConstants.platform == "win") {
|
|
|
++ let file = getUpdateConfigFile();
|
|
|
++ if (aEnabled === undefined || aEnabled === null) {
|
|
|
++ if (file.exists()) {
|
|
|
++ file.remove(false);
|
|
|
++ }
|
|
|
++ } else {
|
|
|
++ writeFile(file, "{\"" + CONFIG_APP_UPDATE_AUTO + "\":" +
|
|
|
++ aEnabled.toString() + "}");
|
|
|
++@@ -640,28 +646,28 @@ function getGREBinDir() {
|
|
|
++ return Services.dirsvc.get(NS_GRE_BIN_DIR, Ci.nsIFile);
|
|
|
++ }
|
|
|
++
|
|
|
++ /**
|
|
|
++ * Returns the file containing update configuration
|
|
|
++ */
|
|
|
++ function getUpdateConfigFile() {
|
|
|
++ let configFile = getUpdatesRootDir();
|
|
|
++- configFile.append(FILE_UPDATE_CONFIG);
|
|
|
+++ configFile.append(FILE_UPDATE_CONFIG_JSON);
|
|
|
++ return configFile;
|
|
|
++ }
|
|
|
++
|
|
|
++ /**
|
|
|
++ * Gets the unique mutex name for the installation.
|
|
|
++ *
|
|
|
++ * @return Global mutex path.
|
|
|
++ * @throws If the function is called on a platform other than Windows.
|
|
|
++ */
|
|
|
++ function getPerInstallationMutexName() {
|
|
|
++- if (!IS_WIN) {
|
|
|
+++ if (AppConstants.platform != "win") {
|
|
|
++ throw new Error("Windows only function called by a different platform!");
|
|
|
++ }
|
|
|
++
|
|
|
++ let hasher = Cc["@mozilla.org/security/hash;1"].
|
|
|
++ createInstance(Ci.nsICryptoHash);
|
|
|
++ hasher.init(hasher.SHA1);
|
|
|
++
|
|
|
++ let exeFile = Services.dirsvc.get(XRE_EXECUTABLE_FILE, Ci.nsIFile);
|
|
|
++@@ -677,17 +683,17 @@ function getPerInstallationMutexName() {
|
|
|
++ /**
|
|
|
++ * Closes a Win32 handle.
|
|
|
++ *
|
|
|
++ * @param aHandle
|
|
|
++ * The handle to close.
|
|
|
++ * @throws If the function is called on a platform other than Windows.
|
|
|
++ */
|
|
|
++ function closeHandle(aHandle) {
|
|
|
++- if (!IS_WIN) {
|
|
|
+++ if (AppConstants.platform != "win") {
|
|
|
++ throw new Error("Windows only function called by a different platform!");
|
|
|
++ }
|
|
|
++
|
|
|
++ let lib = ctypes.open("kernel32.dll");
|
|
|
++ let CloseHandle = lib.declare("CloseHandle",
|
|
|
++ ctypes.winapi_abi,
|
|
|
++ ctypes.int32_t, /* success */
|
|
|
++ ctypes.void_t.ptr); /* handle */
|
|
|
++@@ -699,17 +705,17 @@ function closeHandle(aHandle) {
|
|
|
++ * Creates a mutex.
|
|
|
++ *
|
|
|
++ * @param aName
|
|
|
++ * The name for the mutex.
|
|
|
++ * @return The Win32 handle to the mutex.
|
|
|
++ * @throws If the function is called on a platform other than Windows.
|
|
|
++ */
|
|
|
++ function createMutex(aName) {
|
|
|
++- if (!IS_WIN) {
|
|
|
+++ if (AppConstants.platform != "win") {
|
|
|
++ throw new Error("Windows only function called by a different platform!");
|
|
|
++ }
|
|
|
++
|
|
|
++ const INITIAL_OWN = 1;
|
|
|
++ const ERROR_ALREADY_EXISTS = 0xB7;
|
|
|
++ let lib = ctypes.open("kernel32.dll");
|
|
|
++ let CreateMutexW = lib.declare("CreateMutexW",
|
|
|
++ ctypes.winapi_abi,
|
|
|
+diff --git a/toolkit/mozapps/update/tests/data/xpcshellConstantsPP.js b/toolkit/mozapps/update/tests/data/xpcshellConstantsPP.js
|
|
|
+--- a/toolkit/mozapps/update/tests/data/xpcshellConstantsPP.js
|
|
|
++++ b/toolkit/mozapps/update/tests/data/xpcshellConstantsPP.js
|
|
|
+@@ -1,53 +1,23 @@
|
|
|
+ /* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
+
|
|
|
+ /* Preprocessed constants used by xpcshell tests */
|
|
|
+
|
|
|
+-const INSTALL_LOCALE = "@AB_CD@";
|
|
|
+-const MOZ_APP_NAME = "@MOZ_APP_NAME@";
|
|
|
+-const BIN_SUFFIX = "@BIN_SUFFIX@";
|
|
|
+-
|
|
|
+ // MOZ_APP_VENDOR is optional.
|
|
|
+ #ifdef MOZ_APP_VENDOR
|
|
|
+ const MOZ_APP_VENDOR = "@MOZ_APP_VENDOR@";
|
|
|
+ #else
|
|
|
+ const MOZ_APP_VENDOR = "";
|
|
|
+ #endif
|
|
|
+
|
|
|
+ // MOZ_APP_BASENAME is not optional for tests.
|
|
|
+ const MOZ_APP_BASENAME = "@MOZ_APP_BASENAME@";
|
|
|
+-#ifdef XP_LINUX
|
|
|
+-const APP_BIN_SUFFIX = "-bin";
|
|
|
+-#else
|
|
|
+-const APP_BIN_SUFFIX = "@BIN_SUFFIX@";
|
|
|
+-#endif
|
|
|
+-
|
|
|
+-const APP_INFO_NAME = "XPCShell";
|
|
|
+-const APP_INFO_VENDOR = "Mozilla";
|
|
|
+-
|
|
|
+-#ifdef XP_WIN
|
|
|
+-const IS_WIN = true;
|
|
|
+-#else
|
|
|
+-const IS_WIN = false;
|
|
|
+-#endif
|
|
|
+-
|
|
|
+-#ifdef XP_MACOSX
|
|
|
+-const IS_MACOSX = true;
|
|
|
+-#else
|
|
|
+-const IS_MACOSX = false;
|
|
|
+-#endif
|
|
|
+-
|
|
|
+-#ifdef XP_UNIX
|
|
|
+-const IS_UNIX = true;
|
|
|
+-#else
|
|
|
+-const IS_UNIX = false;
|
|
|
+-#endif
|
|
|
+
|
|
|
+ #ifdef MOZ_VERIFY_MAR_SIGNATURE
|
|
|
+ const MOZ_VERIFY_MAR_SIGNATURE = true;
|
|
|
+ #else
|
|
|
+ const MOZ_VERIFY_MAR_SIGNATURE = false;
|
|
|
+ #endif
|
|
|
+
|
|
|
+ #ifdef DISABLE_UPDATER_AUTHENTICODE_CHECK
|
|
|
+diff --git a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
|
|
|
+--- a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
|
|
|
++++ b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
|
|
|
+@@ -27,66 +27,63 @@
|
|
|
+ * "NS_FAILED(rv)" in nsThreadUtils.cpp are due to using timers and it might be
|
|
|
+ * possible to fix some or all of these in the test itself.
|
|
|
+ */
|
|
|
+
|
|
|
+ "use strict";
|
|
|
+
|
|
|
+ /* eslint-disable no-undef */
|
|
|
+
|
|
|
++const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
|
|
++const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|
|
++const {TestUtils} = ChromeUtils.import("resource://testing-common/TestUtils.jsm");
|
|
|
++
|
|
|
++ChromeUtils.defineModuleGetter(this, "MockRegistrar",
|
|
|
++ "resource://testing-common/MockRegistrar.jsm");
|
|
|
++
|
|
|
+ const Cm = Components.manager;
|
|
|
+
|
|
|
+ const URL_HTTP_UPDATE_SJS = "http://test_details/";
|
|
|
+
|
|
|
+-/* global INSTALL_LOCALE, MOZ_APP_NAME, BIN_SUFFIX, MOZ_APP_VENDOR */
|
|
|
+-/* global MOZ_APP_BASENAME, APP_BIN_SUFFIX, APP_INFO_NAME, APP_INFO_VENDOR */
|
|
|
+-/* global IS_WIN, IS_MACOSX, IS_UNIX, MOZ_VERIFY_MAR_SIGNATURE */
|
|
|
+-/* global IS_AUTHENTICODE_CHECK_ENABLED */
|
|
|
++/* global MOZ_APP_VENDOR, MOZ_APP_BASENAME */
|
|
|
++/* global MOZ_VERIFY_MAR_SIGNATURE, IS_AUTHENTICODE_CHECK_ENABLED */
|
|
|
+ load("../data/xpcshellConstantsPP.js");
|
|
|
+
|
|
|
+-function getLogSuffix() {
|
|
|
+- if (IS_WIN) {
|
|
|
+- return "_win";
|
|
|
+- }
|
|
|
+- if (IS_MACOSX) {
|
|
|
+- return "_mac";
|
|
|
+- }
|
|
|
+- return "_linux";
|
|
|
+-}
|
|
|
+-
|
|
|
+-ChromeUtils.import("resource://gre/modules/Services.jsm", this);
|
|
|
+-
|
|
|
+-const DIR_MACOS = IS_MACOSX ? "Contents/MacOS/" : "";
|
|
|
+-const DIR_RESOURCES = IS_MACOSX ? "Contents/Resources/" : "";
|
|
|
+-const TEST_FILE_SUFFIX = IS_MACOSX ? "_mac" : "";
|
|
|
++const DIR_MACOS = AppConstants.platform == "macosx" ? "Contents/MacOS/" : "";
|
|
|
++const DIR_RESOURCES = AppConstants.platform == "macosx" ? "Contents/Resources/" : "";
|
|
|
++const TEST_FILE_SUFFIX = AppConstants.platform == "macosx" ? "_mac" : "";
|
|
|
+ const FILE_COMPLETE_MAR = "complete" + TEST_FILE_SUFFIX + ".mar";
|
|
|
+ const FILE_PARTIAL_MAR = "partial" + TEST_FILE_SUFFIX + ".mar";
|
|
|
+ const FILE_COMPLETE_PRECOMPLETE = "complete_precomplete" + TEST_FILE_SUFFIX;
|
|
|
+ const FILE_PARTIAL_PRECOMPLETE = "partial_precomplete" + TEST_FILE_SUFFIX;
|
|
|
+ const FILE_COMPLETE_REMOVEDFILES = "complete_removed-files" + TEST_FILE_SUFFIX;
|
|
|
+ const FILE_PARTIAL_REMOVEDFILES = "partial_removed-files" + TEST_FILE_SUFFIX;
|
|
|
+ const FILE_UPDATE_IN_PROGRESS_LOCK = "updated.update_in_progress.lock";
|
|
|
+-const COMPARE_LOG_SUFFIX = getLogSuffix();
|
|
|
++const COMPARE_LOG_SUFFIX = "_" + mozinfo.os;
|
|
|
+ const LOG_COMPLETE_SUCCESS = "complete_log_success" + COMPARE_LOG_SUFFIX;
|
|
|
+ const LOG_PARTIAL_SUCCESS = "partial_log_success" + COMPARE_LOG_SUFFIX;
|
|
|
+ const LOG_PARTIAL_FAILURE = "partial_log_failure" + COMPARE_LOG_SUFFIX;
|
|
|
+ const LOG_REPLACE_SUCCESS = "replace_log_success";
|
|
|
+
|
|
|
+-const USE_EXECV = IS_UNIX && !IS_MACOSX;
|
|
|
++const USE_EXECV = AppConstants.platform == "linux";
|
|
|
+
|
|
|
+ const URL_HOST = "http://localhost";
|
|
|
+
|
|
|
+-const FILE_APP_BIN = MOZ_APP_NAME + APP_BIN_SUFFIX;
|
|
|
++const APP_INFO_NAME = "XPCShell";
|
|
|
++const APP_INFO_VENDOR = "Mozilla";
|
|
|
++
|
|
|
++const APP_BIN_SUFFIX = AppConstants.platform == "linux" ? "-bin" : mozinfo.bin_suffix;
|
|
|
++const FILE_APP_BIN = AppConstants.MOZ_APP_NAME + APP_BIN_SUFFIX;
|
|
|
+ const FILE_COMPLETE_EXE = "complete.exe";
|
|
|
+-const FILE_HELPER_BIN = "TestAUSHelper" + BIN_SUFFIX;
|
|
|
++const FILE_HELPER_BIN = "TestAUSHelper" + mozinfo.bin_suffix;
|
|
|
+ const FILE_MAINTENANCE_SERVICE_BIN = "maintenanceservice.exe";
|
|
|
+ const FILE_MAINTENANCE_SERVICE_INSTALLER_BIN = "maintenanceservice_installer.exe";
|
|
|
+ const FILE_OLD_VERSION_MAR = "old_version.mar";
|
|
|
+ const FILE_PARTIAL_EXE = "partial.exe";
|
|
|
+-const FILE_UPDATER_BIN = "updater" + BIN_SUFFIX;
|
|
|
++const FILE_UPDATER_BIN = "updater" + mozinfo.bin_suffix;
|
|
|
+ const FILE_WRONG_CHANNEL_MAR = "wrong_product_channel.mar";
|
|
|
+
|
|
|
+ const PERFORMING_STAGED_UPDATE = "Performing a staged update";
|
|
|
+ const CALL_QUIT = "calling QuitProgressUI";
|
|
|
+ const ERR_UPDATE_IN_PROGRESS = "Update already in progress! Exiting";
|
|
|
+ const ERR_RENAME_FILE = "rename_file: failed to rename file";
|
|
|
+ const ERR_ENSURE_COPY = "ensure_copy: failed to copy the file";
|
|
|
+ const ERR_UNABLE_OPEN_DEST = "unable to open destination file";
|
|
|
+@@ -119,17 +116,17 @@ const HELPER_SLEEP_TIMEOUT = 180;
|
|
|
+ // the test will try to kill it.
|
|
|
+ const APP_TIMER_TIMEOUT = 120000;
|
|
|
+
|
|
|
+ // How many of do_timeout calls using FILE_IN_USE_TIMEOUT_MS to wait before the
|
|
|
+ // test is aborted.
|
|
|
+ const FILE_IN_USE_MAX_TIMEOUT_RUNS = 60;
|
|
|
+ const FILE_IN_USE_TIMEOUT_MS = 1000;
|
|
|
+
|
|
|
+-const PIPE_TO_NULL = IS_WIN ? ">nul" : "> /dev/null 2>&1";
|
|
|
++const PIPE_TO_NULL = AppConstants.platform == "win" ? ">nul" : "> /dev/null 2>&1";
|
|
|
+
|
|
|
+ const LOG_FUNCTION = info;
|
|
|
+
|
|
|
+ const gHTTPHandlerPath = "updates.xml";
|
|
|
+
|
|
|
+ // This default value will be overridden when using the http server.
|
|
|
+ var gURLData = URL_HOST + "/";
|
|
|
+
|
|
|
+@@ -156,19 +153,19 @@ var gHandle;
|
|
|
+ var gGREDirOrig;
|
|
|
+ var gGREBinDirOrig;
|
|
|
+ var gAppDirOrig;
|
|
|
+
|
|
|
+ var gPIDPersistProcess;
|
|
|
+
|
|
|
+ // Variables are used instead of contants so tests can override these values if
|
|
|
+ // necessary.
|
|
|
+-var gCallbackBinFile = "callback_app" + BIN_SUFFIX;
|
|
|
++var gCallbackBinFile = "callback_app" + mozinfo.bin_suffix;
|
|
|
+ var gCallbackArgs = ["./", "callback.log", "Test Arg 2", "Test Arg 3"];
|
|
|
+-var gPostUpdateBinFile = "postup_app" + BIN_SUFFIX;
|
|
|
++var gPostUpdateBinFile = "postup_app" + mozinfo.bin_suffix;
|
|
|
+ var gSvcOriginalLogContents;
|
|
|
+ // Some update staging failures can remove the update. This allows tests to
|
|
|
+ // specify that the status file and the active update should not be checked
|
|
|
+ // after an update is staged.
|
|
|
+ var gStagingRemovedUpdate = false;
|
|
|
+
|
|
|
+ var gTimeoutRuns = 0;
|
|
|
+ var gFileInUseTimeoutRuns = 0;
|
|
|
+@@ -182,24 +179,23 @@ var gEnvDyldLibraryPath;
|
|
|
+ var gEnvLdLibraryPath;
|
|
|
+ var gASanOptions;
|
|
|
+
|
|
|
+ // Set to true to log additional information for debugging. To log additional
|
|
|
+ // information for an individual test set DEBUG_AUS_TEST to true in the test's
|
|
|
+ // run_test function.
|
|
|
+ var DEBUG_AUS_TEST = true;
|
|
|
+
|
|
|
++const URL_HTTP_UPDATE_SJS = "http://test_details/";
|
|
|
+ const DATA_URI_SPEC = Services.io.newFileURI(do_get_file("../data", false)).spec;
|
|
|
+ /* import-globals-from ../data/shared.js */
|
|
|
+ Services.scriptloader.loadSubScript(DATA_URI_SPEC + "shared.js", this);
|
|
|
+
|
|
|
+ XPCOMUtils.defineLazyModuleGetter(this, "ctypes",
|
|
|
+ "resource://gre/modules/ctypes.jsm");
|
|
|
+-XPCOMUtils.defineLazyModuleGetter(this, "MockRegistrar",
|
|
|
+- "resource://testing-common/MockRegistrar.jsm");
|
|
|
+
|
|
|
+ var gTestFiles = [];
|
|
|
+ var gTestDirs = [];
|
|
|
+
|
|
|
+ // Common files for both successful and failed updates.
|
|
|
+ var gTestFilesCommon = [
|
|
|
+ {
|
|
|
+ description: "Should never change",
|
|
|
+@@ -800,22 +796,20 @@ function setupTestCommon() {
|
|
|
+ // existing test directory (bug 1294196).
|
|
|
+ gTestID += "_new";
|
|
|
+ logTestInfo("using a new directory for the test by changing gTestID " +
|
|
|
+ "since there is an existing test directory that can't be " +
|
|
|
+ "removed, gTestID: " + gTestID);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ Services.prefs.setBoolPref(PREF_APP_UPDATE_SERVICE_ENABLED, !!IS_SERVICE_TEST);
|
|
|
+ }
|
|
|
+
|
|
|
+- // adjustGeneralPaths registers a cleanup function that calls end_test when
|
|
|
+- // it is defined as a function.
|
|
|
+ adjustGeneralPaths();
|
|
|
+ // Logged once here instead of in the mock directory provider to lessen test
|
|
|
+ // log spam.
|
|
|
+ debugDump("Updates Directory (UpdRootD) Path: " + getMockUpdRootD().path);
|
|
|
+
|
|
|
+ // This prevents a warning about not being able to find the greprefs.js file
|
|
|
+ // from being logged.
|
|
|
+ let grePrefsFile = getGREDir();
|
|
|
+@@ -826,17 +820,17 @@ function setupTestCommon() {
|
|
|
+ if (!grePrefsFile.exists()) {
|
|
|
+ grePrefsFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Remove the updates directory on Windows and Mac OS X which is located
|
|
|
+ // outside of the application directory after the call to adjustGeneralPaths
|
|
|
+ // has set it up. Since the test hasn't ran yet and the directory shouldn't
|
|
|
+ // exist this is non-fatal for the test.
|
|
|
+- if (IS_WIN || IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "win" || AppConstants.platform == "macosx") {
|
|
|
+ let updatesDir = getMockUpdRootD();
|
|
|
+ if (updatesDir.exists()) {
|
|
|
+ debugDump("attempting to remove directory. Path: " + updatesDir.path);
|
|
|
+ try {
|
|
|
+ removeDirRecursive(updatesDir);
|
|
|
+ } catch (e) {
|
|
|
+ logTestInfo("non-fatal error removing directory. Path: " +
|
|
|
+ updatesDir.path + ", Exception: " + e);
|
|
|
+@@ -863,22 +857,22 @@ function cleanupTestCommon() {
|
|
|
+ // shutdown of app update runs without throwing or leaking. The observer
|
|
|
+ // method is used directly instead of calling notifyObservers so components
|
|
|
+ // outside of the scope of this test don't assert and thereby cause app update
|
|
|
+ // tests to fail.
|
|
|
+ gAUS.observe(null, "quit-application", "");
|
|
|
+
|
|
|
+ gTestserver = null;
|
|
|
+
|
|
|
+- if (IS_UNIX) {
|
|
|
++ if (AppConstants.platform == "macosx" || AppConstants.platform == "linux") {
|
|
|
+ // This will delete the launch script if it exists.
|
|
|
+ getLaunchScript();
|
|
|
+ }
|
|
|
+
|
|
|
+- if (IS_WIN && MOZ_APP_BASENAME) {
|
|
|
++ if (AppConstants.platform == "win" && MOZ_APP_BASENAME) {
|
|
|
+ let appDir = getApplyDirFile(null, true);
|
|
|
+ let vendor = MOZ_APP_VENDOR ? MOZ_APP_VENDOR : "Mozilla";
|
|
|
+ const REG_PATH = "SOFTWARE\\" + vendor + "\\" + MOZ_APP_BASENAME +
|
|
|
+ "\\TaskBarIDs";
|
|
|
+ let key = Cc["@mozilla.org/windows-registry-key;1"].
|
|
|
+ createInstance(Ci.nsIWindowsRegKey);
|
|
|
+ try {
|
|
|
+ key.open(Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE, REG_PATH,
|
|
|
+@@ -895,29 +889,29 @@ function cleanupTestCommon() {
|
|
|
+ key.removeValue(appDir.path);
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // The updates directory is located outside of the application directory and
|
|
|
+ // needs to be removed on Windows and Mac OS X.
|
|
|
+- if (IS_WIN || IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "win" || AppConstants.platform == "macosx") {
|
|
|
+ let updatesDir = getMockUpdRootD();
|
|
|
+ // Try to remove the directory used to apply updates. Since the test has
|
|
|
+ // already finished this is non-fatal for the test.
|
|
|
+ if (updatesDir.exists()) {
|
|
|
+ debugDump("attempting to remove directory. Path: " + updatesDir.path);
|
|
|
+ try {
|
|
|
+ removeDirRecursive(updatesDir);
|
|
|
+ } catch (e) {
|
|
|
+ logTestInfo("non-fatal error removing directory. Path: " +
|
|
|
+ updatesDir.path + ", Exception: " + e);
|
|
|
+ }
|
|
|
+- if (IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "macosx") {
|
|
|
+ let updatesRootDir = gUpdatesRootDir.clone();
|
|
|
+ while (updatesRootDir.path != updatesDir.path) {
|
|
|
+ if (updatesDir.exists()) {
|
|
|
+ debugDump("attempting to remove directory. Path: " +
|
|
|
+ updatesDir.path);
|
|
|
+ try {
|
|
|
+ // Try to remove the directory without the recursive flag set
|
|
|
+ // since the top level directory has already had its contents
|
|
|
+@@ -1072,32 +1066,32 @@ function preventDistributionFiles() {
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * On Mac OS X this sets the last modified time for the app bundle directory to
|
|
|
+ * a date in the past to test that the last modified time is updated when an
|
|
|
+ * update has been successfully applied (bug 600098).
|
|
|
+ */
|
|
|
+ function setAppBundleModTime() {
|
|
|
+- if (!IS_MACOSX) {
|
|
|
++ if (AppConstants.platform != "macosx") {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let now = Date.now();
|
|
|
+ let yesterday = now - (1000 * 60 * 60 * 24);
|
|
|
+ let applyToDir = getApplyDirFile();
|
|
|
+ applyToDir.lastModifiedTime = yesterday;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * On Mac OS X this checks that the last modified time for the app bundle
|
|
|
+ * directory has been updated when an update has been successfully applied
|
|
|
+ * (bug 600098).
|
|
|
+ */
|
|
|
+ function checkAppBundleModTime() {
|
|
|
+- if (!IS_MACOSX) {
|
|
|
++ if (AppConstants.platform != "macosx") {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let now = Date.now();
|
|
|
+ let applyToDir = getApplyDirFile();
|
|
|
+ let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
|
|
|
+ Assert.ok(timeDiff < MAC_MAX_TIME_DIFFERENCE,
|
|
|
+ "the last modified time on the apply to directory should " +
|
|
|
+ "change after a successful update");
|
|
|
+@@ -1201,17 +1195,17 @@ function waitForUpdateXMLFiles(aActiveUp
|
|
|
+ /**
|
|
|
+ * On Mac OS X and Windows this checks if the post update '.running' file exists
|
|
|
+ * to determine if the post update binary was launched.
|
|
|
+ *
|
|
|
+ * @param aShouldExist
|
|
|
+ * Whether the post update '.running' file should exist.
|
|
|
+ */
|
|
|
+ function checkPostUpdateRunningFile(aShouldExist) {
|
|
|
+- if (!IS_WIN && !IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "linux") {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let postUpdateRunningFile = getPostUpdateFile(".running");
|
|
|
+ if (aShouldExist) {
|
|
|
+ Assert.ok(postUpdateRunningFile.exists(),
|
|
|
+ MSG_SHOULD_EXIST + getMsgPath(postUpdateRunningFile.path));
|
|
|
+ } else {
|
|
|
+ Assert.ok(!postUpdateRunningFile.exists(),
|
|
|
+@@ -1310,17 +1304,17 @@ function getApplyDirFile(aRelPath, aAllo
|
|
|
+ * Whether the file must exist. If false or not specified the file must
|
|
|
+ * exist or the function will throw.
|
|
|
+ * @return The nsIFile for the file in the directory where the update will be
|
|
|
+ * staged.
|
|
|
+ * @throws If aAllowNonexistent is not specified or is false and the file or
|
|
|
+ * directory does not exist.
|
|
|
+ */
|
|
|
+ function getStageDirFile(aRelPath, aAllowNonexistent) {
|
|
|
+- if (IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "macosx") {
|
|
|
+ let file = getMockUpdRootD();
|
|
|
+ file.append(DIR_UPDATES);
|
|
|
+ file.append(DIR_PATCH);
|
|
|
+ file.append(DIR_UPDATED);
|
|
|
+ if (aRelPath) {
|
|
|
+ let pathParts = aRelPath.split("/");
|
|
|
+ for (let i = 0; i < pathParts.length; i++) {
|
|
|
+ if (pathParts[i]) {
|
|
|
+@@ -1369,19 +1363,20 @@ function getTestDirFile(aRelPath, aAllow
|
|
|
+ return do_get_file(relpath, !!aAllowNonExists);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Helper function for getting the nsIFile for the maintenance service
|
|
|
+ * directory on Windows.
|
|
|
+ *
|
|
|
+ * @return The nsIFile for the maintenance service directory.
|
|
|
++ * @throws If called from a platform other than Windows.
|
|
|
+ */
|
|
|
+ function getMaintSvcDir() {
|
|
|
+- if (!IS_WIN) {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
+ do_throw("Windows only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ const CSIDL_PROGRAM_FILES = 0x26;
|
|
|
+ const CSIDL_PROGRAM_FILESX86 = 0x2A;
|
|
|
+ // This will return an empty string on our Win XP build systems.
|
|
|
+ let maintSvcDir = getSpecialFolderDir(CSIDL_PROGRAM_FILESX86);
|
|
|
+ if (maintSvcDir) {
|
|
|
+@@ -1409,17 +1404,17 @@ function getMaintSvcDir() {
|
|
|
+ * passed.
|
|
|
+ *
|
|
|
+ * @param aCSIDL
|
|
|
+ * The CSIDL for the Windows special folder.
|
|
|
+ * @return The nsIFile for the Windows special folder.
|
|
|
+ * @throws If called from a platform other than Windows.
|
|
|
+ */
|
|
|
+ function getSpecialFolderDir(aCSIDL) {
|
|
|
+- if (!IS_WIN) {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
+ do_throw("Windows only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ let lib = ctypes.open("shell32");
|
|
|
+ let SHGetSpecialFolderPath = lib.declare("SHGetSpecialFolderPathW",
|
|
|
+ ctypes.winapi_abi,
|
|
|
+ ctypes.bool, /* bool(return) */
|
|
|
+ ctypes.int32_t, /* HWND hwndOwner */
|
|
|
+@@ -1437,17 +1432,17 @@ function getSpecialFolderDir(aCSIDL) {
|
|
|
+ }
|
|
|
+ debugDump("SHGetSpecialFolderPath returned path: " + path);
|
|
|
+ let dir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
|
|
+ dir.initWithPath(path);
|
|
|
+ return dir;
|
|
|
+ }
|
|
|
+
|
|
|
+ XPCOMUtils.defineLazyGetter(this, "gInstallDirPathHash", function test_gIDPH() {
|
|
|
+- if (!IS_WIN) {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
+ do_throw("Windows only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!MOZ_APP_BASENAME) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ let vendor = MOZ_APP_VENDOR ? MOZ_APP_VENDOR : "Mozilla";
|
|
|
+@@ -1474,59 +1469,61 @@ XPCOMUtils.defineLazyGetter(this, "gInst
|
|
|
+ logTestInfo("failed to create registry key. Registry Path: " + REG_PATH +
|
|
|
+ ", Key Name: " + appDir.path + ", Key Value: " + gTestID +
|
|
|
+ ", Exception " + e);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ });
|
|
|
+
|
|
|
+ XPCOMUtils.defineLazyGetter(this, "gLocalAppDataDir", function test_gLADD() {
|
|
|
+- if (!IS_WIN) {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
+ do_throw("Windows only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ const CSIDL_LOCAL_APPDATA = 0x1c;
|
|
|
+ return getSpecialFolderDir(CSIDL_LOCAL_APPDATA);
|
|
|
+ });
|
|
|
+
|
|
|
+ XPCOMUtils.defineLazyGetter(this, "gProgFilesDir", function test_gPFD() {
|
|
|
+- if (!IS_WIN) {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
+ do_throw("Windows only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ const CSIDL_PROGRAM_FILES = 0x26;
|
|
|
+ return getSpecialFolderDir(CSIDL_PROGRAM_FILES);
|
|
|
+ });
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Helper function for getting the update root directory used by the tests. This
|
|
|
+ * returns the same directory as returned by nsXREDirProvider::GetUpdateRootDir
|
|
|
+ * in nsXREDirProvider.cpp so an application will be able to find the update
|
|
|
+ * when running a test that launches the application.
|
|
|
+ */
|
|
|
+ function getMockUpdRootD() {
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ return getMockUpdRootDWin();
|
|
|
+ }
|
|
|
+
|
|
|
+- if (IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "macosx") {
|
|
|
+ return getMockUpdRootDMac();
|
|
|
+ }
|
|
|
+
|
|
|
+ return getApplyDirFile(DIR_MACOS, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Helper function for getting the update root directory used by the tests. This
|
|
|
+ * returns the same directory as returned by nsXREDirProvider::GetUpdateRootDir
|
|
|
+ * in nsXREDirProvider.cpp so an application will be able to find the update
|
|
|
+ * when running a test that launches the application.
|
|
|
++ *
|
|
|
++ * @throws If called from a platform other than Windows.
|
|
|
+ */
|
|
|
+ function getMockUpdRootDWin() {
|
|
|
+- if (!IS_WIN) {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
+ do_throw("Windows only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ let localAppDataDir = gLocalAppDataDir.clone();
|
|
|
+ let progFilesDir = gProgFilesDir.clone();
|
|
|
+ let appDir = Services.dirsvc.get(XRE_EXECUTABLE_FILE, Ci.nsIFile).parent;
|
|
|
+
|
|
|
+ let appDirPath = appDir.path;
|
|
|
+@@ -1560,17 +1557,17 @@ function getMockUpdRootDWin() {
|
|
|
+
|
|
|
+ let updatesDir = Cc["@mozilla.org/file/local;1"].
|
|
|
+ createInstance(Ci.nsIFile);
|
|
|
+ updatesDir.initWithPath(localAppDataDir.path + "\\" + relPathUpdates);
|
|
|
+ return updatesDir;
|
|
|
+ }
|
|
|
+
|
|
|
+ XPCOMUtils.defineLazyGetter(this, "gUpdatesRootDir", function test_gURD() {
|
|
|
+- if (!IS_MACOSX) {
|
|
|
++ if (AppConstants.platform != "macosx") {
|
|
|
+ do_throw("Mac OS X only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ let dir = Services.dirsvc.get("ULibDir", Ci.nsIFile);
|
|
|
+ dir.append("Caches");
|
|
|
+ if (MOZ_APP_VENDOR || MOZ_APP_BASENAME) {
|
|
|
+ dir.append(MOZ_APP_VENDOR ? MOZ_APP_VENDOR : MOZ_APP_BASENAME);
|
|
|
+ } else {
|
|
|
+@@ -1582,17 +1579,17 @@ XPCOMUtils.defineLazyGetter(this, "gUpda
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Helper function for getting the update root directory used by the tests. This
|
|
|
+ * returns the same directory as returned by nsXREDirProvider::GetUpdateRootDir
|
|
|
+ * in nsXREDirProvider.cpp so an application will be able to find the update
|
|
|
+ * when running a test that launches the application.
|
|
|
+ */
|
|
|
+ function getMockUpdRootDMac() {
|
|
|
+- if (!IS_MACOSX) {
|
|
|
++ if (AppConstants.platform != "macosx") {
|
|
|
+ do_throw("Mac OS X only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ let appDir = Services.dirsvc.get(XRE_EXECUTABLE_FILE, Ci.nsIFile).
|
|
|
+ parent.parent.parent;
|
|
|
+ let appDirPath = appDir.path;
|
|
|
+ appDirPath = appDirPath.substr(0, appDirPath.length - 4);
|
|
|
+
|
|
|
+@@ -1604,19 +1601,20 @@ function getMockUpdRootDMac() {
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Creates an update in progress lock file in the specified directory on
|
|
|
+ * Windows.
|
|
|
+ *
|
|
|
+ * @param aDir
|
|
|
+ * The nsIFile for the directory where the lock file should be created.
|
|
|
++ * @throws If called from a platform other than Windows.
|
|
|
+ */
|
|
|
+ function createUpdateInProgressLockFile(aDir) {
|
|
|
+- if (!IS_WIN) {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
+ do_throw("Windows only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ let file = aDir.clone();
|
|
|
+ file.append(FILE_UPDATE_IN_PROGRESS_LOCK);
|
|
|
+ file.create(file.NORMAL_FILE_TYPE, 0o444);
|
|
|
+ file.QueryInterface(Ci.nsILocalFileWin);
|
|
|
+ file.fileAttributesWin |= file.WFA_READONLY;
|
|
|
+@@ -1628,19 +1626,20 @@ function createUpdateInProgressLockFile(
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Removes an update in progress lock file in the specified directory on
|
|
|
+ * Windows.
|
|
|
+ *
|
|
|
+ * @param aDir
|
|
|
+ * The nsIFile for the directory where the lock file is located.
|
|
|
++ * @throws If called from a platform other than Windows.
|
|
|
+ */
|
|
|
+ function removeUpdateInProgressLockFile(aDir) {
|
|
|
+- if (!IS_WIN) {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
+ do_throw("Windows only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ let file = aDir.clone();
|
|
|
+ file.append(FILE_UPDATE_IN_PROGRESS_LOCK);
|
|
|
+ file.QueryInterface(Ci.nsILocalFileWin);
|
|
|
+ file.fileAttributesWin |= file.WFA_READWRITE;
|
|
|
+ file.fileAttributesWin &= ~file.WFA_READONLY;
|
|
|
+@@ -1685,28 +1684,28 @@ function copyTestUpdaterToBinDir() {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Copies the test updater to the location where it will be launched to apply an
|
|
|
+ * update and returns the nsIFile for the copied test updater.
|
|
|
+ *
|
|
|
+ * @return nsIFIle for the copied test updater.
|
|
|
+ */
|
|
|
+ function copyTestUpdaterForRunUsingUpdater() {
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ return copyTestUpdaterToBinDir();
|
|
|
+ }
|
|
|
+
|
|
|
+ let testUpdater = getTestUpdater();
|
|
|
+ let updater = getUpdatesPatchDir();
|
|
|
+ updater.append(testUpdater.leafName);
|
|
|
+ if (!updater.exists()) {
|
|
|
+ testUpdater.copyToFollowingLinks(updater.parent, updater.leafName);
|
|
|
+ }
|
|
|
+
|
|
|
+- if (IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "macosx") {
|
|
|
+ updater.append("Contents");
|
|
|
+ updater.append("MacOS");
|
|
|
+ updater.append("org.mozilla.updater");
|
|
|
+ }
|
|
|
+ return updater;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -2057,17 +2056,17 @@ function stageUpdate(aCheckSvcLog) {
|
|
|
+ * Checks that the update state is correct as well as the expected files are
|
|
|
+ * present after staging and update for updater tests and then calls
|
|
|
+ * stageUpdateFinished.
|
|
|
+ *
|
|
|
+ * @param aUpdateState
|
|
|
+ * The update state received by the observer notification.
|
|
|
+ */
|
|
|
+ function checkUpdateStagedState(aUpdateState) {
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ if (IS_SERVICE_TEST) {
|
|
|
+ waitForServiceStop(false);
|
|
|
+ } else {
|
|
|
+ let updater = getApplyDirFile(FILE_UPDATER_BIN, true);
|
|
|
+ if (isFileInUse(updater)) {
|
|
|
+ do_timeout(FILE_IN_USE_TIMEOUT_MS,
|
|
|
+ checkUpdateStagedState.bind(null, aUpdateState));
|
|
|
+ return;
|
|
|
+@@ -2121,19 +2120,20 @@ function checkUpdateStagedState(aUpdateS
|
|
|
+ executeSoon(stageUpdateFinished);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Helper function to check whether the maintenance service updater tests should
|
|
|
+ * run. See bug 711660 for more details.
|
|
|
+ *
|
|
|
+ * @return true if the test should run and false if it shouldn't.
|
|
|
++ * @throws If called from a platform other than Windows.
|
|
|
+ */
|
|
|
+ function shouldRunServiceTest() {
|
|
|
+- if (!IS_WIN) {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
+ do_throw("Windows only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ let binDir = getGREBinDir();
|
|
|
+ let updaterBin = binDir.clone();
|
|
|
+ updaterBin.append(FILE_UPDATER_BIN);
|
|
|
+ Assert.ok(updaterBin.exists(),
|
|
|
+ MSG_SHOULD_EXIST + ", leafName: " + updaterBin.leafName);
|
|
|
+@@ -2256,17 +2256,17 @@ function setupAppFiles() {
|
|
|
+ let appFiles = [{relPath: FILE_APP_BIN,
|
|
|
+ inGreDir: false},
|
|
|
+ {relPath: FILE_APPLICATION_INI,
|
|
|
+ inGreDir: true},
|
|
|
+ {relPath: "dependentlibs.list",
|
|
|
+ inGreDir: true}];
|
|
|
+
|
|
|
+ // On Linux the updater.png must also be copied
|
|
|
+- if (IS_UNIX && !IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "linux") {
|
|
|
+ appFiles.push({relPath: "icons/updater.png",
|
|
|
+ inGreDir: true});
|
|
|
+ }
|
|
|
+
|
|
|
+ // Read the dependent libs file leafnames from the dependentlibs.list file
|
|
|
+ // into the array.
|
|
|
+ let deplibsFile = gGREDirOrig.clone();
|
|
|
+ deplibsFile.append("dependentlibs.list");
|
|
|
+@@ -2318,17 +2318,17 @@ function copyFileToTestAppDir(aFileRelPa
|
|
|
+ let pathParts = fileRelPath.split("/");
|
|
|
+ for (let i = 0; i < pathParts.length; i++) {
|
|
|
+ if (pathParts[i]) {
|
|
|
+ srcFile.append(pathParts[i]);
|
|
|
+ destFile.append(pathParts[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+- if (IS_MACOSX && !srcFile.exists()) {
|
|
|
++ if (AppConstants.platform == "macosx" && !srcFile.exists()) {
|
|
|
+ debugDump("unable to copy file since it doesn't exist! Checking if " +
|
|
|
+ fileRelPath + ".app exists. Path: " + srcFile.path);
|
|
|
+ // gGREDirOrig and gGREBinDirOrig must always be cloned when changing its
|
|
|
+ // properties
|
|
|
+ srcFile = aInGreDir ? gGREDirOrig.clone() : gGREBinDirOrig.clone();
|
|
|
+ destFile = aInGreDir ? getGREDir() : getGREBinDir();
|
|
|
+ for (let i = 0; i < pathParts.length; i++) {
|
|
|
+ if (pathParts[i]) {
|
|
|
+@@ -2352,21 +2352,21 @@ function copyFileToTestAppDir(aFileRelPa
|
|
|
+ srcFile.copyToFollowingLinks(destFile.parent, destFile.leafName);
|
|
|
+ } catch (e) {
|
|
|
+ // Just in case it is partially copied
|
|
|
+ if (destFile.exists()) {
|
|
|
+ try {
|
|
|
+ destFile.remove(true);
|
|
|
+ } catch (ex) {
|
|
|
+ logTestInfo("unable to remove file that failed to copy! Path: " +
|
|
|
+- destFile.path);
|
|
|
++ destFile.path + ", Exception: " + ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ do_throw("Unable to copy file! Path: " + srcFile.path +
|
|
|
+- ", Exception: " + ex);
|
|
|
++ ", Exception: " + e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ if (destFile.exists()) {
|
|
|
+ destFile.remove(false);
|
|
|
+ }
|
|
|
+ let ln = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
|
|
+@@ -2388,19 +2388,20 @@ function copyFileToTestAppDir(aFileRelPa
|
|
|
+ * Attempts to upgrade the maintenance service if permissions are allowed.
|
|
|
+ * This is useful for XP where we have permission to upgrade in case an
|
|
|
+ * older service installer exists. Also if the user manually installed into
|
|
|
+ * a unprivileged location.
|
|
|
+ *
|
|
|
+ * @return true if the installed service is from this build. If the installed
|
|
|
+ * service is not from this build the test will fail instead of
|
|
|
+ * returning false.
|
|
|
++ * @throws If called from a platform other than Windows.
|
|
|
+ */
|
|
|
+ function attemptServiceInstall() {
|
|
|
+- if (!IS_WIN) {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
+ do_throw("Windows only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ let maintSvcDir = getMaintSvcDir();
|
|
|
+ Assert.ok(maintSvcDir.exists(),
|
|
|
+ MSG_SHOULD_EXIST + ", leafName: " + maintSvcDir.leafName);
|
|
|
+ let oldMaintSvcBin = maintSvcDir.clone();
|
|
|
+ oldMaintSvcBin.append(FILE_MAINTENANCE_SERVICE_BIN);
|
|
|
+@@ -2437,35 +2438,39 @@ function attemptServiceInstall() {
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Waits for the applications that are launched by the maintenance service to
|
|
|
+ * stop.
|
|
|
++ *
|
|
|
++ * @throws If called from a platform other than Windows.
|
|
|
+ */
|
|
|
+ function waitServiceApps() {
|
|
|
+- if (!IS_WIN) {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
+ do_throw("Windows only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ // maintenanceservice_installer.exe is started async during updates.
|
|
|
+ waitForApplicationStop("maintenanceservice_installer.exe");
|
|
|
+ // maintenanceservice_tmp.exe is started async from the service installer.
|
|
|
+ waitForApplicationStop("maintenanceservice_tmp.exe");
|
|
|
+ // In case the SCM thinks the service is stopped, but process still exists.
|
|
|
+ waitForApplicationStop("maintenanceservice.exe");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Waits for the maintenance service to stop.
|
|
|
++ *
|
|
|
++ * @throws If called from a platform other than Windows.
|
|
|
+ */
|
|
|
+ function waitForServiceStop(aFailTest) {
|
|
|
+- if (!IS_WIN) {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
+ do_throw("Windows only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ waitServiceApps();
|
|
|
+ debugDump("waiting for the maintenance service to stop if necessary");
|
|
|
+ // Use the helper bin to ensure the service is stopped. If not stopped, then
|
|
|
+ // wait for the service to stop (at most 120 seconds).
|
|
|
+ let args = ["wait-for-service-stop", "MozillaMaintenance", "120"];
|
|
|
+@@ -2485,19 +2490,20 @@ function waitForServiceStop(aFailTest) {
|
|
|
+ waitServiceApps();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Waits for the specified application to stop.
|
|
|
+ *
|
|
|
+ * @param aApplication
|
|
|
+ * The application binary name to wait until it has stopped.
|
|
|
++ * @throws If called from a platform other than Windows.
|
|
|
+ */
|
|
|
+ function waitForApplicationStop(aApplication) {
|
|
|
+- if (!IS_WIN) {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
+ do_throw("Windows only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ debugDump("waiting for " + aApplication + " to stop if necessary");
|
|
|
+ // Use the helper bin to ensure the application is stopped. If not stopped,
|
|
|
+ // then wait for it to stop (at most 120 seconds).
|
|
|
+ let args = ["wait-for-application-exit", aApplication, "120"];
|
|
|
+ let exitValue = runTestHelperSync(args);
|
|
|
+@@ -2512,17 +2518,17 @@ function waitForApplicationStop(aApplica
|
|
|
+ * in turn launches a binary used for the test (e.g. application, updater,
|
|
|
+ * etc.). A shell is used so debug console output can be redirected to a file so
|
|
|
+ * it doesn't end up in the test log.
|
|
|
+ *
|
|
|
+ * @return nsIFile for the shell binary to launch using nsIProcess.
|
|
|
+ */
|
|
|
+ function getLaunchBin() {
|
|
|
+ let launchBin;
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ launchBin = Services.dirsvc.get("WinD", Ci.nsIFile);
|
|
|
+ launchBin.append("System32");
|
|
|
+ launchBin.append("cmd.exe");
|
|
|
+ } else {
|
|
|
+ launchBin = Cc["@mozilla.org/file/local;1"].
|
|
|
+ createInstance(Ci.nsIFile);
|
|
|
+ launchBin.initWithPath("/bin/sh");
|
|
|
+ }
|
|
|
+@@ -2533,19 +2539,20 @@ function getLaunchBin() {
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Locks a Windows directory.
|
|
|
+ *
|
|
|
+ * @param aDirPath
|
|
|
+ * The test file object that describes the file to make in use.
|
|
|
++ * @throws If called from a platform other than Windows.
|
|
|
+ */
|
|
|
+ function lockDirectory(aDirPath) {
|
|
|
+- if (!IS_WIN) {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
+ do_throw("Windows only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ debugDump("start - locking installation directory");
|
|
|
+ const LPCWSTR = ctypes.char16_t.ptr;
|
|
|
+ const DWORD = ctypes.uint32_t;
|
|
|
+ const LPVOID = ctypes.voidptr_t;
|
|
|
+ const GENERIC_READ = 0x80000000;
|
|
|
+@@ -2642,17 +2649,17 @@ function runHelperLockFile(aTestFile) {
|
|
|
+ // Exclusively lock an existing file so it is in use during the update.
|
|
|
+ let helperBin = getTestDirFile(FILE_HELPER_BIN);
|
|
|
+ let helperDestDir = getApplyDirFile(DIR_RESOURCES);
|
|
|
+ helperBin.copyTo(helperDestDir, FILE_HELPER_BIN);
|
|
|
+ helperBin = getApplyDirFile(DIR_RESOURCES + FILE_HELPER_BIN);
|
|
|
+ // Strip off the first two directories so the path has to be from the helper's
|
|
|
+ // working directory.
|
|
|
+ let lockFileRelPath = aTestFile.relPathDir.split("/");
|
|
|
+- if (IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "macosx") {
|
|
|
+ lockFileRelPath = lockFileRelPath.slice(2);
|
|
|
+ }
|
|
|
+ lockFileRelPath = lockFileRelPath.join("/") + "/" + aTestFile.fileName;
|
|
|
+ let args = [getApplyDirPath() + DIR_RESOURCES, "input", "output", "-s",
|
|
|
+ HELPER_SLEEP_TIMEOUT, lockFileRelPath];
|
|
|
+ let helperProcess = Cc["@mozilla.org/process/util;1"].
|
|
|
+ createInstance(Ci.nsIProcess);
|
|
|
+ helperProcess.init(helperBin);
|
|
|
+@@ -2791,17 +2798,17 @@ function setupUpdaterTest(aMarFile, aPos
|
|
|
+ } else {
|
|
|
+ testFile = getApplyDirFile(aTestFile.relPathDir + aTestFile.fileName,
|
|
|
+ true);
|
|
|
+ writeFile(testFile, aTestFile.originalContents);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Skip these tests on Windows since chmod doesn't really set permissions
|
|
|
+ // on Windows.
|
|
|
+- if (!IS_WIN && aTestFile.originalPerms) {
|
|
|
++ if (AppConstants.platform != "win" && aTestFile.originalPerms) {
|
|
|
+ testFile.permissions = aTestFile.originalPerms;
|
|
|
+ // Store the actual permissions on the file for reference later after
|
|
|
+ // setting the permissions.
|
|
|
+ if (!aTestFile.comparePerms) {
|
|
|
+ aTestFile.comparePerms = testFile.permissions;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+@@ -2883,17 +2890,17 @@ function createUpdaterINI(aIsExeAsync, a
|
|
|
+ if (aIsExeAsync) {
|
|
|
+ exeAsync = "ExeAsync=true\n";
|
|
|
+ } else {
|
|
|
+ exeArg = "ExeArg=post-update-sync\n";
|
|
|
+ exeAsync = "ExeAsync=false\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+- if (aExeRelPathPrefix && IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win" && aExeRelPathPrefix) {
|
|
|
+ aExeRelPathPrefix = aExeRelPathPrefix.replace("/", "\\");
|
|
|
+ }
|
|
|
+
|
|
|
+ let exeRelPathMac = "ExeRelPath=" + aExeRelPathPrefix + DIR_RESOURCES +
|
|
|
+ gPostUpdateBinFile + "\n";
|
|
|
+ let exeRelPathWin = "ExeRelPath=" + aExeRelPathPrefix + gPostUpdateBinFile + "\n";
|
|
|
+ let updaterIniContents = "[Strings]\n" +
|
|
|
+ "Title=Update Test\n" +
|
|
|
+@@ -2933,30 +2940,30 @@ function getMsgPath(aPath) {
|
|
|
+ * The update log file's contents.
|
|
|
+ * @return the log contents with the paths replaced.
|
|
|
+ */
|
|
|
+ function replaceLogPaths(aLogContents) {
|
|
|
+ let logContents = aLogContents;
|
|
|
+ // Remove the majority of the path up to the test directory. This is needed
|
|
|
+ // since Assert.equal won't print long strings to the test logs.
|
|
|
+ let testDirPath = do_get_file(gTestID, false).path;
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ // Replace \\ with \\\\ so the regexp works.
|
|
|
+ testDirPath = testDirPath.replace(/\\/g, "\\\\");
|
|
|
+ }
|
|
|
+ logContents = logContents.replace(new RegExp(testDirPath, "g"),
|
|
|
+ "<test_dir_path>/" + gTestID);
|
|
|
+ let updatesDirPath = getMockUpdRootD().path;
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ // Replace \\ with \\\\ so the regexp works.
|
|
|
+ updatesDirPath = updatesDirPath.replace(/\\/g, "\\\\");
|
|
|
+ }
|
|
|
+ logContents = logContents.replace(new RegExp(updatesDirPath, "g"),
|
|
|
+ "<update_dir_path>/" + gTestID);
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ // Replace \ with /
|
|
|
+ logContents = logContents.replace(/\\/g, "/");
|
|
|
+ }
|
|
|
+ return logContents;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Helper function for updater binary tests for verifying the contents of the
|
|
|
+@@ -2969,17 +2976,17 @@ function replaceLogPaths(aLogContents) {
|
|
|
+ * @param aReplace
|
|
|
+ * If the update log file is for a replace update.
|
|
|
+ * @param aExcludeDistDir
|
|
|
+ * Removes lines containing the distribution directory from the log
|
|
|
+ * file to compare the update log with.
|
|
|
+ */
|
|
|
+ function checkUpdateLogContents(aCompareLogFile, aStaged = false,
|
|
|
+ aReplace = false, aExcludeDistDir = false) {
|
|
|
+- if (IS_UNIX) {
|
|
|
++ if (AppConstants.platform == "macosx" || AppConstants.platform == "linux") {
|
|
|
+ // The order that files are returned when enumerating the file system on
|
|
|
+ // Linux and Mac is not deterministic so skip checking the logs.
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ let updateLog = getUpdateLog(FILE_LAST_UPDATE_LOG);
|
|
|
+ let updateLogContents = readFileBytes(updateLog);
|
|
|
+
|
|
|
+@@ -3001,17 +3008,17 @@ function checkUpdateLogContents(aCompare
|
|
|
+ // These could be changed to relative paths using <test_dir_path> and
|
|
|
+ // <update_dir_path>
|
|
|
+ updateLogContents = updateLogContents.replace(/PATCH DIRECTORY.*/g, "");
|
|
|
+ updateLogContents = updateLogContents.replace(/INSTALLATION DIRECTORY.*/g, "");
|
|
|
+ updateLogContents = updateLogContents.replace(/WORKING DIRECTORY.*/g, "");
|
|
|
+ // Skip lines that log failed attempts to open the callback executable.
|
|
|
+ updateLogContents = updateLogContents.replace(/NS_main: callback app file .*/g, "");
|
|
|
+
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ // The FindFile results when enumerating the filesystem on Windows is not
|
|
|
+ // determistic so the results matching the following need to be fixed.
|
|
|
+ let re = new RegExp("([^\n]* 7\/7text1[^\n]*)\n" +
|
|
|
+ "([^\n]* 7\/7text0[^\n]*)\n", "g");
|
|
|
+ updateLogContents = updateLogContents.replace(re, "$2\n$1\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (aReplace) {
|
|
|
+@@ -3133,17 +3140,17 @@ function checkFilesAfterUpdateSuccess(aG
|
|
|
+ let testFile = aGetFileFunc(aTestFile.relPathDir + aTestFile.fileName, true);
|
|
|
+ debugDump("testing file: " + testFile.path);
|
|
|
+ if (aTestFile.compareFile || aTestFile.compareContents) {
|
|
|
+ Assert.ok(testFile.exists(),
|
|
|
+ MSG_SHOULD_EXIST + getMsgPath(testFile.path));
|
|
|
+
|
|
|
+ // Skip these tests on Windows since chmod doesn't really set permissions
|
|
|
+ // on Windows.
|
|
|
+- if (!IS_WIN && aTestFile.comparePerms) {
|
|
|
++ if (AppConstants.platform != "win" && aTestFile.comparePerms) {
|
|
|
+ // Check if the permssions as set in the complete mar file are correct.
|
|
|
+ Assert.equal(testFile.permissions & 0xfff,
|
|
|
+ aTestFile.comparePerms & 0xfff,
|
|
|
+ "the file permissions" + MSG_SHOULD_EQUAL);
|
|
|
+ }
|
|
|
+
|
|
|
+ let fileContents1 = readFileBytes(testFile);
|
|
|
+ let fileContents2 = aTestFile.compareFile ?
|
|
|
+@@ -3232,17 +3239,17 @@ function checkFilesAfterUpdateFailure(aG
|
|
|
+ let testFile = aGetFileFunc(aTestFile.relPathDir + aTestFile.fileName, true);
|
|
|
+ debugDump("testing file: " + testFile.path);
|
|
|
+ if (aTestFile.compareFile || aTestFile.compareContents) {
|
|
|
+ Assert.ok(testFile.exists(),
|
|
|
+ MSG_SHOULD_EXIST + getMsgPath(testFile.path));
|
|
|
+
|
|
|
+ // Skip these tests on Windows since chmod doesn't really set permissions
|
|
|
+ // on Windows.
|
|
|
+- if (!IS_WIN && aTestFile.comparePerms) {
|
|
|
++ if (AppConstants.platform != "win" && aTestFile.comparePerms) {
|
|
|
+ // Check the original permssions are retained on the file.
|
|
|
+ Assert.equal(testFile.permissions & 0xfff,
|
|
|
+ aTestFile.comparePerms & 0xfff,
|
|
|
+ "the file permissions" + MSG_SHOULD_EQUAL);
|
|
|
+ }
|
|
|
+
|
|
|
+ let fileContents1 = readFileBytes(testFile);
|
|
|
+ let fileContents2 = aTestFile.compareFile ?
|
|
|
+@@ -3320,17 +3327,18 @@ function checkFilesAfterUpdateCommon(aGe
|
|
|
+ if (aStageDirExists) {
|
|
|
+ Assert.ok(stageDir.exists(),
|
|
|
+ MSG_SHOULD_EXIST + getMsgPath(stageDir.path));
|
|
|
+ } else {
|
|
|
+ Assert.ok(!stageDir.exists(),
|
|
|
+ MSG_SHOULD_NOT_EXIST + getMsgPath(stageDir.path));
|
|
|
+ }
|
|
|
+
|
|
|
+- let toBeDeletedDirExists = IS_WIN ? aToBeDeletedDirExists : false;
|
|
|
++ let toBeDeletedDirExists =
|
|
|
++ AppConstants.platform == "win" ? aToBeDeletedDirExists : false;
|
|
|
+ let toBeDeletedDir = getApplyDirFile(DIR_TOBEDELETED, true);
|
|
|
+ if (toBeDeletedDirExists) {
|
|
|
+ Assert.ok(toBeDeletedDir.exists(),
|
|
|
+ MSG_SHOULD_EXIST + getMsgPath(toBeDeletedDir.path));
|
|
|
+ } else {
|
|
|
+ Assert.ok(!toBeDeletedDir.exists(),
|
|
|
+ MSG_SHOULD_NOT_EXIST + getMsgPath(toBeDeletedDir.path));
|
|
|
+ }
|
|
|
+@@ -3426,17 +3434,17 @@ function getPostUpdateFile(aSuffix) {
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Checks the contents of the updater post update binary log. When completed
|
|
|
+ * checkPostUpdateAppLogFinished will be called.
|
|
|
+ */
|
|
|
+ function checkPostUpdateAppLog() {
|
|
|
+ // Only Mac OS X and Windows support post update.
|
|
|
+- if (IS_MACOSX || IS_WIN) {
|
|
|
++ if (AppConstants.platform == "macosx" || AppConstants.platform == "win") {
|
|
|
+ gTimeoutRuns++;
|
|
|
+ let postUpdateLog = getPostUpdateFile(".log");
|
|
|
+ if (!postUpdateLog.exists()) {
|
|
|
+ debugDump("postUpdateLog does not exist. Path: " + postUpdateLog.path);
|
|
|
+ if (gTimeoutRuns > MAX_TIMEOUT_RUNS) {
|
|
|
+ do_throw("Exceeded MAX_TIMEOUT_RUNS while waiting for the post update " +
|
|
|
+ "process to create the post update log. Path: " +
|
|
|
+ postUpdateLog.path);
|
|
|
+@@ -3471,19 +3479,20 @@ function checkPostUpdateAppLog() {
|
|
|
+ * a file and attempting to delete the original file. If the deletion is
|
|
|
+ * successful the copy of the original file is renamed to the original file's
|
|
|
+ * name and if the deletion is not successful the copy of the original file is
|
|
|
+ * deleted.
|
|
|
+ *
|
|
|
+ * @param aFile
|
|
|
+ * An nsIFile for the file to be checked if it is in use.
|
|
|
+ * @return true if the file can't be deleted and false otherwise.
|
|
|
++ * @throws If called from a platform other than Windows.
|
|
|
+ */
|
|
|
+ function isFileInUse(aFile) {
|
|
|
+- if (!IS_WIN) {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
+ do_throw("Windows only function called by a different platform!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!aFile.exists()) {
|
|
|
+ debugDump("file does not exist, path: " + aFile.path);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+@@ -3512,17 +3521,17 @@ function isFileInUse(aFile) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Waits until files that are in use that break tests are no longer in use and
|
|
|
+ * then calls doTestFinish to end the test.
|
|
|
+ */
|
|
|
+ function waitForFilesInUse() {
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ let fileNames = [FILE_APP_BIN, FILE_UPDATER_BIN,
|
|
|
+ FILE_MAINTENANCE_SERVICE_INSTALLER_BIN];
|
|
|
+ for (let i = 0; i < fileNames.length; ++i) {
|
|
|
+ let file = getApplyDirFile(fileNames[i], true);
|
|
|
+ if (isFileInUse(file)) {
|
|
|
+ do_timeout(FILE_IN_USE_TIMEOUT_MS, waitForFilesInUse);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+@@ -3580,17 +3589,16 @@ function checkFilesInDirRecursive(aDir,
|
|
|
+ /**
|
|
|
+ * Helper function to override the update prompt component to verify whether it
|
|
|
+ * is called or not.
|
|
|
+ *
|
|
|
+ * @param aCallback
|
|
|
+ * The callback to call if the update prompt component is called.
|
|
|
+ */
|
|
|
+ function overrideUpdatePrompt(aCallback) {
|
|
|
+- ChromeUtils.import("resource://testing-common/MockRegistrar.jsm");
|
|
|
+ MockRegistrar.register("@mozilla.org/updates/update-prompt;1", UpdatePrompt, [aCallback]);
|
|
|
+ }
|
|
|
+
|
|
|
+ function UpdatePrompt(aCallback) {
|
|
|
+ this._callback = aCallback;
|
|
|
+
|
|
|
+ let fns = ["checkForUpdates", "showUpdateAvailable", "showUpdateDownloaded",
|
|
|
+ "showUpdateError", "showUpdateHistory", "showUpdateInstalled"];
|
|
|
+@@ -3735,17 +3743,17 @@ function stop_httpserver(aCallback) {
|
|
|
+ * The version of the application
|
|
|
+ * @param aPlatformVersion
|
|
|
+ * The gecko version of the application
|
|
|
+ */
|
|
|
+ function createAppInfo(aID, aName, aVersion, aPlatformVersion) {
|
|
|
+ const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
|
|
|
+ const XULAPPINFO_CID = Components.ID("{c763b610-9d49-455a-bbd2-ede71682a1ac}");
|
|
|
+ let ifaces = [Ci.nsIXULAppInfo, Ci.nsIXULRuntime];
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ ifaces.push(Ci.nsIWinAppHelper);
|
|
|
+ }
|
|
|
+ const XULAppInfo = {
|
|
|
+ vendor: APP_INFO_VENDOR,
|
|
|
+ name: aName,
|
|
|
+ ID: aID,
|
|
|
+ version: aVersion,
|
|
|
+ appBuildID: "2007010101",
|
|
|
+@@ -3799,17 +3807,17 @@ function getProcessArgs(aExtraArgs) {
|
|
|
+ }
|
|
|
+
|
|
|
+ let appBinPath = getApplyDirFile(DIR_MACOS + FILE_APP_BIN, false).path;
|
|
|
+ if (/ /.test(appBinPath)) {
|
|
|
+ appBinPath = '"' + appBinPath + '"';
|
|
|
+ }
|
|
|
+
|
|
|
+ let args;
|
|
|
+- if (IS_UNIX) {
|
|
|
++ if (AppConstants.platform == "macosx" || AppConstants.platform == "linux") {
|
|
|
+ let launchScript = getLaunchScript();
|
|
|
+ // Precreate the script with executable permissions
|
|
|
+ launchScript.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_DIRECTORY);
|
|
|
+
|
|
|
+ let scriptContents = "#! /bin/sh\n";
|
|
|
+ scriptContents += appBinPath + " -no-remote -test-process-updates " +
|
|
|
+ aExtraArgs.join(" ") + " " + PIPE_TO_NULL;
|
|
|
+ writeFile(launchScript, scriptContents);
|
|
|
+@@ -3927,22 +3935,16 @@ function adjustGeneralPaths() {
|
|
|
+ kernel32.close();
|
|
|
+ gHandle = null;
|
|
|
+ debugDump("finish - closing handle");
|
|
|
+ } catch (e) {
|
|
|
+ debugDump("call to CloseHandle failed. Exception: " + e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+- // Call end_test first before the directory provider is unregistered
|
|
|
+- if (typeof end_test == typeof Function) {
|
|
|
+- debugDump("calling end_test");
|
|
|
+- end_test();
|
|
|
+- }
|
|
|
+-
|
|
|
+ ds.unregisterProvider(dirProvider);
|
|
|
+ cleanupTestCommon();
|
|
|
+
|
|
|
+ debugDump("finish - unregistering directory provider");
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+@@ -3990,17 +3992,17 @@ function runUpdateUsingApp(aExpectedStat
|
|
|
+ executeSoon(afterAppExits);
|
|
|
+ },
|
|
|
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
|
|
|
+ };
|
|
|
+
|
|
|
+ function afterAppExits() {
|
|
|
+ gTimeoutRuns++;
|
|
|
+
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ waitForApplicationStop(FILE_UPDATER_BIN);
|
|
|
+ }
|
|
|
+
|
|
|
+ let status;
|
|
|
+ try {
|
|
|
+ status = readStatusFile();
|
|
|
+ } catch (e) {
|
|
|
+ logTestInfo("error reading status file, exception: " + e);
|
|
|
+@@ -4187,17 +4189,17 @@ IncrementalDownload.prototype = {
|
|
|
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIIncrementalDownload])
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Sets the environment that will be used by the application process when it is
|
|
|
+ * launched.
|
|
|
+ */
|
|
|
+ function setEnvironment() {
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ // The tests use nsIProcess to launch the updater and it is simpler to just
|
|
|
+ // set an environment variable and have the test updater set the current
|
|
|
+ // working directory than it is to set the current working directory in the
|
|
|
+ // test itself.
|
|
|
+ gEnv.set("CURWORKDIRPATH", getApplyDirFile().path);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Prevent setting the environment more than once.
|
|
|
+@@ -4210,29 +4212,29 @@ function setEnvironment() {
|
|
|
+ // See bug 1279108.
|
|
|
+ if (gEnv.exists("ASAN_OPTIONS")) {
|
|
|
+ gASanOptions = gEnv.get("ASAN_OPTIONS");
|
|
|
+ gEnv.set("ASAN_OPTIONS", gASanOptions + ":detect_leaks=0");
|
|
|
+ } else {
|
|
|
+ gEnv.set("ASAN_OPTIONS", "detect_leaks=0");
|
|
|
+ }
|
|
|
+
|
|
|
+- if (IS_WIN && !gEnv.exists("XRE_NO_WINDOWS_CRASH_DIALOG")) {
|
|
|
++ if (AppConstants.platform == "win" && !gEnv.exists("XRE_NO_WINDOWS_CRASH_DIALOG")) {
|
|
|
+ gAddedEnvXRENoWindowsCrashDialog = true;
|
|
|
+ debugDump("setting the XRE_NO_WINDOWS_CRASH_DIALOG environment " +
|
|
|
+ "variable to 1... previously it didn't exist");
|
|
|
+ gEnv.set("XRE_NO_WINDOWS_CRASH_DIALOG", "1");
|
|
|
+ }
|
|
|
+
|
|
|
+- if (IS_UNIX) {
|
|
|
++ if (AppConstants.platform == "macosx" || AppConstants.platform == "linux") {
|
|
|
+ let appGreBinDir = gGREBinDirOrig.clone();
|
|
|
+ let envGreBinDir = Cc["@mozilla.org/file/local;1"].
|
|
|
+ createInstance(Ci.nsIFile);
|
|
|
+ let shouldSetEnv = true;
|
|
|
+- if (IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "macosx") {
|
|
|
+ if (gEnv.exists("DYLD_LIBRARY_PATH")) {
|
|
|
+ gEnvDyldLibraryPath = gEnv.get("DYLD_LIBRARY_PATH");
|
|
|
+ envGreBinDir.initWithPath(gEnvDyldLibraryPath);
|
|
|
+ if (envGreBinDir.path == appGreBinDir.path) {
|
|
|
+ gEnvDyldLibraryPath = null;
|
|
|
+ shouldSetEnv = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+@@ -4309,18 +4311,18 @@ function resetEnvironment() {
|
|
|
+ debugDump("setting the XPCOM_DEBUG_BREAK environment variable back to " +
|
|
|
+ gEnvXPCOMDebugBreak);
|
|
|
+ gEnv.set("XPCOM_DEBUG_BREAK", gEnvXPCOMDebugBreak);
|
|
|
+ } else if (gEnv.exists("XPCOM_DEBUG_BREAK")) {
|
|
|
+ debugDump("clearing the XPCOM_DEBUG_BREAK environment variable");
|
|
|
+ gEnv.set("XPCOM_DEBUG_BREAK", "");
|
|
|
+ }
|
|
|
+
|
|
|
+- if (IS_UNIX) {
|
|
|
+- if (IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "macosx" || AppConstants.platform == "linux") {
|
|
|
++ if (AppConstants.platform == "macosx") {
|
|
|
+ if (gEnvDyldLibraryPath) {
|
|
|
+ debugDump("setting DYLD_LIBRARY_PATH environment variable value " +
|
|
|
+ "back to " + gEnvDyldLibraryPath);
|
|
|
+ gEnv.set("DYLD_LIBRARY_PATH", gEnvDyldLibraryPath);
|
|
|
+ } else if (gEnvDyldLibraryPath !== null) {
|
|
|
+ debugDump("removing DYLD_LIBRARY_PATH environment variable");
|
|
|
+ gEnv.set("DYLD_LIBRARY_PATH", "");
|
|
|
+ }
|
|
|
+@@ -4329,17 +4331,17 @@ function resetEnvironment() {
|
|
|
+ "to " + gEnvLdLibraryPath);
|
|
|
+ gEnv.set("LD_LIBRARY_PATH", gEnvLdLibraryPath);
|
|
|
+ } else if (gEnvLdLibraryPath !== null) {
|
|
|
+ debugDump("removing LD_LIBRARY_PATH environment variable");
|
|
|
+ gEnv.set("LD_LIBRARY_PATH", "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+- if (IS_WIN && gAddedEnvXRENoWindowsCrashDialog) {
|
|
|
++ if (AppConstants.platform == "win" && gAddedEnvXRENoWindowsCrashDialog) {
|
|
|
+ debugDump("removing the XRE_NO_WINDOWS_CRASH_DIALOG environment " +
|
|
|
+ "variable");
|
|
|
+ gEnv.set("XRE_NO_WINDOWS_CRASH_DIALOG", "");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (IS_SERVICE_TEST) {
|
|
|
+ debugDump("removing MOZ_NO_SERVICE_FALLBACK environment variable");
|
|
|
+ gEnv.set("MOZ_NO_SERVICE_FALLBACK", "");
|
|
|
+diff --git a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js.1525858.later b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js.1525858.later
|
|
|
+new file mode 100644
|
|
|
+--- /dev/null
|
|
|
++++ b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js.1525858.later
|
|
|
+@@ -0,0 +1,58 @@
|
|
|
++--- xpcshellUtilsAUS.js
|
|
|
+++++ xpcshellUtilsAUS.js
|
|
|
++@@ -1511,35 +1503,35 @@ XPCOMUtils.defineLazyGetter(this, "gInst
|
|
|
++ ", Exception " + e);
|
|
|
++ do_throw("Unable to write HKLM or HKCU TaskBarIDs registry key, key path: "
|
|
|
++ + REG_PATH);
|
|
|
++ }
|
|
|
++ return null;
|
|
|
++ });
|
|
|
++
|
|
|
++ XPCOMUtils.defineLazyGetter(this, "gLocalAppDataDir", function test_gLADD() {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
++ do_throw("Windows only function called by a different platform!");
|
|
|
++ }
|
|
|
++
|
|
|
++ const CSIDL_LOCAL_APPDATA = 0x1c;
|
|
|
++ return getSpecialFolderDir(CSIDL_LOCAL_APPDATA);
|
|
|
++ });
|
|
|
++
|
|
|
++ XPCOMUtils.defineLazyGetter(this, "gCommonAppDataDir", function test_gCDD() {
|
|
|
++- if (!IS_WIN) {
|
|
|
+++ if (AppConstants.platform != "win") {
|
|
|
++ do_throw("Windows only function called by a different platform!");
|
|
|
++ }
|
|
|
++
|
|
|
++ const CSIDL_COMMON_APPDATA = 0x0023;
|
|
|
++ return getSpecialFolderDir(CSIDL_COMMON_APPDATA);
|
|
|
++ });
|
|
|
++
|
|
|
++ XPCOMUtils.defineLazyGetter(this, "gProgFilesDir", function test_gPFD() {
|
|
|
++ if (AppConstants.platform != "win") {
|
|
|
++ do_throw("Windows only function called by a different platform!");
|
|
|
++ }
|
|
|
++
|
|
|
++ const CSIDL_PROGRAM_FILES = 0x26;
|
|
|
++ return getSpecialFolderDir(CSIDL_PROGRAM_FILES);
|
|
|
++ });
|
|
|
++
|
|
|
++ /**
|
|
|
++@@ -1593,17 +1587,17 @@ function getMockUpdRootDWin(aGetOldLocat
|
|
|
++ let updatesDir = Cc["@mozilla.org/file/local;1"].
|
|
|
++ createInstance(Ci.nsIFile);
|
|
|
++ updatesDir.initWithPath(dataDirectory.path + "\\" + relPathUpdates);
|
|
|
++ return updatesDir;
|
|
|
++ }
|
|
|
++
|
|
|
++ function createWorldWritableAppUpdateDir() {
|
|
|
++ // This function is only necessary in Windows
|
|
|
++- if (IS_WIN) {
|
|
|
+++ if (AppConstants.platform == "win") {
|
|
|
++ let installDir = Services.dirsvc.get(XRE_EXECUTABLE_FILE, Ci.nsIFile).parent;
|
|
|
++ let exitValue = runTestHelperSync(["create-update-dir", installDir.path]);
|
|
|
++ Assert.equal(exitValue, 0, "The helper process exit value should be 0");
|
|
|
++ }
|
|
|
++ }
|
|
|
++
|
|
|
++ XPCOMUtils.defineLazyGetter(this, "gUpdatesRootDir", function test_gURD() {
|
|
|
++ if (AppConstants.platform != "macosx") {
|
|
|
+diff --git a/toolkit/mozapps/update/tests/moz.build b/toolkit/mozapps/update/tests/moz.build
|
|
|
+--- a/toolkit/mozapps/update/tests/moz.build
|
|
|
++++ b/toolkit/mozapps/update/tests/moz.build
|
|
|
+@@ -35,18 +35,17 @@ if CONFIG['OS_ARCH'] == 'WINNT':
|
|
|
+ OS_LIBS += [
|
|
|
+ 'shlwapi',
|
|
|
+ ]
|
|
|
+
|
|
|
+ USE_LIBS += [
|
|
|
+ 'updatecommon',
|
|
|
+ ]
|
|
|
+
|
|
|
+-for var in ('MOZ_APP_NAME', 'MOZ_APP_BASENAME', 'MOZ_APP_DISPLAYNAME',
|
|
|
+- 'MOZ_APP_VENDOR', 'BIN_SUFFIX', 'MOZ_DEBUG'):
|
|
|
++for var in ('MOZ_APP_VENDOR', 'MOZ_APP_BASENAME'):
|
|
|
+ DEFINES[var] = CONFIG[var]
|
|
|
+
|
|
|
+ DEFINES['NS_NO_XPCOM'] = True
|
|
|
+
|
|
|
+ DisableStlWrapping()
|
|
|
+
|
|
|
+ if CONFIG['MOZ_MAINTENANCE_SERVICE']:
|
|
|
+ DEFINES['MOZ_MAINTENANCE_SERVICE'] = CONFIG['MOZ_MAINTENANCE_SERVICE']
|
|
|
+diff --git a/toolkit/mozapps/update/tests/unit_aus_update/ausReadStrings.js b/toolkit/mozapps/update/tests/unit_aus_update/ausReadStrings.js
|
|
|
+--- a/toolkit/mozapps/update/tests/unit_aus_update/ausReadStrings.js
|
|
|
++++ b/toolkit/mozapps/update/tests/unit_aus_update/ausReadStrings.js
|
|
|
+@@ -1,14 +1,14 @@
|
|
|
+ /* Any copyright is dedicated to the Public Domain.
|
|
|
+ * http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
+ */
|
|
|
+
|
|
|
+-const BIN_DIR = (IS_WIN ? "test_bug473417-ó" : "test_bug473417");
|
|
|
+-const BIN_EXE = "TestAUSReadStrings" + BIN_SUFFIX;
|
|
|
++const BIN_DIR = (AppConstants.platform == "win" ? "test_bug473417-ó" : "test_bug473417");
|
|
|
++const BIN_EXE = "TestAUSReadStrings" + mozinfo.bin_suffix;
|
|
|
+ const tempdir = do_get_tempdir();
|
|
|
+
|
|
|
+ function run_test() {
|
|
|
+ let workdir = tempdir.clone();
|
|
|
+ workdir.append(BIN_DIR);
|
|
|
+
|
|
|
+ let paths = [
|
|
|
+ BIN_EXE,
|
|
|
+diff --git a/toolkit/mozapps/update/tests/unit_aus_update/canCheckForAndCanApplyUpdates.js b/toolkit/mozapps/update/tests/unit_aus_update/canCheckForAndCanApplyUpdates.js
|
|
|
+--- a/toolkit/mozapps/update/tests/unit_aus_update/canCheckForAndCanApplyUpdates.js
|
|
|
++++ b/toolkit/mozapps/update/tests/unit_aus_update/canCheckForAndCanApplyUpdates.js
|
|
|
+@@ -10,17 +10,17 @@ function run_test() {
|
|
|
+ debugDump("testing write access to the application directory");
|
|
|
+ let testFile = getCurrentProcessDir();
|
|
|
+ testFile.append("update_write_access_test");
|
|
|
+ testFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
|
|
|
+ Assert.ok(testFile.exists(), MSG_SHOULD_EXIST);
|
|
|
+ testFile.remove(false);
|
|
|
+ Assert.ok(!testFile.exists(), MSG_SHOULD_NOT_EXIST);
|
|
|
+
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ // Create a mutex to prevent being able to check for or apply updates.
|
|
|
+ debugDump("attempting to create mutex");
|
|
|
+ let handle = createMutex(getPerInstallationMutexName());
|
|
|
+ Assert.ok(!!handle, "the update mutex should have been created");
|
|
|
+
|
|
|
+ // Check if available updates cannot be checked for when there is a mutex
|
|
|
+ // for this installation.
|
|
|
+ Assert.ok(!gAUS.canCheckForUpdates, "should not be able to check for " +
|
|
|
+@@ -35,17 +35,17 @@ function run_test() {
|
|
|
+ closeHandle(handle);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Check if available updates can be checked for
|
|
|
+ Assert.ok(gAUS.canCheckForUpdates, "should be able to check for updates");
|
|
|
+ // Check if updates can be applied
|
|
|
+ Assert.ok(gAUS.canApplyUpdates, "should be able to apply updates");
|
|
|
+
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ // Attempt to create a mutex when application update has already created one
|
|
|
+ // with the same name.
|
|
|
+ debugDump("attempting to create mutex");
|
|
|
+ let handle = createMutex(getPerInstallationMutexName());
|
|
|
+
|
|
|
+ Assert.ok(!handle, "should not be able to create the update mutex when " +
|
|
|
+ "the application has created the update mutex");
|
|
|
+ }
|
|
|
+diff --git a/toolkit/mozapps/update/tests/unit_base_updater/head_update.js.1525858.later b/toolkit/mozapps/update/tests/unit_base_updater/head_update.js.1525858.later
|
|
|
+new file mode 100644
|
|
|
+--- /dev/null
|
|
|
++++ b/toolkit/mozapps/update/tests/unit_base_updater/head_update.js.1525858.later
|
|
|
+@@ -0,0 +1,15 @@
|
|
|
++--- head_update.js
|
|
|
+++++ head_update.js
|
|
|
++@@ -1,12 +1,8 @@
|
|
|
++ /* Any copyright is dedicated to the Public Domain.
|
|
|
++ * http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
++ */
|
|
|
++
|
|
|
++ const IS_SERVICE_TEST = false;
|
|
|
++
|
|
|
++ /* import-globals-from ../data/xpcshellUtilsAUS.js */
|
|
|
++ load("xpcshellUtilsAUS.js");
|
|
|
++-
|
|
|
++-XPCOMUtils.defineLazyModuleGetters(this, {
|
|
|
++- AppConstants: "resource://gre/modules/AppConstants.jsm",
|
|
|
++-});
|
|
|
+diff --git a/toolkit/mozapps/update/tests/unit_base_updater/invalidArgCallbackFilePathTooLongFailure.js b/toolkit/mozapps/update/tests/unit_base_updater/invalidArgCallbackFilePathTooLongFailure.js
|
|
|
+--- a/toolkit/mozapps/update/tests/unit_base_updater/invalidArgCallbackFilePathTooLongFailure.js
|
|
|
++++ b/toolkit/mozapps/update/tests/unit_base_updater/invalidArgCallbackFilePathTooLongFailure.js
|
|
|
+@@ -17,17 +17,17 @@ function run_test() {
|
|
|
+ setupUpdaterTest(FILE_COMPLETE_MAR, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Called after the call to setupUpdaterTest finishes.
|
|
|
+ */
|
|
|
+ function setupUpdaterTestFinished() {
|
|
|
+ let path = "123456789";
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ path = "\\" + path;
|
|
|
+ path = path.repeat(30); // 300 characters
|
|
|
+ path = "C:" + path;
|
|
|
+ } else {
|
|
|
+ path = "/" + path;
|
|
|
+ path = path.repeat(1000); // 10000 characters
|
|
|
+ }
|
|
|
+
|
|
|
+diff --git a/toolkit/mozapps/update/tests/unit_base_updater/invalidArgInstallDirPathTooLongFailure.js b/toolkit/mozapps/update/tests/unit_base_updater/invalidArgInstallDirPathTooLongFailure.js
|
|
|
+--- a/toolkit/mozapps/update/tests/unit_base_updater/invalidArgInstallDirPathTooLongFailure.js
|
|
|
++++ b/toolkit/mozapps/update/tests/unit_base_updater/invalidArgInstallDirPathTooLongFailure.js
|
|
|
+@@ -19,17 +19,17 @@ function run_test() {
|
|
|
+ setupUpdaterTest(FILE_COMPLETE_MAR, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Called after the call to setupUpdaterTest finishes.
|
|
|
+ */
|
|
|
+ function setupUpdaterTestFinished() {
|
|
|
+ let path = "123456789";
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ path = "\\" + path;
|
|
|
+ path = path.repeat(30); // 300 characters
|
|
|
+ path = "C:" + path;
|
|
|
+ } else {
|
|
|
+ path = "/" + path;
|
|
|
+ path = path.repeat(1000); // 10000 characters
|
|
|
+ }
|
|
|
+
|
|
|
+diff --git a/toolkit/mozapps/update/tests/unit_base_updater/invalidArgInstallDirPathTraversalFailure.js b/toolkit/mozapps/update/tests/unit_base_updater/invalidArgInstallDirPathTraversalFailure.js
|
|
|
+--- a/toolkit/mozapps/update/tests/unit_base_updater/invalidArgInstallDirPathTraversalFailure.js
|
|
|
++++ b/toolkit/mozapps/update/tests/unit_base_updater/invalidArgInstallDirPathTraversalFailure.js
|
|
|
+@@ -19,17 +19,17 @@ function run_test() {
|
|
|
+ setupUpdaterTest(FILE_COMPLETE_MAR, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Called after the call to setupUpdaterTest finishes.
|
|
|
+ */
|
|
|
+ function setupUpdaterTestFinished() {
|
|
|
+ let path = "123456789";
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ path = "C:\\" + path + "\\..\\" + path;
|
|
|
+ } else {
|
|
|
+ path = "/" + path + "/../" + path;
|
|
|
+ }
|
|
|
+
|
|
|
+ runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+diff --git a/toolkit/mozapps/update/tests/unit_base_updater/invalidArgPatchDirPathTraversalFailure.js b/toolkit/mozapps/update/tests/unit_base_updater/invalidArgPatchDirPathTraversalFailure.js
|
|
|
+--- a/toolkit/mozapps/update/tests/unit_base_updater/invalidArgPatchDirPathTraversalFailure.js
|
|
|
++++ b/toolkit/mozapps/update/tests/unit_base_updater/invalidArgPatchDirPathTraversalFailure.js
|
|
|
+@@ -18,17 +18,17 @@ function run_test() {
|
|
|
+ setupUpdaterTest(FILE_COMPLETE_MAR, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Called after the call to setupUpdaterTest finishes.
|
|
|
+ */
|
|
|
+ function setupUpdaterTestFinished() {
|
|
|
+ let path = getUpdatesPatchDir();
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ path = path + "\\..\\";
|
|
|
+ } else {
|
|
|
+ path = path + "/../";
|
|
|
+ }
|
|
|
+
|
|
|
+ runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, path, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js
|
|
|
+--- a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js
|
|
|
++++ b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js
|
|
|
+@@ -79,17 +79,17 @@ function waitForUpdateXMLFilesFinished()
|
|
|
+ checkUpdateManager(STATE_NONE, false, STATE_SUCCEEDED, 0, 1);
|
|
|
+ checkCallbackLog();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Setup symlinks for the test.
|
|
|
+ */
|
|
|
+ function setupSymLinks() {
|
|
|
+- if (IS_UNIX) {
|
|
|
++ if (AppConstants.platform == "macosx" || AppConstants.platform == "linux") {
|
|
|
+ removeSymlink();
|
|
|
+ createSymlink();
|
|
|
+ registerCleanupFunction(removeSymlink);
|
|
|
+ gTestFiles.splice(gTestFiles.length - 3, 0,
|
|
|
+ {
|
|
|
+ description: "Readable symlink",
|
|
|
+ fileName: "link",
|
|
|
+ relPathDir: DIR_RESOURCES,
|
|
|
+@@ -102,12 +102,12 @@ function setupSymLinks() {
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Checks the state of the symlinks for the test.
|
|
|
+ */
|
|
|
+ function checkSymLinks() {
|
|
|
+- if (IS_UNIX) {
|
|
|
++ if (AppConstants.platform == "macosx" || AppConstants.platform == "linux") {
|
|
|
+ checkSymlink();
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js
|
|
|
+--- a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js
|
|
|
++++ b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js
|
|
|
+@@ -67,17 +67,17 @@ function waitForUpdateXMLFilesFinished()
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Setup symlinks for the test.
|
|
|
+ */
|
|
|
+ function setupSymLinks() {
|
|
|
+ // Don't test symlinks on Mac OS X in this test since it tends to timeout.
|
|
|
+ // It is tested on Mac OS X in marAppInUseStageSuccessComplete_unix.js
|
|
|
+- if (IS_UNIX && !IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "linux") {
|
|
|
+ removeSymlink();
|
|
|
+ createSymlink();
|
|
|
+ registerCleanupFunction(removeSymlink);
|
|
|
+ gTestFiles.splice(gTestFiles.length - 3, 0,
|
|
|
+ {
|
|
|
+ description: "Readable symlink",
|
|
|
+ fileName: "link",
|
|
|
+ relPathDir: DIR_RESOURCES,
|
|
|
+@@ -92,12 +92,12 @@ function setupSymLinks() {
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Checks the state of the symlinks for the test.
|
|
|
+ */
|
|
|
+ function checkSymLinks() {
|
|
|
+ // Don't test symlinks on Mac OS X in this test since it tends to timeout.
|
|
|
+ // It is tested on Mac OS X in marAppInUseStageSuccessComplete_unix.js
|
|
|
+- if (IS_UNIX && !IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "linux") {
|
|
|
+ checkSymlink();
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/toolkit/mozapps/update/tests/unit_service_updater/head_update.js.1525858.later b/toolkit/mozapps/update/tests/unit_service_updater/head_update.js.1525858.later
|
|
|
+new file mode 100644
|
|
|
+--- /dev/null
|
|
|
++++ b/toolkit/mozapps/update/tests/unit_service_updater/head_update.js.1525858.later
|
|
|
+@@ -0,0 +1,15 @@
|
|
|
++--- head_update.js
|
|
|
+++++ head_update.js
|
|
|
++@@ -1,12 +1,8 @@
|
|
|
++ /* Any copyright is dedicated to the Public Domain.
|
|
|
++ * http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
++ */
|
|
|
++
|
|
|
++ const IS_SERVICE_TEST = true;
|
|
|
++
|
|
|
++ /* import-globals-from ../data/xpcshellUtilsAUS.js */
|
|
|
++ load("xpcshellUtilsAUS.js");
|
|
|
++-
|
|
|
++-XPCOMUtils.defineLazyModuleGetters(this, {
|
|
|
++- AppConstants: "resource://gre/modules/AppConstants.jsm",
|
|
|
++-});
|
|
|
+diff --git a/toolkit/mozapps/update/tests/unit_service_updater/invalidArgInstallDirPathTooLongFailureSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/invalidArgInstallDirPathTooLongFailureSvc.js
|
|
|
+--- a/toolkit/mozapps/update/tests/unit_service_updater/invalidArgInstallDirPathTooLongFailureSvc.js
|
|
|
++++ b/toolkit/mozapps/update/tests/unit_service_updater/invalidArgInstallDirPathTooLongFailureSvc.js
|
|
|
+@@ -19,17 +19,17 @@ function run_test() {
|
|
|
+ setupUpdaterTest(FILE_COMPLETE_MAR, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Called after the call to setupUpdaterTest finishes.
|
|
|
+ */
|
|
|
+ function setupUpdaterTestFinished() {
|
|
|
+ let path = "123456789";
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ path = "\\" + path;
|
|
|
+ path = path.repeat(30); // 300 characters
|
|
|
+ path = "C:" + path;
|
|
|
+ } else {
|
|
|
+ path = "/" + path;
|
|
|
+ path = path.repeat(1000); // 10000 characters
|
|
|
+ }
|
|
|
+
|
|
|
+diff --git a/toolkit/mozapps/update/tests/unit_service_updater/invalidArgInstallDirPathTraversalFailureSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/invalidArgInstallDirPathTraversalFailureSvc.js
|
|
|
+--- a/toolkit/mozapps/update/tests/unit_service_updater/invalidArgInstallDirPathTraversalFailureSvc.js
|
|
|
++++ b/toolkit/mozapps/update/tests/unit_service_updater/invalidArgInstallDirPathTraversalFailureSvc.js
|
|
|
+@@ -19,17 +19,17 @@ function run_test() {
|
|
|
+ setupUpdaterTest(FILE_COMPLETE_MAR, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Called after the call to setupUpdaterTest finishes.
|
|
|
+ */
|
|
|
+ function setupUpdaterTestFinished() {
|
|
|
+ let path = "123456789";
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ path = "C:\\" + path + "\\..\\" + path;
|
|
|
+ } else {
|
|
|
+ path = "/" + path + "/../" + path;
|
|
|
+ }
|
|
|
+
|
|
|
+ runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, null, path, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+diff --git a/toolkit/mozapps/update/tests/unit_service_updater/invalidArgPatchDirPathTraversalFailureSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/invalidArgPatchDirPathTraversalFailureSvc.js
|
|
|
+--- a/toolkit/mozapps/update/tests/unit_service_updater/invalidArgPatchDirPathTraversalFailureSvc.js
|
|
|
++++ b/toolkit/mozapps/update/tests/unit_service_updater/invalidArgPatchDirPathTraversalFailureSvc.js
|
|
|
+@@ -18,17 +18,17 @@ function run_test() {
|
|
|
+ setupUpdaterTest(FILE_COMPLETE_MAR, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Called after the call to setupUpdaterTest finishes.
|
|
|
+ */
|
|
|
+ function setupUpdaterTestFinished() {
|
|
|
+ let path = getUpdatesPatchDir();
|
|
|
+- if (IS_WIN) {
|
|
|
++ if (AppConstants.platform == "win") {
|
|
|
+ path = path + "\\..\\";
|
|
|
+ } else {
|
|
|
+ path = path + "/../";
|
|
|
+ }
|
|
|
+
|
|
|
+ runUpdate(STATE_AFTER_RUNUPDATE, false, 1, true, path, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js
|
|
|
+--- a/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js
|
|
|
++++ b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js
|
|
|
+@@ -67,17 +67,17 @@ function waitForUpdateXMLFilesFinished()
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Setup symlinks for the test.
|
|
|
+ */
|
|
|
+ function setupSymLinks() {
|
|
|
+ // Don't test symlinks on Mac OS X in this test since it tends to timeout.
|
|
|
+ // It is tested on Mac OS X in marAppInUseStageSuccessComplete_unix.js
|
|
|
+- if (IS_UNIX && !IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "linux") {
|
|
|
+ removeSymlink();
|
|
|
+ createSymlink();
|
|
|
+ registerCleanupFunction(removeSymlink);
|
|
|
+ gTestFiles.splice(gTestFiles.length - 3, 0,
|
|
|
+ {
|
|
|
+ description: "Readable symlink",
|
|
|
+ fileName: "link",
|
|
|
+ relPathDir: DIR_RESOURCES,
|
|
|
+@@ -92,12 +92,12 @@ function setupSymLinks() {
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Checks the state of the symlinks for the test.
|
|
|
+ */
|
|
|
+ function checkSymLinks() {
|
|
|
+ // Don't test symlinks on Mac OS X in this test since it tends to timeout.
|
|
|
+ // It is tested on Mac OS X in marAppInUseStageSuccessComplete_unix.js
|
|
|
+- if (IS_UNIX && !IS_MACOSX) {
|
|
|
++ if (AppConstants.platform == "linux") {
|
|
|
+ checkSymlink();
|
|
|
+ }
|
|
|
+ }
|