Bug 708690 - XPCShell test enhancements for product information blocks. r=rstrong
authorBrian R. Bondy <netzen@gmail.com>
Fri, 24 Feb 2012 16:29:42 -0500
changeset 90515 df3801e30225ee4a533d9b0c8b56eeb95ebd3671
parent 90514 ad8fe9d36d16474b7543335557c6c6e63df50674
child 90516 52bd72d77fda6827b8b5470149abd1f80801e731
push id783
push userlsblakk@mozilla.com
push dateTue, 24 Apr 2012 17:33:42 +0000
treeherdermozilla-beta@11faed19f136 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs708690
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 708690 - XPCShell test enhancements for product information blocks. r=rstrong
toolkit/mozapps/update/common/updatehelper.cpp
toolkit/mozapps/update/common/updatehelper.h
toolkit/mozapps/update/test/chrome/Makefile.in
toolkit/mozapps/update/test/sharedUpdateXML.js
toolkit/mozapps/update/test/unit/head_update.js.in
toolkit/mozapps/update/test/unit/test_0200_app_launch_apply_update.js
toolkit/mozapps/update/updater/archivereader.cpp
toolkit/mozapps/update/updater/resource.h
toolkit/mozapps/update/updater/updater.cpp
toolkit/mozapps/update/updater/updater.rc
toolkit/mozapps/update/updater/xpcshellCertificate.der
--- a/toolkit/mozapps/update/common/updatehelper.cpp
+++ b/toolkit/mozapps/update/common/updatehelper.cpp
@@ -34,16 +34,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include <windows.h>
 #include <stdio.h>
 #include "shlobj.h"
 #include "updatehelper.h"
+#include "pathhash.h"
 
 // Needed for PathAppendW
 #include <shlwapi.h>
 // Needed for CreateToolhelp32Snapshot
 #include <tlhelp32.h>
 #pragma comment(lib, "shlwapi.lib") 
 
 WCHAR* MakeCommandLine(int argc, WCHAR **argv);
@@ -332,17 +333,17 @@ StartServiceCommand(int argc, LPCWSTR* a
  *
  * @param  exePath The path of the executable to run
  * @param  argc    The total number of arguments in argv
  * @param  argv    An array of null terminated strings to pass to the exePath, 
  *                 argv[0] must be the path to the updater.exe
  * @return ERROR_SUCCESS if successful
  */
 DWORD
-LaunchServiceSoftwareUpdateCommand(DWORD argc, LPCWSTR* argv)
+LaunchServiceSoftwareUpdateCommand(int argc, LPCWSTR* argv)
 {
   // The service command is the same as the updater.exe command line except 
   // it has 2 extra args: 1) The Path to udpater.exe, and 2) the command 
   // being executed which is "software-update"
   LPCWSTR *updaterServiceArgv = new LPCWSTR[argc + 2];
   updaterServiceArgv[0] = L"MozillaMaintenance";
   updaterServiceArgv[1] = L"software-update";
 
@@ -626,8 +627,28 @@ WaitForProcessExit(LPCWSTR filename, DWO
   }
 
   if (ERROR_SUCCESS == applicationRunningError) {
     return WAIT_TIMEOUT;
   }
 
   return applicationRunningError;
 }
+
+/**
+ *  Determines if the fallback key exists or not
+ *
+ *  @return TRUE if the fallback key exists and there was no error checking
+*/
+BOOL
+DoesFallbackKeyExist()
+{
+  HKEY testOnlyFallbackKey;
+  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, 
+                    TEST_ONLY_FALLBACK_KEY_PATH, 0,
+                    KEY_READ | KEY_WOW64_64KEY, 
+                    &testOnlyFallbackKey) != ERROR_SUCCESS) {
+    return FALSE;
+  }
+
+  RegCloseKey(testOnlyFallbackKey);
+  return TRUE;
+}
--- a/toolkit/mozapps/update/common/updatehelper.h
+++ b/toolkit/mozapps/update/common/updatehelper.h
@@ -36,15 +36,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 BOOL LaunchWinPostProcess(const WCHAR *installationDir,
                           const WCHAR *updateInfoDir, 
                           bool forceSync,
                           HANDLE userToken);
 BOOL StartServiceUpdate(int argc, LPWSTR *argv);
 BOOL GetUpdateDirectoryPath(LPWSTR path);
-DWORD LaunchServiceSoftwareUpdateCommand(DWORD argc, LPCWSTR *argv);
+DWORD LaunchServiceSoftwareUpdateCommand(int argc, LPCWSTR *argv);
 BOOL WriteStatusFailure(LPCWSTR updateDirPath, int errorCode);
 BOOL WriteStatusPending(LPCWSTR updateDirPath);
 DWORD WaitForServiceStop(LPCWSTR serviceName, DWORD maxWaitSeconds);
 DWORD WaitForProcessExit(LPCWSTR filename, DWORD maxSeconds);
+BOOL DoesFallbackKeyExist();
 
 #define SVC_NAME L"MozillaMaintenance"
--- a/toolkit/mozapps/update/test/chrome/Makefile.in
+++ b/toolkit/mozapps/update/test/chrome/Makefile.in
@@ -39,17 +39,17 @@ DEPTH     = ../../../../..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 relativesrcdir = toolkit/mozapps/update/test/chrome
 
 include $(DEPTH)/config/autoconf.mk
 
 _OTHER_FILES = \
-  ../unit/data/simple.mar \
+  ../unit/data/simple_no_pib.mar \
   $(NULL)
 
 _CHROME_FILES = \
   test_0011_check_basic.xul \
   test_0012_check_basic_license.xul \
   test_0013_check_incompat_basic.xul \
   test_0015_check_incompat_basic_addons.xul \
   test_0014_check_incompat_basic_license.xul \
--- a/toolkit/mozapps/update/test/sharedUpdateXML.js
+++ b/toolkit/mozapps/update/test/sharedUpdateXML.js
@@ -6,17 +6,17 @@
  * Helper functions for creating xml strings used by application update tests.
  *
  * !IMPORTANT - This file contains everything needed (along with dependencies)
  * by the updates.sjs file used by the mochitest-chrome tests. Since xpcshell
  * used by the http server is launched with -v 170 this file must not use
  * features greater than JavaScript 1.7.
  */
 
-const FILE_SIMPLE_MAR = "simple.mar";
+const FILE_SIMPLE_MAR = "simple_no_pib.mar";
 
 const SIZE_SIMPLE_MAR = "351";
 
 const MD5_HASH_SIMPLE_MAR    = "d0a7f84dacc55a252ab916668a7cb216";
 const SHA1_HASH_SIMPLE_MAR   = "f5053f9552d087c6c6ed83f9b19405eccf1436fc";
 const SHA256_HASH_SIMPLE_MAR = "663c7cbd11fe45b0a71438387db924d205997ab85ccf5" +
                                "b40aebbdaef179796ab";
 const SHA384_HASH_SIMPLE_MAR = "a57250554755a9f42b91932993599bb6b05e063dcbd71" +
--- a/toolkit/mozapps/update/test/unit/head_update.js.in
+++ b/toolkit/mozapps/update/test/unit/head_update.js.in
@@ -85,16 +85,18 @@ const URL_PATH = "data";
 
 const APPLY_TO_DIR_SUFFIX = "_applyToDir/";
 const HELPER_BIN_FILE = "TestAUSHelper" + BIN_SUFFIX;
 const MAR_COMPLETE_FILE = "data/complete.mar";
 const MAR_PARTIAL_FILE = "data/partial.mar";
 const UPDATER_BIN_FILE = "updater" + BIN_SUFFIX;
 const MAINTENANCE_SERVICE_BIN_FILE = "maintenanceservice.exe";
 const MAINTENANCE_SERVICE_INSTALLER_BIN_FILE = "maintenanceservice_installer.exe";
+const UPDATE_SETTINGS_INI_FILE = "update-settings.ini";
+const UPDATE_SETTINGS_CONTENTS = "[Settings]\nMAR_CHANNEL_ID=xpcshell-test\n"
 const UPDATES_DIR_SUFFIX = "_mar";
 
 const LOG_COMPLETE_SUCCESS = "data/complete_log_success";
 const LOG_COMPLETE_CC_SUCCESS = "data/complete_cc_log_success";
 
 const LOG_PARTIAL_SUCCESS = "data/partial_log_success";
 const LOG_PARTIAL_FAILURE = "data/partial_log_failure";
 
@@ -438,16 +440,20 @@ function runUpdate() {
   let cwdPath = callbackApp.parent.path;
   if (/ /.test(cwdPath))
     cwdPath = '"' + cwdPath + '"';
 
   let callbackAppPath = callbackApp.path;
   if (/ /.test(callbackAppPath))
     callbackAppPath = '"' + callbackAppPath + '"';
 
+  let updateSettingsIni = getApplyDirFile(null, true);
+  updateSettingsIni.append(UPDATE_SETTINGS_INI_FILE);
+  writeFile(updateSettingsIni, UPDATE_SETTINGS_CONTENTS);
+
   let args = [updatesDirPath, applyToDirPath, 0, cwdPath, callbackAppPath].
              concat(gCallbackArgs);
   let process = AUS_Cc["@mozilla.org/process/util;1"].
                 createInstance(AUS_Ci.nsIProcess);
   process.init(updateBin);
   process.run(true, args, args.length);
   return process.exitValue;
 }
@@ -744,16 +750,20 @@ function runUpdateUsingService(aInitialS
 
   // The service will execute maintenanceservice_installer.exe and
   // will copy maintenanceservice.exe out of the same directory from
   // the installation directory.  So we need to make sure both of those
   // bins always exist in the installation directory.
   copyBinToApplyToDir(MAINTENANCE_SERVICE_BIN_FILE);
   copyBinToApplyToDir(MAINTENANCE_SERVICE_INSTALLER_BIN_FILE);
 
+  let updateSettingsIni = getApplyDirFile(null, true);
+  updateSettingsIni.append(UPDATE_SETTINGS_INI_FILE);
+  writeFile(updateSettingsIni, UPDATE_SETTINGS_CONTENTS);
+
   // Firefox does not wait for the service command to finish, but
   // we still launch the process sync to avoid intermittent failures with
   // the log file not being written out yet.
   // We will rely on watching the update.status file and waiting for the service
   // to stop to know the service command is done.
   process.run(true, args, args.length);
 
   resetEnvironment();
--- a/toolkit/mozapps/update/test/unit/test_0200_app_launch_apply_update.js
+++ b/toolkit/mozapps/update/test/unit/test_0200_app_launch_apply_update.js
@@ -99,16 +99,20 @@ function run_test() {
   let updaterIniContents = "[Strings]\n" +
                            "Title=Update Test\n" +
                            "Info=Application Update XPCShell Test - " +
                            "test_0200_general.js\n";
   updaterIni = processDir.clone();
   updaterIni.append(FILE_UPDATER_INI);
   writeFile(updaterIni, updaterIniContents);
 
+  let updateSettingsIni = processDir.clone();
+  updateSettingsIni.append(UPDATE_SETTINGS_INI_FILE);
+  writeFile(updateSettingsIni, UPDATE_SETTINGS_CONTENTS);
+
   let launchBin = getLaunchBin();
   let args = getProcessArgs();
   logTestInfo("launching " + launchBin.path + " " + args.join(" "));
 
   gProcess = AUS_Cc["@mozilla.org/process/util;1"].
                 createInstance(AUS_Ci.nsIProcess);
   gProcess.init(launchBin);
 
--- a/toolkit/mozapps/update/updater/archivereader.cpp
+++ b/toolkit/mozapps/update/updater/archivereader.cpp
@@ -139,19 +139,26 @@ VerifyLoadedCert(MarFile *archive, int n
 int
 ArchiveReader::VerifySignature()
 {
   if (!mArchive) {
     return ARCHIVE_NOT_OPEN;
   }
 
 #ifdef XP_WIN
-  int rv = VerifyLoadedCert(mArchive, IDR_PRIMARY_CERT, TYPE_CERT);
-  if (rv != OK) {
-    rv = VerifyLoadedCert(mArchive, IDR_BACKUP_CERT, TYPE_CERT);
+  // If the fallback key exists we're running an XPCShell test and we should
+  // use the XPCShell specific cert for the signed MAR.
+  int rv;
+  if (DoesFallbackKeyExist()) {
+    rv = VerifyLoadedCert(mArchive, IDR_XPCSHELL_CERT, TYPE_CERT);
+  } else {
+    rv = VerifyLoadedCert(mArchive, IDR_PRIMARY_CERT, TYPE_CERT);
+    if (rv != OK) {
+      rv = VerifyLoadedCert(mArchive, IDR_BACKUP_CERT, TYPE_CERT);
+    }
   }
   return rv;
 #else
   return OK;
 #endif
 }
 
 /**
--- a/toolkit/mozapps/update/updater/resource.h
+++ b/toolkit/mozapps/update/updater/resource.h
@@ -5,19 +5,20 @@
 #define IDD_DIALOG                      101
 #define IDC_PROGRESS                    1000
 #define IDC_INFO                        1002
 #define IDI_DIALOG                      1003
 #define TYPE_CERT                       512
 #define IDR_PRIMARY_CERT                1004
 #define IDR_BACKUP_CERT                 1005
 #define IDS_UPDATER_IDENTITY            1006
+#define IDR_XPCSHELL_CERT               1007
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        102
 #define _APS_NEXT_COMMAND_VALUE         40001
-#define _APS_NEXT_CONTROL_VALUE         1007
+#define _APS_NEXT_CONTROL_VALUE         1008
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -1669,25 +1669,17 @@ int NS_main(int argc, NS_tchar **argv)
 
   // We never want the service to be used unless we build with
   // the maintenance service.
 #ifdef MOZ_MAINTENANCE_SERVICE
   IsUpdateStatusPending(useService);
   // Our tests run with a different apply directory for each test.
   // We use this registry key on our test slaves to store the 
   // allowed name/issuers.
-  HKEY testOnlyFallbackKey;
-  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, 
-                    TEST_ONLY_FALLBACK_KEY_PATH, 0,
-                    KEY_READ | KEY_WOW64_64KEY, 
-                    &testOnlyFallbackKey) == ERROR_SUCCESS) {
-    testOnlyFallbackKeyExists = true;
-    RegCloseKey(testOnlyFallbackKey);
-  }
-
+  testOnlyFallbackKeyExists = DoesFallbackKeyExist();
 #endif
 #endif
 
   if (!WriteStatusApplying()) {
     LOG(("failed setting status to 'applying'\n"));
     return 1;
   }
 
--- a/toolkit/mozapps/update/updater/updater.rc
+++ b/toolkit/mozapps/update/updater/updater.rc
@@ -47,16 +47,18 @@ IDR_BACKUP_CERT TYPE_CERT  "release_seco
 #elif defined(MAR_SIGNING_AURORA_NIGHTLY)
 IDR_PRIMARY_CERT TYPE_CERT "nightly_aurora_level3_primary.der"
 IDR_BACKUP_CERT TYPE_CERT  "nightly_aurora_level3_secondary.der"
 #else
 IDR_PRIMARY_CERT TYPE_CERT "dep1.der"
 IDR_BACKUP_CERT TYPE_CERT  "dep2.der"
 #endif
 
+IDR_XPCSHELL_CERT TYPE_CERT "xpcshellCertificate.der"
+ 
 
 /////////////////////////////////////////////////////////////////////////////
 //
 // Embedded an identifier to uniquely identiy this as a Mozilla updater.
 //
 
 STRINGTABLE
 {
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..185b2dff4a696f6ec9b7330eeefddd4d57617eac
GIT binary patch
literal 677
zc$_n6Vp?d>#MrrjnTe5!iIrix_HIW5UN%mxHjlRNyo`*jtPBQ1h5`nBY|No7%);!x
zl?u+OMI{Du;=G1N21Z5(1}4Vl#uiavt|^?0RZkP660*^ZtPIRejQk8haW1ANMn;B3
z!VBJOulye6aBuR<$&GfEoYz$i0@!_98j_~1?yowL)5{}tDd9=N+1r8zoX1OQ*A*D4
zw)9Qq_Wbc8OuF}hS<<yFi*h~QytCbICu~yDBH?Qzao%m(3duJ{LF%C=*3Mtd6cZd)
z(7w^|kC-@1Zl&lopWpgPj|~^cx387$Dqa0hL+~|M!nLn*emMr4{~j+~R8jCC<eXgK
z*Zf0!4_pb?y%N1pdhhpl0dEqwmHuwxd+K~SS1@i<+`-?BL6x^TPyR`JA)1t7RJ@XH
zQR0*o(WpC3@$M=Ytz%BFvJ&yy#wQhWyszDKp`ol)!*5qc)6A~*+^O<9Y-S1@X0mUZ
zwdt^lwc&myW<~}^w7_Qu1&pVy%0ag7MLGXxTijd5;KUuZq$hPkp<47ThM7Gwo(CJR
zXz%nr=g2<!gRaaMm;Vn6Zu3>Y^7%Gv@9Fn(b8~jjGE90_`sg_Oq-nQr^50}x^`h(q
zzecC<TBchQm)`sH`qgyZ8Hew@FzuRgwOKD~&bJ4$N1i5TicDx{ND5=&3H#W=B<-^H
z&h$t751;-kZ!6UB<L|Y*a~k$uUKo2rD%jidsYlp};uEUux8^-u^7l+^c<l?3Duv`#
z(`KoM3JJ<ocYie4zJOhIT~Mj_)U}*j*R#mZDT#48pLlCi#YGO?iMCT2_xZ-3ZvMhz
idHvOnfNu!_Gq$fdvq8~w$2X_tWwLu)7rVXwHW>gHs~D94