From 28f9560f91c144e4dd97bcff67c7487c8d3c8513 Mon Sep 17 00:00:00 2001 From: Robert Strong Date: Tue, 19 Oct 2010 21:28:29 -0700 Subject: [PATCH] Bug 601518 - Need updater tests to cover nsUpdateDriver.cpp code. r=dtownsend, a=blocking2.0-final --- .../mozapps/installer/windows/nsis/common.nsh | 3 +- toolkit/mozapps/update/test/Makefile.in | 28 +- .../mozapps/update/test/chrome/Makefile.in | 2 +- .../test/chrome/test_0011_check_basic.xul | 3 +- .../chrome/test_0012_check_basic_license.xul | 3 +- .../chrome/test_0013_check_incompat_basic.xul | 3 +- ...test_0014_check_incompat_basic_license.xul | 3 +- .../test_0015_check_incompat_basic_addons.xul | 3 +- ...16_check_incompat_basic_license_addons.xul | 3 +- .../test/chrome/test_0021_check_billboard.xul | 3 +- .../test_0022_check_billboard_license.xul | 3 +- .../test_0023_check_incompat_billboard.xul | 3 +- ..._0024_check_incompat_billboard_license.xul | 3 +- ...t_0025_check_incompat_billboard_addons.xul | 3 +- ...heck_incompat_billboard_license_addons.xul | 3 +- .../test/chrome/test_0031_available_basic.xul | 3 +- .../test_0032_available_basic_license.xul | 3 +- .../test_0033_available_incompat_basic.xul | 3 +- ..._0034_available_incompat_basic_license.xul | 3 +- ...t_0035_available_incompat_basic_addons.xul | 3 +- ...vailable_incompat_basic_license_addons.xul | 3 +- .../chrome/test_0041_available_billboard.xul | 3 +- .../test_0042_available_billboard_license.xul | 3 +- ...test_0043_available_incompat_billboard.xul | 3 +- ...4_available_incompat_billboard_license.xul | 3 +- ...45_available_incompat_billboard_addons.xul | 3 +- ...able_incompat_billboard_license_addons.xul | 3 +- .../test_0051_check_error_xml_malformed.xul | 3 +- .../chrome/test_0052_check_no_updates.xul | 3 +- ...st_0053_check_billboard_license_noAttr.xul | 3 +- .../test_0054_check_billboard_license_404.xul | 3 +- ...061_check_verifyFailPartial_noComplete.xul | 3 +- ...062_check_verifyFailComplete_noPartial.xul | 3 +- ...t_0063_check_verifyFailPartialComplete.xul | 3 +- ...heck_verifyFailPartial_successComplete.xul | 3 +- ...71_notify_verifyFailPartial_noComplete.xul | 2 +- ...72_notify_verifyFailComplete_noPartial.xul | 2 +- ..._0073_notify_verifyFailPartialComplete.xul | 2 +- ...tify_verifyFailPartial_successComplete.xul | 2 +- ...1_error_patchApplyFailure_partial_only.xul | 2 +- ..._error_patchApplyFailure_complete_only.xul | 2 +- ...ror_patchApplyFailure_partial_complete.xul | 2 +- ..._error_patchApplyFailure_verify_failed.xul | 2 +- .../test/chrome/test_0091_installed.xul | 2 +- .../chrome/test_0092_finishedBackground.xul | 2 +- .../chrome/test_0111_neverButton_basic.xul | 3 +- .../test_0112_neverButton_billboard.xul | 3 +- ...113_showNeverForVersionRemovedWithPref.xul | 3 +- .../test_0121_check_requireBuiltinCert.xul | 36 +- ...eck_allowNonBuiltinCert_validCertAttrs.xul | 36 +- ...k_allowNonBuiltinCert_noCertAttrsCheck.xul | 4 +- ...t_0131_check_invalidCertAttrs_noUpdate.xul | 4 +- ..._0132_check_invalidCertAttrs_hasUpdate.xul | 4 +- ..._0141_notify_invalidCertAttrs_noUpdate.xul | 4 +- ...0142_notify_invalidCertAttrs_hasUpdate.xul | 4 +- .../test_0151_notify_backgroundCheckError.xul | 3 +- .../update/test/chrome/test_9999_cleanup.xul | 7 +- toolkit/mozapps/update/test/chrome/update.sjs | 64 +- toolkit/mozapps/update/test/chrome/utils.js | 248 ++++--- toolkit/mozapps/update/test/shared.js | 445 +++--------- .../mozapps/update/test/sharedUpdateXML.js | 343 +++++++++ .../mozapps/update/test/unit/data/empty.mar | Bin 775 -> 0 bytes .../mozapps/update/test/unit/data/simple.mar | Bin 0 -> 351 bytes .../update/test/unit/head_update.js.in | 69 +- .../update/test/unit/test_0010_general.js | 14 +- .../update/test/unit/test_0020_general.js | 33 +- .../update/test/unit/test_0030_general.js | 45 +- .../update/test/unit/test_0040_general.js | 30 +- .../update/test/unit/test_0050_general.js | 40 +- .../update/test/unit/test_0060_manager.js | 25 +- .../update/test/unit/test_0061_manager.js | 12 +- .../update/test/unit/test_0062_manager.js | 16 +- .../update/test/unit/test_0063_manager.js | 16 +- .../update/test/unit/test_0064_manager.js | 14 +- .../test/unit/test_0070_update_dir_cleanup.js | 17 +- .../test/unit/test_0071_update_dir_cleanup.js | 19 +- .../test/unit/test_0072_update_dir_cleanup.js | 11 +- .../test/unit/test_0080_prompt_silent.js | 18 +- .../unit/test_0081_prompt_uiAlreadyOpen.js | 16 +- .../update/test/unit/test_0110_general.js | 132 +++- .../update/test/unit/test_0111_general.js | 143 +++- .../update/test/unit/test_0112_general.js | 132 +++- .../unit/test_0200_app_launch_apply_update.js | 675 ++++++++++++++++++ .../update/test/unit/test_bug497578.js | 28 +- .../update/test/unit/test_bug595059.js | 13 +- toolkit/xre/nsAppRunner.cpp | 78 +- 86 files changed, 2086 insertions(+), 870 deletions(-) create mode 100644 toolkit/mozapps/update/test/sharedUpdateXML.js delete mode 100644 toolkit/mozapps/update/test/unit/data/empty.mar create mode 100644 toolkit/mozapps/update/test/unit/data/simple.mar create mode 100644 toolkit/mozapps/update/test/unit/test_0200_app_launch_apply_update.js diff --git a/toolkit/mozapps/installer/windows/nsis/common.nsh b/toolkit/mozapps/installer/windows/nsis/common.nsh index 103c019401e5..ad102518a696 100755 --- a/toolkit/mozapps/installer/windows/nsis/common.nsh +++ b/toolkit/mozapps/installer/windows/nsis/common.nsh @@ -4824,7 +4824,8 @@ IfErrors continue +1 ; If the uninstall.log does not exist don't perform post update ; operations. This prevents updating the registry for zip builds. - IfFileExists "$EXEDIR\uninstall.log" +1 finish + IfFileExists "$EXEDIR\uninstall.log" +2 +1 + Quit ; Nothing initialized so no need to call OnEndCommon ${PostUpdate} ClearErrors ${GetOptions} "$R0" "/UninstallLog=" $R2 diff --git a/toolkit/mozapps/update/test/Makefile.in b/toolkit/mozapps/update/test/Makefile.in index 7575105d636c..c4e82c4c0a7c 100644 --- a/toolkit/mozapps/update/test/Makefile.in +++ b/toolkit/mozapps/update/test/Makefile.in @@ -43,16 +43,24 @@ relativesrcdir = toolkit/mozapps/update/test include $(DEPTH)/config/autoconf.mk -DIRS = \ - chrome \ - $(NULL) - XPCSHELL_TESTS = \ unit \ $(NULL) TESTROOT = $(call core_abspath,$(DEPTH))/_tests/xpcshell/$(relativesrcdir) +DEFINES += \ + -DAB_CD=$(AB_CD) \ + -DMOZ_APP_NAME=$(MOZ_APP_NAME) \ + -DBIN_SUFFIX=$(BIN_SUFFIX) \ + -DNS_NO_XPCOM \ + $(NULL) + +ifndef ANDROID +DIRS = \ + chrome \ + $(NULL) + CPPSRCS = \ TestAUSReadStrings.cpp \ $(NULL) @@ -72,11 +80,6 @@ LOCAL_INCLUDES += \ MOZ_WINCONSOLE = 1 -DEFINES += \ - -DAB_CD=$(AB_CD) \ - -DNS_NO_XPCOM \ - $(NULL) - LIBS += \ ../../readstrings/$(LIB_PREFIX)readstrings.$(LIB_SUFFIX) \ $(NULL) @@ -102,9 +105,6 @@ else bug473417dir = test_bug473417 endif -libs:: unit/head_update.js.in - $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py -Fsubstitution $(DEFINES) $(ACDEFINES) $^ > $(TESTROOT)/unit/head_update.js - check:: $(RM) -rf $(DEPTH)/_tests/updater/ && $(NSINSTALL) -D $(DEPTH)/_tests/updater/$(bug473417dir)/ for i in $(INI_TEST_FILES); do \ @@ -112,3 +112,7 @@ check:: done $(INSTALL) $(FINAL_TARGET)/TestAUSReadStrings$(BIN_SUFFIX) $(DEPTH)/_tests/updater/$(bug473417dir)/ @$(RUN_TEST_PROGRAM) $(DEPTH)/_tests/updater/$(bug473417dir)/TestAUSReadStrings$(BIN_SUFFIX) +endif # ANDROID + +libs:: unit/head_update.js.in + $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py -Fsubstitution $(DEFINES) $(ACDEFINES) $^ > $(TESTROOT)/unit/head_update.js diff --git a/toolkit/mozapps/update/test/chrome/Makefile.in b/toolkit/mozapps/update/test/chrome/Makefile.in index 14bb0294a7fb..35d3145e16d8 100644 --- a/toolkit/mozapps/update/test/chrome/Makefile.in +++ b/toolkit/mozapps/update/test/chrome/Makefile.in @@ -44,7 +44,7 @@ relativesrcdir = toolkit/mozapps/update/test/chrome include $(DEPTH)/config/autoconf.mk _OTHER_FILES = \ - ../unit/data/empty.mar \ + ../unit/data/simple.mar \ $(NULL) _CHROME_FILES = \ diff --git a/toolkit/mozapps/update/test/chrome/test_0011_check_basic.xul b/toolkit/mozapps/update/test/chrome/test_0011_check_basic.xul index 6d2a409265bf..f30ae29c7270 100644 --- a/toolkit/mozapps/update/test/chrome/test_0011_check_basic.xul +++ b/toolkit/mozapps/update/test/chrome/test_0011_check_basic.xul @@ -34,11 +34,10 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showDetails=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0012_check_basic_license.xul b/toolkit/mozapps/update/test/chrome/test_0012_check_basic_license.xul index 24b0cc13260e..f9dfe7da73fb 100644 --- a/toolkit/mozapps/update/test/chrome/test_0012_check_basic_license.xul +++ b/toolkit/mozapps/update/test/chrome/test_0012_check_basic_license.xul @@ -74,11 +74,10 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showLicense=1&showDetails=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0013_check_incompat_basic.xul b/toolkit/mozapps/update/test/chrome/test_0013_check_incompat_basic.xul index 441f77bf8b99..da6d94938b65 100644 --- a/toolkit/mozapps/update/test/chrome/test_0013_check_incompat_basic.xul +++ b/toolkit/mozapps/update/test/chrome/test_0013_check_incompat_basic.xul @@ -38,12 +38,11 @@ const TESTS = [ { gDisableNoUpdateAddon = true; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showDetails=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump(PREF_APP_UPDATE_URL_OVERRIDE + ": " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0014_check_incompat_basic_license.xul b/toolkit/mozapps/update/test/chrome/test_0014_check_incompat_basic_license.xul index 63d4f33dd0a1..1075486bd47f 100644 --- a/toolkit/mozapps/update/test/chrome/test_0014_check_incompat_basic_license.xul +++ b/toolkit/mozapps/update/test/chrome/test_0014_check_incompat_basic_license.xul @@ -78,12 +78,11 @@ const TESTS = [ { gDisableNoUpdateAddon = true; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showLicense=1&showDetails=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0015_check_incompat_basic_addons.xul b/toolkit/mozapps/update/test/chrome/test_0015_check_incompat_basic_addons.xul index 9960dea084a7..32d6a579f508 100644 --- a/toolkit/mozapps/update/test/chrome/test_0015_check_incompat_basic_addons.xul +++ b/toolkit/mozapps/update/test/chrome/test_0015_check_incompat_basic_addons.xul @@ -47,12 +47,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showDetails=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump(PREF_APP_UPDATE_URL_OVERRIDE + ": " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0016_check_incompat_basic_license_addons.xul b/toolkit/mozapps/update/test/chrome/test_0016_check_incompat_basic_license_addons.xul index 8c70697ff4c1..bac87d6a5343 100644 --- a/toolkit/mozapps/update/test/chrome/test_0016_check_incompat_basic_license_addons.xul +++ b/toolkit/mozapps/update/test/chrome/test_0016_check_incompat_basic_license_addons.xul @@ -87,12 +87,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showLicense=1&showDetails=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump(PREF_APP_UPDATE_URL_OVERRIDE + ": " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0021_check_billboard.xul b/toolkit/mozapps/update/test/chrome/test_0021_check_billboard.xul index f0bacb08bbad..f4f6f2ceb6a1 100644 --- a/toolkit/mozapps/update/test/chrome/test_0021_check_billboard.xul +++ b/toolkit/mozapps/update/test/chrome/test_0021_check_billboard.xul @@ -41,11 +41,10 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showBillboard=1&showDetails=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0022_check_billboard_license.xul b/toolkit/mozapps/update/test/chrome/test_0022_check_billboard_license.xul index ab199958c8ae..a4da0c23033b 100644 --- a/toolkit/mozapps/update/test/chrome/test_0022_check_billboard_license.xul +++ b/toolkit/mozapps/update/test/chrome/test_0022_check_billboard_license.xul @@ -83,12 +83,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showBillboard=1&showLicense=1&showDetails=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0023_check_incompat_billboard.xul b/toolkit/mozapps/update/test/chrome/test_0023_check_incompat_billboard.xul index aac223e3ee01..11c8c67bfe88 100644 --- a/toolkit/mozapps/update/test/chrome/test_0023_check_incompat_billboard.xul +++ b/toolkit/mozapps/update/test/chrome/test_0023_check_incompat_billboard.xul @@ -45,12 +45,11 @@ const TESTS = [ { gDisableNoUpdateAddon = true; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showBillboard=1&showDetails=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump(PREF_APP_UPDATE_URL_OVERRIDE + ": " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0024_check_incompat_billboard_license.xul b/toolkit/mozapps/update/test/chrome/test_0024_check_incompat_billboard_license.xul index 04591c54fb8b..c6d727fdd6b8 100644 --- a/toolkit/mozapps/update/test/chrome/test_0024_check_incompat_billboard_license.xul +++ b/toolkit/mozapps/update/test/chrome/test_0024_check_incompat_billboard_license.xul @@ -87,12 +87,11 @@ const TESTS = [ { gDisableNoUpdateAddon = true; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showBillboard=1&showLicense=1&showDetails=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0025_check_incompat_billboard_addons.xul b/toolkit/mozapps/update/test/chrome/test_0025_check_incompat_billboard_addons.xul index 707e88e7d4bc..a832db256132 100644 --- a/toolkit/mozapps/update/test/chrome/test_0025_check_incompat_billboard_addons.xul +++ b/toolkit/mozapps/update/test/chrome/test_0025_check_incompat_billboard_addons.xul @@ -56,12 +56,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showBillboard=1&showDetails=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump(PREF_APP_UPDATE_URL_OVERRIDE + ": " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0026_check_incompat_billboard_license_addons.xul b/toolkit/mozapps/update/test/chrome/test_0026_check_incompat_billboard_license_addons.xul index 9ad91606fc9b..ff583ade91af 100644 --- a/toolkit/mozapps/update/test/chrome/test_0026_check_incompat_billboard_license_addons.xul +++ b/toolkit/mozapps/update/test/chrome/test_0026_check_incompat_billboard_license_addons.xul @@ -96,12 +96,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showBillboard=1&showLicense=1&showDetails=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump(PREF_APP_UPDATE_URL_OVERRIDE + ": " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0031_available_basic.xul b/toolkit/mozapps/update/test/chrome/test_0031_available_basic.xul index ef25b75c9b5e..486e47c1e7a8 100644 --- a/toolkit/mozapps/update/test/chrome/test_0031_available_basic.xul +++ b/toolkit/mozapps/update/test/chrome/test_0031_available_basic.xul @@ -32,11 +32,10 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showDetails=1&showPrompt=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gAUS.notify(null); } diff --git a/toolkit/mozapps/update/test/chrome/test_0032_available_basic_license.xul b/toolkit/mozapps/update/test/chrome/test_0032_available_basic_license.xul index 16890dca662a..95e7daab680a 100644 --- a/toolkit/mozapps/update/test/chrome/test_0032_available_basic_license.xul +++ b/toolkit/mozapps/update/test/chrome/test_0032_available_basic_license.xul @@ -72,12 +72,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showLicense=1&showDetails=1&showPrompt=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gAUS.notify(null); } diff --git a/toolkit/mozapps/update/test/chrome/test_0033_available_incompat_basic.xul b/toolkit/mozapps/update/test/chrome/test_0033_available_incompat_basic.xul index dd044302c8c2..a1f8502a48d1 100644 --- a/toolkit/mozapps/update/test/chrome/test_0033_available_incompat_basic.xul +++ b/toolkit/mozapps/update/test/chrome/test_0033_available_incompat_basic.xul @@ -36,12 +36,11 @@ const TESTS = [ { gDisableNoUpdateAddon = true; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showDetails=1&showPrompt=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gAUS.notify(null); } diff --git a/toolkit/mozapps/update/test/chrome/test_0034_available_incompat_basic_license.xul b/toolkit/mozapps/update/test/chrome/test_0034_available_incompat_basic_license.xul index aca5643eb48e..0111467b555a 100644 --- a/toolkit/mozapps/update/test/chrome/test_0034_available_incompat_basic_license.xul +++ b/toolkit/mozapps/update/test/chrome/test_0034_available_incompat_basic_license.xul @@ -76,12 +76,11 @@ const TESTS = [ { gDisableNoUpdateAddon = true; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showLicense=1&showDetails=1&showPrompt=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gAUS.notify(null); } diff --git a/toolkit/mozapps/update/test/chrome/test_0035_available_incompat_basic_addons.xul b/toolkit/mozapps/update/test/chrome/test_0035_available_incompat_basic_addons.xul index 69eca317b4a2..e406b494aaeb 100644 --- a/toolkit/mozapps/update/test/chrome/test_0035_available_incompat_basic_addons.xul +++ b/toolkit/mozapps/update/test/chrome/test_0035_available_incompat_basic_addons.xul @@ -45,12 +45,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showDetails=1&showPrompt=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gAUS.notify(null); } diff --git a/toolkit/mozapps/update/test/chrome/test_0036_available_incompat_basic_license_addons.xul b/toolkit/mozapps/update/test/chrome/test_0036_available_incompat_basic_license_addons.xul index 40f6402a5363..71f35ab4a604 100644 --- a/toolkit/mozapps/update/test/chrome/test_0036_available_incompat_basic_license_addons.xul +++ b/toolkit/mozapps/update/test/chrome/test_0036_available_incompat_basic_license_addons.xul @@ -85,12 +85,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showLicense=1&showDetails=1&showPrompt=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gAUS.notify(null); } diff --git a/toolkit/mozapps/update/test/chrome/test_0041_available_billboard.xul b/toolkit/mozapps/update/test/chrome/test_0041_available_billboard.xul index 96de689cbd9b..9e07e7f65346 100644 --- a/toolkit/mozapps/update/test/chrome/test_0041_available_billboard.xul +++ b/toolkit/mozapps/update/test/chrome/test_0041_available_billboard.xul @@ -39,12 +39,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showBillboard=1&showDetails=1&showPrompt=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gAUS.notify(null); } diff --git a/toolkit/mozapps/update/test/chrome/test_0042_available_billboard_license.xul b/toolkit/mozapps/update/test/chrome/test_0042_available_billboard_license.xul index f3a00651c4a8..05a712882d08 100644 --- a/toolkit/mozapps/update/test/chrome/test_0042_available_billboard_license.xul +++ b/toolkit/mozapps/update/test/chrome/test_0042_available_billboard_license.xul @@ -81,12 +81,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showBillboard=1&showLicense=1&showDetails=1" + "&showPrompt=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gAUS.notify(null); } diff --git a/toolkit/mozapps/update/test/chrome/test_0043_available_incompat_billboard.xul b/toolkit/mozapps/update/test/chrome/test_0043_available_incompat_billboard.xul index 6344d59e8507..140d1a86e456 100644 --- a/toolkit/mozapps/update/test/chrome/test_0043_available_incompat_billboard.xul +++ b/toolkit/mozapps/update/test/chrome/test_0043_available_incompat_billboard.xul @@ -43,12 +43,11 @@ const TESTS = [ { gDisableNoUpdateAddon = true; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showBillboard=1&showPrompt=1&showDetails=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump(PREF_APP_UPDATE_URL_OVERRIDE + ": " + url); gAUS.notify(null); } diff --git a/toolkit/mozapps/update/test/chrome/test_0044_available_incompat_billboard_license.xul b/toolkit/mozapps/update/test/chrome/test_0044_available_incompat_billboard_license.xul index 4255497f3132..b952156f388c 100644 --- a/toolkit/mozapps/update/test/chrome/test_0044_available_incompat_billboard_license.xul +++ b/toolkit/mozapps/update/test/chrome/test_0044_available_incompat_billboard_license.xul @@ -85,12 +85,11 @@ const TESTS = [ { gDisableNoUpdateAddon = true; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showBillboard=1&showLicense=1&showDetails=1&showPrompt=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gAUS.notify(null); } diff --git a/toolkit/mozapps/update/test/chrome/test_0045_available_incompat_billboard_addons.xul b/toolkit/mozapps/update/test/chrome/test_0045_available_incompat_billboard_addons.xul index de2733338380..e4efdf799d6d 100644 --- a/toolkit/mozapps/update/test/chrome/test_0045_available_incompat_billboard_addons.xul +++ b/toolkit/mozapps/update/test/chrome/test_0045_available_incompat_billboard_addons.xul @@ -54,12 +54,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showBillboard=1&showDetails=1&showPrompt=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gAUS.notify(null); } diff --git a/toolkit/mozapps/update/test/chrome/test_0046_available_incompat_billboard_license_addons.xul b/toolkit/mozapps/update/test/chrome/test_0046_available_incompat_billboard_license_addons.xul index a8d56ab68901..9d3642aa078f 100644 --- a/toolkit/mozapps/update/test/chrome/test_0046_available_incompat_billboard_license_addons.xul +++ b/toolkit/mozapps/update/test/chrome/test_0046_available_incompat_billboard_license_addons.xul @@ -94,12 +94,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showBillboard=1&showLicense=1&showDetails=1&showPrompt=1" + getVersionParams(getNewerAppVersion(), getNewerPlatformVersion()); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gAUS.notify(null); } diff --git a/toolkit/mozapps/update/test/chrome/test_0051_check_error_xml_malformed.xul b/toolkit/mozapps/update/test/chrome/test_0051_check_error_xml_malformed.xul index deb342e5cc5d..b94a2ee9e9c3 100644 --- a/toolkit/mozapps/update/test/chrome/test_0051_check_error_xml_malformed.xul +++ b/toolkit/mozapps/update/test/chrome/test_0051_check_error_xml_malformed.xul @@ -29,11 +29,10 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?xmlMalformed=1"; setUpdateURLOverride(url); - debugDump("Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0052_check_no_updates.xul b/toolkit/mozapps/update/test/chrome/test_0052_check_no_updates.xul index a8d02fff1c75..55726803689f 100644 --- a/toolkit/mozapps/update/test/chrome/test_0052_check_no_updates.xul +++ b/toolkit/mozapps/update/test/chrome/test_0052_check_no_updates.xul @@ -29,11 +29,10 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?noUpdates=1"; setUpdateURLOverride(url); - debugDump("Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0053_check_billboard_license_noAttr.xul b/toolkit/mozapps/update/test/chrome/test_0053_check_billboard_license_noAttr.xul index db93467e1b15..eb13edd8e484 100644 --- a/toolkit/mozapps/update/test/chrome/test_0053_check_billboard_license_noAttr.xul +++ b/toolkit/mozapps/update/test/chrome/test_0053_check_billboard_license_noAttr.xul @@ -40,12 +40,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showBillboard=1&showLicense=1&remoteNoTypeAttr=1" + "&showDetails=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0054_check_billboard_license_404.xul b/toolkit/mozapps/update/test/chrome/test_0054_check_billboard_license_404.xul index 620534c32560..24fbee666027 100644 --- a/toolkit/mozapps/update/test/chrome/test_0054_check_billboard_license_404.xul +++ b/toolkit/mozapps/update/test/chrome/test_0054_check_billboard_license_404.xul @@ -40,12 +40,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?billboard404=1&license404=1&showDetails=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0061_check_verifyFailPartial_noComplete.xul b/toolkit/mozapps/update/test/chrome/test_0061_check_verifyFailPartial_noComplete.xul index 8b9315a8a695..24bb690839b2 100644 --- a/toolkit/mozapps/update/test/chrome/test_0061_check_verifyFailPartial_noComplete.xul +++ b/toolkit/mozapps/update/test/chrome/test_0061_check_verifyFailPartial_noComplete.xul @@ -34,12 +34,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showDetails=1&partialPatchOnly=1&invalidPartialHash=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0062_check_verifyFailComplete_noPartial.xul b/toolkit/mozapps/update/test/chrome/test_0062_check_verifyFailComplete_noPartial.xul index 91f21fe01494..60d185928eb5 100644 --- a/toolkit/mozapps/update/test/chrome/test_0062_check_verifyFailComplete_noPartial.xul +++ b/toolkit/mozapps/update/test/chrome/test_0062_check_verifyFailComplete_noPartial.xul @@ -34,12 +34,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showDetails=1&completePatchOnly=1&invalidCompleteHash=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0063_check_verifyFailPartialComplete.xul b/toolkit/mozapps/update/test/chrome/test_0063_check_verifyFailPartialComplete.xul index fca5489ccc73..ff76e2478d14 100644 --- a/toolkit/mozapps/update/test/chrome/test_0063_check_verifyFailPartialComplete.xul +++ b/toolkit/mozapps/update/test/chrome/test_0063_check_verifyFailPartialComplete.xul @@ -34,12 +34,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showDetails=1&invalidPartialHash=1&invalidCompleteHash=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0064_check_verifyFailPartial_successComplete.xul b/toolkit/mozapps/update/test/chrome/test_0064_check_verifyFailPartial_successComplete.xul index 759caaa24afd..2fdf463d49ef 100644 --- a/toolkit/mozapps/update/test/chrome/test_0064_check_verifyFailPartial_successComplete.xul +++ b/toolkit/mozapps/update/test/chrome/test_0064_check_verifyFailPartial_successComplete.xul @@ -34,12 +34,11 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showDetails=1&invalidPartialHash=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0071_notify_verifyFailPartial_noComplete.xul b/toolkit/mozapps/update/test/chrome/test_0071_notify_verifyFailPartial_noComplete.xul index 2e15d9cc6907..5556aa9603c4 100644 --- a/toolkit/mozapps/update/test/chrome/test_0071_notify_verifyFailPartial_noComplete.xul +++ b/toolkit/mozapps/update/test/chrome/test_0071_notify_verifyFailPartial_noComplete.xul @@ -27,7 +27,7 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let patches = getLocalPatchString("partial", null, null, "1234", null, null, STATE_DOWNLOADING); diff --git a/toolkit/mozapps/update/test/chrome/test_0072_notify_verifyFailComplete_noPartial.xul b/toolkit/mozapps/update/test/chrome/test_0072_notify_verifyFailComplete_noPartial.xul index 4a74004bad19..05ad0490647b 100644 --- a/toolkit/mozapps/update/test/chrome/test_0072_notify_verifyFailComplete_noPartial.xul +++ b/toolkit/mozapps/update/test/chrome/test_0072_notify_verifyFailComplete_noPartial.xul @@ -27,7 +27,7 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let patches = getLocalPatchString("complete", null, null, "1234", null, null, STATE_DOWNLOADING); diff --git a/toolkit/mozapps/update/test/chrome/test_0073_notify_verifyFailPartialComplete.xul b/toolkit/mozapps/update/test/chrome/test_0073_notify_verifyFailPartialComplete.xul index b7dde596d015..ebed5297e285 100644 --- a/toolkit/mozapps/update/test/chrome/test_0073_notify_verifyFailPartialComplete.xul +++ b/toolkit/mozapps/update/test/chrome/test_0073_notify_verifyFailPartialComplete.xul @@ -27,7 +27,7 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let patches = getLocalPatchString("partial", null, null, "1234", null, null, STATE_DOWNLOADING) + diff --git a/toolkit/mozapps/update/test/chrome/test_0074_notify_verifyFailPartial_successComplete.xul b/toolkit/mozapps/update/test/chrome/test_0074_notify_verifyFailPartial_successComplete.xul index 2f49d4fa3585..7a765063acc9 100644 --- a/toolkit/mozapps/update/test/chrome/test_0074_notify_verifyFailPartial_successComplete.xul +++ b/toolkit/mozapps/update/test/chrome/test_0074_notify_verifyFailPartial_successComplete.xul @@ -27,7 +27,7 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let patches = getLocalPatchString("partial", null, null, "1234", null, null, STATE_DOWNLOADING) + diff --git a/toolkit/mozapps/update/test/chrome/test_0081_error_patchApplyFailure_partial_only.xul b/toolkit/mozapps/update/test/chrome/test_0081_error_patchApplyFailure_partial_only.xul index fa3716bcfe05..f83dbc43b7a7 100644 --- a/toolkit/mozapps/update/test/chrome/test_0081_error_patchApplyFailure_partial_only.xul +++ b/toolkit/mozapps/update/test/chrome/test_0081_error_patchApplyFailure_partial_only.xul @@ -27,7 +27,7 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let patches = getLocalPatchString("partial", null, null, null, null, null, STATE_PENDING); diff --git a/toolkit/mozapps/update/test/chrome/test_0082_error_patchApplyFailure_complete_only.xul b/toolkit/mozapps/update/test/chrome/test_0082_error_patchApplyFailure_complete_only.xul index c41ee5228e55..a81b4aef97e9 100644 --- a/toolkit/mozapps/update/test/chrome/test_0082_error_patchApplyFailure_complete_only.xul +++ b/toolkit/mozapps/update/test/chrome/test_0082_error_patchApplyFailure_complete_only.xul @@ -27,7 +27,7 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let patches = getLocalPatchString("complete", null, null, null, null, null, STATE_PENDING); diff --git a/toolkit/mozapps/update/test/chrome/test_0083_error_patchApplyFailure_partial_complete.xul b/toolkit/mozapps/update/test/chrome/test_0083_error_patchApplyFailure_partial_complete.xul index 0bd1000e9fcb..11777599180c 100644 --- a/toolkit/mozapps/update/test/chrome/test_0083_error_patchApplyFailure_partial_complete.xul +++ b/toolkit/mozapps/update/test/chrome/test_0083_error_patchApplyFailure_partial_complete.xul @@ -32,7 +32,7 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); // Specify the url to update.sjs with a slowDownloadMar param so the ui can // load before the download completes. diff --git a/toolkit/mozapps/update/test/chrome/test_0084_error_patchApplyFailure_verify_failed.xul b/toolkit/mozapps/update/test/chrome/test_0084_error_patchApplyFailure_verify_failed.xul index 3e73a12ec514..59bbfc605045 100644 --- a/toolkit/mozapps/update/test/chrome/test_0084_error_patchApplyFailure_verify_failed.xul +++ b/toolkit/mozapps/update/test/chrome/test_0084_error_patchApplyFailure_verify_failed.xul @@ -32,7 +32,7 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); // Specify the url to update.sjs with a slowDownloadMar param so the ui can // load before the download completes. diff --git a/toolkit/mozapps/update/test/chrome/test_0091_installed.xul b/toolkit/mozapps/update/test/chrome/test_0091_installed.xul index e3788e8e65c3..c9fdf275c733 100644 --- a/toolkit/mozapps/update/test/chrome/test_0091_installed.xul +++ b/toolkit/mozapps/update/test/chrome/test_0091_installed.xul @@ -27,7 +27,7 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); Services.prefs.setBoolPref(PREF_APP_UPDATE_SHOW_INSTALLED_UI, true); let patches = getLocalPatchString("complete", null, null, null, null, null, diff --git a/toolkit/mozapps/update/test/chrome/test_0092_finishedBackground.xul b/toolkit/mozapps/update/test/chrome/test_0092_finishedBackground.xul index 10c1215fdccb..5d02a7017c84 100644 --- a/toolkit/mozapps/update/test/chrome/test_0092_finishedBackground.xul +++ b/toolkit/mozapps/update/test/chrome/test_0092_finishedBackground.xul @@ -27,7 +27,7 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let patches = getLocalPatchString("complete", null, null, null, null, null, STATE_PENDING); diff --git a/toolkit/mozapps/update/test/chrome/test_0111_neverButton_basic.xul b/toolkit/mozapps/update/test/chrome/test_0111_neverButton_basic.xul index 5241a50d97de..752403074cab 100644 --- a/toolkit/mozapps/update/test/chrome/test_0111_neverButton_basic.xul +++ b/toolkit/mozapps/update/test/chrome/test_0111_neverButton_basic.xul @@ -34,11 +34,10 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showNever=1&showDetails=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); // add the never preference for this version to verify that checking for // updates clears the preference. diff --git a/toolkit/mozapps/update/test/chrome/test_0112_neverButton_billboard.xul b/toolkit/mozapps/update/test/chrome/test_0112_neverButton_billboard.xul index d3d772970a9a..2f5c58171e7d 100644 --- a/toolkit/mozapps/update/test/chrome/test_0112_neverButton_billboard.xul +++ b/toolkit/mozapps/update/test/chrome/test_0112_neverButton_billboard.xul @@ -42,11 +42,10 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showBillboard=1&showNever=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); // add the never preference for this version to verify that checking for // updates clears the preference. diff --git a/toolkit/mozapps/update/test/chrome/test_0113_showNeverForVersionRemovedWithPref.xul b/toolkit/mozapps/update/test/chrome/test_0113_showNeverForVersionRemovedWithPref.xul index cb6d1c5caeca..51b5975d90c8 100644 --- a/toolkit/mozapps/update/test/chrome/test_0113_showNeverForVersionRemovedWithPref.xul +++ b/toolkit/mozapps/update/test/chrome/test_0113_showNeverForVersionRemovedWithPref.xul @@ -31,11 +31,10 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?showDetails=1&showPrompt=1" + getVersionParams(); setUpdateURLOverride(url); - debugDump("Update URL: " + url); // add the never preference for this version to verify that checking for // updates clears the preference. diff --git a/toolkit/mozapps/update/test/chrome/test_0121_check_requireBuiltinCert.xul b/toolkit/mozapps/update/test/chrome/test_0121_check_requireBuiltinCert.xul index 0119ef116f0c..186898473f65 100644 --- a/toolkit/mozapps/update/test/chrome/test_0121_check_requireBuiltinCert.xul +++ b/toolkit/mozapps/update/test/chrome/test_0121_check_requireBuiltinCert.xul @@ -36,20 +36,22 @@ const CERT_ATTRS = ["nickname", "emailAddress", "subjectName", "commonName", "issuerCommonName", "issuerOrganization", "issuerOrganizationUnit", "dbKey", "windowTitle"]; -function runTest() { - debugDump("Entering runTest"); +var gRequest; - var request = AUS_Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]. - createInstance(AUS_Ci.nsIXMLHttpRequest); - request.open("GET", "https://example.com/", true); - request.channel.notificationCallbacks = new BadCertHandler(true); - request.onload = function(event) { testXHRLoad(event); }; - request.onerror = function(event) { testXHRError(event); }; - request.send(null); +function runTest() { + debugDump("entering"); + + gRequest = AUS_Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]. + createInstance(AUS_Ci.nsIXMLHttpRequest); + gRequest.open("GET", "https://example.com/", true); + gRequest.channel.notificationCallbacks = new BadCertHandler(true); + gRequest.onload = function(event) { testXHRLoad(event); }; + gRequest.onerror = function(event) { testXHRError(event); }; + gRequest.send(null); } function testXHRError(aEvent) { - debugDump("Entering testXHRError"); + debugDump("entering"); ok(true, "Entering testXHRError - something went wrong"); @@ -66,11 +68,12 @@ function testXHRError(aEvent) { ok(false, "XHR onerror called: " + status); + gRequest = null; finishTestDefault(); } function testXHRLoad(aEvent) { - debugDump("Entering testXHRLoad"); + debugDump("entering"); var channel = aEvent.target.channel; var cert = channel.securityInfo.QueryInterface(AUS_Ci.nsISSLStatusProvider). @@ -83,12 +86,21 @@ function testXHRLoad(aEvent) { let url = "https://example.com/" + URL_PATH + "/update.sjs?showDetails=1" + getVersionParams(); gAppUpdateURLDefault = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL); + debugDump("setting default pref " + PREF_APP_UPDATE_URL + " to " + url); gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url); - debugDump("Default Update URL: " + url); + gRequest = null; gUP.checkForUpdates(); } +function finishTest() { + if (gRequest) { + gRequest.abort(); + gRequest = null; + } + finishTestDefault(); +} + ]]> diff --git a/toolkit/mozapps/update/test/chrome/test_0122_check_allowNonBuiltinCert_validCertAttrs.xul b/toolkit/mozapps/update/test/chrome/test_0122_check_allowNonBuiltinCert_validCertAttrs.xul index 3d5a7f8464ee..d67850ea5b4e 100644 --- a/toolkit/mozapps/update/test/chrome/test_0122_check_allowNonBuiltinCert_validCertAttrs.xul +++ b/toolkit/mozapps/update/test/chrome/test_0122_check_allowNonBuiltinCert_validCertAttrs.xul @@ -36,20 +36,22 @@ const CERT_ATTRS = ["nickname", "emailAddress", "subjectName", "commonName", "issuerCommonName", "issuerOrganization", "issuerOrganizationUnit", "dbKey", "windowTitle"]; -function runTest() { - debugDump("Entering runTest"); +var gRequest; - var request = AUS_Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]. - createInstance(AUS_Ci.nsIXMLHttpRequest); - request.open("GET", "https://example.com/", true); - request.channel.notificationCallbacks = new BadCertHandler(true); - request.onload = function(event) { testXHRLoad(event); }; - request.onerror = function(event) { testXHRError(event); }; - request.send(null); +function runTest() { + debugDump("entering"); + + gRequest = AUS_Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]. + createInstance(AUS_Ci.nsIXMLHttpRequest); + gRequest.open("GET", "https://example.com/", true); + gRequest.channel.notificationCallbacks = new BadCertHandler(true); + gRequest.onload = function(event) { testXHRLoad(event); }; + gRequest.onerror = function(event) { testXHRError(event); }; + gRequest.send(null); } function testXHRError(aEvent) { - debugDump("Entering testXHRError"); + debugDump("entering"); ok(true, "Entering testXHRError - something went wrong"); @@ -66,11 +68,12 @@ function testXHRError(aEvent) { ok(false, "XHR onerror called: " + status); + gRequest = null; finishTestDefault(); } function testXHRLoad(aEvent) { - debugDump("Entering testXHRLoad"); + debugDump("entering"); var channel = aEvent.target.channel; var cert = channel.securityInfo.QueryInterface(AUS_Ci.nsISSLStatusProvider). @@ -85,12 +88,21 @@ function testXHRLoad(aEvent) { let url = "https://example.com/" + URL_PATH + "/update.sjs?showDetails=1" + getVersionParams(); gAppUpdateURLDefault = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL); + debugDump("setting default pref " + PREF_APP_UPDATE_URL + " to " + url); gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url); - debugDump("Default Update URL: " + url); + gRequest = null; gUP.checkForUpdates(); } +function finishTest() { + if (gRequest) { + gRequest.abort(); + gRequest = null; + } + finishTestDefault(); +} + ]]> diff --git a/toolkit/mozapps/update/test/chrome/test_0123_check_allowNonBuiltinCert_noCertAttrsCheck.xul b/toolkit/mozapps/update/test/chrome/test_0123_check_allowNonBuiltinCert_noCertAttrsCheck.xul index 9d253e1a931e..168b6c81cd4b 100644 --- a/toolkit/mozapps/update/test/chrome/test_0123_check_allowNonBuiltinCert_noCertAttrsCheck.xul +++ b/toolkit/mozapps/update/test/chrome/test_0123_check_allowNonBuiltinCert_noCertAttrsCheck.xul @@ -31,7 +31,7 @@ const TESTS = [ { Components.utils.import("resource://gre/modules/CertUtils.jsm"); function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); Services.prefs.setCharPref(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME, "Invalid Attribute Name"); @@ -42,8 +42,8 @@ function runTest() { let url = "https://example.com/" + URL_PATH + "/update.sjs?showDetails=1" + getVersionParams(); gAppUpdateURLDefault = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL); + debugDump("setting default pref " + PREF_APP_UPDATE_URL + " to " + url); gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url); - debugDump("Default Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0131_check_invalidCertAttrs_noUpdate.xul b/toolkit/mozapps/update/test/chrome/test_0131_check_invalidCertAttrs_noUpdate.xul index 1e8a2ec75ec3..69cddeac13e5 100644 --- a/toolkit/mozapps/update/test/chrome/test_0131_check_invalidCertAttrs_noUpdate.xul +++ b/toolkit/mozapps/update/test/chrome/test_0131_check_invalidCertAttrs_noUpdate.xul @@ -32,7 +32,7 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); Services.prefs.setCharPref(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME, "Invalid Attribute Name"); @@ -40,8 +40,8 @@ function runTest() { let url = "https://example.com/" + URL_PATH + "/update.sjs?noUpdates=1"; gAppUpdateURLDefault = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL); + debugDump("setting default pref " + PREF_APP_UPDATE_URL + " to " + url); gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url); - debugDump("Default Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0132_check_invalidCertAttrs_hasUpdate.xul b/toolkit/mozapps/update/test/chrome/test_0132_check_invalidCertAttrs_hasUpdate.xul index 2265c6c4f139..64e513038d0d 100644 --- a/toolkit/mozapps/update/test/chrome/test_0132_check_invalidCertAttrs_hasUpdate.xul +++ b/toolkit/mozapps/update/test/chrome/test_0132_check_invalidCertAttrs_hasUpdate.xul @@ -32,7 +32,7 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); Services.prefs.setCharPref(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME, "Invalid Attribute Name"); @@ -41,8 +41,8 @@ function runTest() { let url = "https://example.com/" + URL_PATH + "/update.sjs?showDetails=1" + getVersionParams(); gAppUpdateURLDefault = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL); + debugDump("setting default pref " + PREF_APP_UPDATE_URL + " to " + url); gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url); - debugDump("Default Update URL: " + url); gUP.checkForUpdates(); } diff --git a/toolkit/mozapps/update/test/chrome/test_0141_notify_invalidCertAttrs_noUpdate.xul b/toolkit/mozapps/update/test/chrome/test_0141_notify_invalidCertAttrs_noUpdate.xul index fbe72888b3e0..eabe8804e643 100644 --- a/toolkit/mozapps/update/test/chrome/test_0141_notify_invalidCertAttrs_noUpdate.xul +++ b/toolkit/mozapps/update/test/chrome/test_0141_notify_invalidCertAttrs_noUpdate.xul @@ -30,15 +30,15 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); Services.prefs.setCharPref(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME, "Invalid Attribute Name"); let url = "https://example.com/" + URL_PATH + "/update.sjs?noUpdates=1"; gAppUpdateURLDefault = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL); + debugDump("setting default pref " + PREF_APP_UPDATE_URL + " to " + url); gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url); - debugDump("Default Update URL: " + url); errorsPrefObserver.init(PREF_APP_UPDATE_CERT_ERRORS, PREF_APP_UPDATE_CERT_MAXERRORS); diff --git a/toolkit/mozapps/update/test/chrome/test_0142_notify_invalidCertAttrs_hasUpdate.xul b/toolkit/mozapps/update/test/chrome/test_0142_notify_invalidCertAttrs_hasUpdate.xul index 0aa7d2520d1c..4b364ff3cdf0 100644 --- a/toolkit/mozapps/update/test/chrome/test_0142_notify_invalidCertAttrs_hasUpdate.xul +++ b/toolkit/mozapps/update/test/chrome/test_0142_notify_invalidCertAttrs_hasUpdate.xul @@ -30,7 +30,7 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); Services.prefs.setCharPref(PREF_APP_UPDATE_CERT_INVALID_ATTR_NAME, "Invalid Attribute Name"); @@ -38,8 +38,8 @@ function runTest() { let url = "https://example.com/" + URL_PATH + "/update.sjs?showDetails=1" + getVersionParams(); gAppUpdateURLDefault = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_URL); + debugDump("setting default pref " + PREF_APP_UPDATE_URL + " to " + url); gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_URL, url); - debugDump("Default Update URL: " + url); errorsPrefObserver.init(PREF_APP_UPDATE_CERT_ERRORS, PREF_APP_UPDATE_CERT_MAXERRORS); diff --git a/toolkit/mozapps/update/test/chrome/test_0151_notify_backgroundCheckError.xul b/toolkit/mozapps/update/test/chrome/test_0151_notify_backgroundCheckError.xul index 7bdf3e6c753c..9a8511980663 100644 --- a/toolkit/mozapps/update/test/chrome/test_0151_notify_backgroundCheckError.xul +++ b/toolkit/mozapps/update/test/chrome/test_0151_notify_backgroundCheckError.xul @@ -30,11 +30,10 @@ const TESTS = [ { } ]; function runTest() { - debugDump("Entering runTest"); + debugDump("entering"); let url = URL_UPDATE + "?xmlMalformed=1"; setUpdateURLOverride(url); - debugDump("Update URL: " + url); errorsPrefObserver.init(PREF_APP_UPDATE_BACKGROUNDERRORS, PREF_APP_UPDATE_BACKGROUNDMAXERRORS); diff --git a/toolkit/mozapps/update/test/chrome/test_9999_cleanup.xul b/toolkit/mozapps/update/test/chrome/test_9999_cleanup.xul index 62b841e07088..955aac23d560 100644 --- a/toolkit/mozapps/update/test/chrome/test_9999_cleanup.xul +++ b/toolkit/mozapps/update/test/chrome/test_9999_cleanup.xul @@ -34,7 +34,7 @@ * happening. */ function runTest() { - ok(true, "Entering runTest - cleanup"); + debugDump("entering"); SimpleTest.waitForExplicitFinish(); @@ -74,8 +74,9 @@ function runTest() { removeDirRecursive(addonPrepDir); } catch (e) { - debugDump("removeDirRecursive failed to remove the " + ADDON_PREP_DIR + - " from the profile. " + e); + dump("Unable to remove directory\n" + + "path: " + addonPrepDir.path + "\n" + + "Exception: " + e + "\n"); } resetAddons(SimpleTest.finish); diff --git a/toolkit/mozapps/update/test/chrome/update.sjs b/toolkit/mozapps/update/test/chrome/update.sjs index 7a3a7e949838..cbede30f4712 100644 --- a/toolkit/mozapps/update/test/chrome/update.sjs +++ b/toolkit/mozapps/update/test/chrome/update.sjs @@ -1,12 +1,23 @@ -#include ../shared.js +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +/** + * Server side http server script for application update tests. + * + * !IMPORTANT - Since xpcshell used by the http server is launched with -v 170 + * this file must not use features greater than JavaScript 1.7. + */ + +const AUS_Cc = Components.classes; +const AUS_Ci = Components.interfaces; + +#include ../sharedUpdateXML.js const URL_HOST = "http://example.com/"; const URL_PATH = "chrome/toolkit/mozapps/update/test/chrome/"; const URL_UPDATE = URL_HOST + URL_PATH + "update.sjs"; -const SHA512_HASH = "1d2307e309587ddd04299423b34762639ce6af3ee17cfdaa8fdd4e6" + - "6b5a61bfb6555b6e40a82604908d6d68d3e42f318f82e22b6f5e111" + - "8b4222e3417a2fa2d0"; -const SERVICE_URL = URL_HOST + URL_PATH + "empty.mar"; +const SERVICE_URL = URL_HOST + URL_PATH + FILE_SIMPLE_MAR; const SLOW_MAR_DOWNLOAD_INTERVAL = 100; @@ -33,11 +44,11 @@ function handleRequest(aRequest, aResponse) { if (params.slowDownloadMar) { aResponse.processAsync(); aResponse.setHeader("Content-Type", "binary/octet-stream"); - aResponse.setHeader("Content-Length", "775"); + aResponse.setHeader("Content-Length", SIZE_SIMPLE_MAR); var marFile = AUS_Cc["@mozilla.org/file/directory_service;1"]. getService(AUS_Ci.nsIProperties). get("CurWorkD", AUS_Ci.nsILocalFile); - var path = URL_PATH + "empty.mar"; + var path = URL_PATH + FILE_SIMPLE_MAR; var pathParts = path.split("/"); for(var i = 0; i < pathParts.length; ++i) marFile.append(pathParts[i]); @@ -54,8 +65,9 @@ function handleRequest(aRequest, aResponse) { if (params.uiURL) { var remoteType = ""; if (!params.remoteNoTypeAttr && - (params.uiURL == "BILLBOARD" || params.uiURL == "LICENSE")) + (params.uiURL == "BILLBOARD" || params.uiURL == "LICENSE")) { remoteType = " " + params.uiURL.toLowerCase() + "=\"1\""; + } aResponse.write("" + params.uiURL + @@ -77,15 +89,15 @@ function handleRequest(aRequest, aResponse) { var hash; var patches = ""; if (!params.partialPatchOnly) { - hash = SHA512_HASH + (params.invalidCompleteHash ? "e" : ""); + hash = SHA512_HASH_SIMPLE_MAR + (params.invalidCompleteHash ? "e" : ""); patches += getRemotePatchString("complete", SERVICE_URL, "SHA512", - hash, "775"); + hash, SIZE_SIMPLE_MAR); } if (!params.completePatchOnly) { - hash = SHA512_HASH + (params.invalidPartialHash ? "e" : ""); + hash = SHA512_HASH_SIMPLE_MAR + (params.invalidPartialHash ? "e" : ""); patches += getRemotePatchString("partial", SERVICE_URL, "SHA512", - hash, "775"); + hash, SIZE_SIMPLE_MAR); } var type = params.type ? params.type : "major"; @@ -203,3 +215,31 @@ function getUpdateRDF(aParams) { " \n" + "\n"; } + +/** + * Reads the binary contents of a file and returns it as a string. + * + * @param aFile + * The file to read from. + * @return The contents of the file as a string. + */ +function readFileBytes(aFile) { + var fis = AUS_Cc["@mozilla.org/network/file-input-stream;1"]. + createInstance(AUS_Ci.nsIFileInputStream); + fis.init(aFile, -1, -1, false); + var bis = AUS_Cc["@mozilla.org/binaryinputstream;1"]. + createInstance(AUS_Ci.nsIBinaryInputStream); + bis.setInputStream(fis); + var data = []; + var count = fis.available(); + while (count > 0) { + var bytes = bis.readByteArray(Math.min(65535, count)); + data.push(String.fromCharCode.apply(null, bytes)); + count -= bytes.length; + if (bytes.length == 0) + throw "Nothing read from input stream!"; + } + data.join(''); + fis.close(); + return data.toString(); +} diff --git a/toolkit/mozapps/update/test/chrome/utils.js b/toolkit/mozapps/update/test/chrome/utils.js index 250c5e00dcd9..d3e34b2a1170 100644 --- a/toolkit/mozapps/update/test/chrome/utils.js +++ b/toolkit/mozapps/update/test/chrome/utils.js @@ -153,11 +153,17 @@ const TEST_ADDONS = [ "appdisabled_1", "appdisabled_2", "updateversion_1", "updateversion_2", "userdisabled_1", "userdisabled_2" ]; -const DEBUG = false; -const TEST_TIMEOUT = 30000; // 30 seconds +const TEST_TIMEOUT = 20000; // 20 seconds var gTimeoutTimer; +// The number of SimpleTest.executeSoon calls to perform when waiting on an +// update window to close before giving up. +const CLOSE_WINDOW_TIMEOUT_MAXCOUNT = 10; +// Counter for the SimpleTest.executeSoon when waiting on an update window to +// close before giving up. +var gCloseWindowTimeoutCounter = 0; + // The following vars are for restoring previous preference values (if present) // when the test finishes. var gAppUpdateChannel; // app.update.channel (default prefbranch) @@ -172,13 +178,12 @@ var gDocElem; var gPrefToCheck; var gDisableNoUpdateAddon = false; -#include ../shared.js +// 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 = false; -function debugDump(msg) { - if (DEBUG) { - dump("*** " + msg + "\n"); - } -} +#include ../shared.js /** * The current test in TESTS array. @@ -237,10 +242,13 @@ __defineGetter__("gIncompatibleListbox", function() { }); /** - * Default test run function that can be used by most tests. + * Default test run function that can be used by most tests. This function uses + * protective measures to prevent the test from failing provided by + * |runTestDefaultWaitForWindowClosed| helper functions to prevent failure due + * to a previous test failure. */ function runTestDefault() { - debugDump("Entering runTestDefault"); + debugDump("entering"); if (!("@mozilla.org/zipwriter;1" in AUS_Cc)) { ok(false, "nsIZipWriter is required to run these tests"); @@ -249,22 +257,53 @@ function runTestDefault() { SimpleTest.waitForExplicitFinish(); - Services.ww.registerNotification(gWindowObserver); - - setupPrefs(); - removeUpdateDirsAndFiles(); - reloadUpdateManagerData(); - setupAddons(runTest); + runTestDefaultWaitForWindowClosed(); } /** - * Default test finish function that can be used by most tests. + * If an update window is found SimpleTest.executeSoon can callback before the + * update window is fully closed especially with debug builds. If an update + * window is found this function will call itself using SimpleTest.executeSoon + * up to the amount declared in CLOSE_WINDOW_TIMEOUT_MAXCOUNT until the update + * window has closed before continuing the test. + */ +function runTestDefaultWaitForWindowClosed() { + gCloseWindowTimeoutCounter++; + if (gCloseWindowTimeoutCounter > CLOSE_WINDOW_TIMEOUT_MAXCOUNT) { + try { + finishTest(); + } + catch (e) { + finishTestDefault(); + } + return; + } + + // The update window should not be open at this time. If it is the call to + // |closeUpdateWindow| will close it and cause the test to fail. + if (closeUpdateWindow()) { + SimpleTest.executeSoon(runTestDefaultWaitForWindowClosed); + } + else { + Services.ww.registerNotification(gWindowObserver); + + gCloseWindowTimeoutCounter = 0; + + setupPrefs(); + removeUpdateDirsAndFiles(); + reloadUpdateManagerData(); + setupAddons(runTest); + } +} + +/** + * Default test finish function that can be used by most tests. This function + * uses protective measures to prevent the next test from failing provided by + * |finishTestDefaultWaitForWindowClosed| helper functions to prevent failure + * due to an update window being left open. */ function finishTestDefault() { - debugDump("Entering finishTestDefault"); - - gDocElem.removeEventListener("pageshow", onPageShowDefault, false); - + debugDump("entering"); if (gTimeoutTimer) { gTimeoutTimer.cancel(); gTimeoutTimer = null; @@ -272,12 +311,16 @@ function finishTestDefault() { verifyTestsRan(); - Services.ww.unregisterNotification(gWindowObserver); - resetPrefs(); removeUpdateDirsAndFiles(); reloadUpdateManagerData(); - SimpleTest.finish(); + + Services.ww.unregisterNotification(gWindowObserver); + if (gDocElem) { + gDocElem.removeEventListener("pageshow", onPageShowDefault, false); + } + + finishTestDefaultWaitForWindowClosed(); } /** @@ -289,10 +332,39 @@ function finishTestDefault() { * The nsITimer that fired. */ function finishTestTimeout(aTimer) { - gTimeoutTimer = null; ok(false, "Test timed out. Maximum time allowed is " + (TEST_TIMEOUT / 1000) + " seconds"); - gWin.close(); + + try { + finishTest(); + } + catch (e) { + finishTestDefault(); + } +} + +/** + * If an update window is found SimpleTest.executeSoon can callback before the + * update window is fully closed especially with debug builds. If an update + * window is found this function will call itself using SimpleTest.executeSoon + * up to the amount declared in CLOSE_WINDOW_TIMEOUT_MAXCOUNT until the update + * window has closed before finishing the test. + */ +function finishTestDefaultWaitForWindowClosed() { + gCloseWindowTimeoutCounter++; + if (gCloseWindowTimeoutCounter > CLOSE_WINDOW_TIMEOUT_MAXCOUNT) { + SimpleTest.finish(); + return; + } + + // The update window should not be open at this time. If it is the call to + // |closeUpdateWindow| will close it and cause the test to fail. + if (closeUpdateWindow()) { + SimpleTest.executeSoon(finishTestDefaultWaitForWindowClosed); + } + else { + SimpleTest.finish(); + } } /** @@ -301,12 +373,16 @@ function finishTestTimeout(aTimer) { * wizardpage. */ function onPageShowDefault(aEvent) { + if (!gTimeoutTimer) { + debugDump("gTimeoutTimer is null... returning early"); + return; + } + // Return early if the event's original target isn't for a wizardpage element. // This check is necessary due to the remotecontent element firing pageshow. if (aEvent.originalTarget.nodeName != "wizardpage") { - debugDump("onPageShowDefault - only handles events with an " + - "originalTarget nodeName of |wizardpage|. " + - "aEvent.originalTarget.nodeName = " + + debugDump("only handles events with an originalTarget nodeName of " + + "|wizardpage|. aEvent.originalTarget.nodeName = " + aEvent.originalTarget.nodeName + "... returning early"); return; } @@ -319,15 +395,19 @@ function onPageShowDefault(aEvent) { * Default callback that can be used by most tests. */ function defaultCallback(aEvent) { - debugDump("Entering defaultCallback - TESTS[" + gTestCounter + "], " + - "pageid: " + gTest.pageid + ", " + - "aEvent.originalTarget.nodeName: " + aEvent.originalTarget.nodeName); + if (!gTimeoutTimer) { + debugDump("gTimeoutTimer is null... returning early"); + return; + } + + debugDump("entering - TESTS[" + gTestCounter + "], pageid: " + gTest.pageid + + ", aEvent.originalTarget.nodeName: " + + aEvent.originalTarget.nodeName); if (gTest && gTest.extraStartFunction) { - debugDump("defaultCallback - calling extraStartFunction " + - gTest.extraStartFunction.name); + debugDump("calling extraStartFunction " + gTest.extraStartFunction.name); if (gTest.extraStartFunction(aEvent)) { - debugDump("defaultCallback - extraStartFunction early return"); + debugDump("extraStartFunction early return"); return; } } @@ -337,8 +417,7 @@ function defaultCallback(aEvent) { // Perform extra checks if specified by the test if (gTest.extraCheckFunction) { - debugDump("delayedCallback - calling extraCheckFunction " + - gTest.extraCheckFunction.name); + debugDump("calling extraCheckFunction " + gTest.extraCheckFunction.name); gTest.extraCheckFunction(); } @@ -354,8 +433,12 @@ function defaultCallback(aEvent) { * before checking their values. */ function delayedDefaultCallback() { - debugDump("Entering delayedDefaultCallback - TESTS[" + gTestCounter + "], " + - "pageid: " + gTest.pageid); + if (!gTimeoutTimer) { + debugDump("gTimeoutTimer is null... returning early"); + return; + } + + debugDump("entering - TESTS[" + gTestCounter + "], pageid: " + gTest.pageid); // Verify the pageid hasn't changed after executeSoon was called. is(gDocElem.currentPage.pageid, gTest.pageid, @@ -366,7 +449,7 @@ function delayedDefaultCallback() { // Perform delayed extra checks if specified by the test if (gTest.extraDelayedCheckFunction) { - debugDump("delayedDefaultCallback - calling extraDelayedCheckFunction " + + debugDump("calling extraDelayedCheckFunction " + gTest.extraDelayedCheckFunction.name); gTest.extraDelayedCheckFunction(); } @@ -375,15 +458,14 @@ function delayedDefaultCallback() { gTest.ranTest = true; if (gTest.buttonClick) { - debugDump("delayedDefaultCallback - clicking " + gTest.buttonClick + - " button"); + debugDump("clicking " + gTest.buttonClick + " button"); if(gTest.extraDelayedFinishFunction) { throw("Tests cannot have a buttonClick and an extraDelayedFinishFunction property"); } gDocElem.getButton(gTest.buttonClick).click(); } else if (gTest.extraDelayedFinishFunction) { - debugDump("delayedDefaultCallback - calling extraDelayedFinishFunction " + + debugDump("calling extraDelayedFinishFunction " + gTest.extraDelayedFinishFunction.name); gTest.extraDelayedFinishFunction(); } @@ -395,8 +477,7 @@ function delayedDefaultCallback() { * and hidden attribute value is true. */ function checkButtonStates() { - debugDump("Entering checkButtonStates - TESTS[" + gTestCounter + "], " + - "pageid: " + gTest.pageid); + debugDump("entering - TESTS[" + gTestCounter + "], pageid: " + gTest.pageid); const buttonNames = ["extra1", "extra2", "back", "next", "finish", "cancel"]; let buttonStates = getExpectedButtonStates(); @@ -471,8 +552,7 @@ function getExpectedButtonStates() { * Adds a load event listener to the current remotecontent element. */ function addRemoteContentLoadListener() { - debugDump("Entering addRemoteContentLoadListener - TESTS[" + gTestCounter + - "], pageid: " + gTest.pageid); + debugDump("entering - TESTS[" + gTestCounter + "], pageid: " + gTest.pageid); gRemoteContent.addEventListener("load", remoteContentLoadListener, false); } @@ -483,9 +563,8 @@ function addRemoteContentLoadListener() { function remoteContentLoadListener(aEvent) { // Return early if the event's original target's nodeName isn't remotecontent. if (aEvent.originalTarget.nodeName != "remotecontent") { - debugDump("remoteContentLoadListener - only handles events with an " + - "originalTarget nodeName of |remotecontent|. " + - "aEvent.originalTarget.nodeName = " + + debugDump("only handles events with an originalTarget nodeName of " + + "|remotecontent|. aEvent.originalTarget.nodeName = " + aEvent.originalTarget.nodeName); return; } @@ -511,7 +590,7 @@ function waitForRemoteContentLoaded(aEvent) { // expected or isn't the event's originalTarget. if (gRemoteContentState != gTest.expectedRemoteContentState || !aEvent.originalTarget.isSameNode(gRemoteContent)) { - debugDump("waitForRemoteContentLoaded - returning early\n" + + debugDump("returning early\n" + "gRemoteContentState: " + gRemoteContentState + "\n" + "expectedRemoteContentState: " + gTest.expectedRemoteContentState + "\n" + @@ -539,8 +618,7 @@ function checkRemoteContentState() { * the radio element specified in the current test's radioClick property. */ function addRadioGroupSelectListenerAndClick() { - debugDump("Entering addRadioGroupSelectListenerAndClick - TESTS[" + - gTestCounter + "], pageid: " + gTest.pageid); + debugDump("entering - TESTS[" + gTestCounter + "], pageid: " + gTest.pageid); gAcceptDeclineLicense.addEventListener("select", radioGroupSelectListener, false); @@ -553,9 +631,8 @@ function addRadioGroupSelectListenerAndClick() { function radioGroupSelectListener(aEvent) { // Return early if the event's original target's nodeName isn't radiogroup. if (aEvent.originalTarget.nodeName != "radiogroup") { - debugDump("remoteContentLoadListener - only handles events with an " + - "originalTarget nodeName of |radiogroup|. " + - "aEvent.originalTarget.nodeName = " + + debugDump("only handles events with an originalTarget nodeName of " + + "|radiogroup|. aEvent.originalTarget.nodeName = " + aEvent.originalTarget.nodeName); return; } @@ -689,7 +766,7 @@ function getNewerPlatformVersion() { * Verifies that all tests ran. */ function verifyTestsRan() { - debugDump("Entering verifyTestsRan"); + debugDump("entering"); // Return early if there are no tests defined. if (!TESTS) { @@ -716,12 +793,12 @@ function setupPrefs() { gAppUpdateChannel = gDefaultPrefBranch.getCharPref(PREF_APP_UPDATE_CHANNEL); setUpdateChannel(); - if (DEBUG) { + if (DEBUG_AUS_TEST) { Services.prefs.setBoolPref(PREF_APP_UPDATE_LOG, true) } if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_URL_OVERRIDE)) { - gAppUpdateURL = Services.prefs.setIntPref(PREF_APP_UPDATE_URL_OVERRIDE); + gAppUpdateURL = Services.prefs.getCharPref(PREF_APP_UPDATE_URL_OVERRIDE); } if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_ENABLED)) { @@ -849,7 +926,7 @@ function resetPrefs() { * A callback to call after all operations have completed. */ function setupAddons(aCallback) { - debugDump("Entering setupAddons"); + debugDump("entering"); // Sets the appropriate userDisabled value for the noupdate test add-ons based // on the value of gDisableNoUpdateAddon and calls the callback specified in @@ -871,6 +948,12 @@ function setupAddons(aCallback) { } } }); + // Start the timout timer before the update window is displayed so it can + // clean up tests that don't successfully display the update window. + gTimeoutTimer = AUS_Cc["@mozilla.org/timer;1"]. + createInstance(AUS_Ci.nsITimer); + gTimeoutTimer.initWithCallback(finishTestTimeout, TEST_TIMEOUT, + AUS_Ci.nsITimer.TYPE_ONE_SHOT); aCallback(); }); } @@ -956,13 +1039,13 @@ function setupAddons(aCallback) { * A callback to call after all operations have completed. */ function resetAddons(aCallback) { - debugDump("Entering resetAddons"); + debugDump("entering"); // If test_9999_cleanup.xul is ran by itself then the test add-ons will not // have been installed and any pre-existing add-ons will not have been // disabled so return early. if (!Services.prefs.prefHasUserValue(PREF_DISABLEDADDONS)) { - debugDump("resetAddons - preference " + PREF_DISABLEDADDONS + " doesn't " + - "exist... returning early"); + debugDump("preference " + PREF_DISABLEDADDONS + " doesn't exist... " + + "returning early"); aCallback(); return; } @@ -1102,16 +1185,20 @@ function getInstallRDFString(aName) { } /** - * Closes the update window if it is open. + * Closes the update window if it is open and causes the test to fail if an + * update window is found. + * + * @return true if an update window was found, otherwise false. */ function closeUpdateWindow() { let updateWindow = getUpdateWindow(); if (!updateWindow) - return; + return false; - ok(false, "Found an existing Update Window from a previous test... " + - "attempting to close it."); + ok(false, "Found an existing Update Window from the current or a previous " + + "test... attempting to close it."); updateWindow.close(); + return true; } /** @@ -1146,24 +1233,24 @@ var errorsPrefObserver = { this.observedPref = aObservePref; this.maxErrorPref = aMaxErrorPref; - let maxErrors = aMaxErrorCount ? aMaxErrorCount : 5; + let maxErrors = aMaxErrorCount ? aMaxErrorCount : 2; Services.prefs.setIntPref(aMaxErrorPref, maxErrors); Services.prefs.addObserver(aObservePref, this, false); }, /** - * Preference observer for the app.update.cert.errors preference. + * Preference observer for the preference specified in |this.observedPref|. */ observe: function XPI_observe(aSubject, aTopic, aData) { if (aData == this.observedPref) { let errCount = Services.prefs.getIntPref(this.observedPref); let errMax = Services.prefs.getIntPref(this.maxErrorPref); if (errCount >= errMax) { - debugDump("errorsPrefObserver - removing pref observer"); + debugDump("removing pref observer"); Services.prefs.removeObserver(this.observedPref, this); } else { - debugDump("errorsPrefObserver - notifying AUS"); + debugDump("notifying AUS"); SimpleTest.executeSoon(function() { gAUS.notify(null); }); @@ -1181,9 +1268,8 @@ var gWindowObserver = { if (aTopic == "domwindowclosed") { if (win.location != URI_UPDATE_PROMPT_DIALOG) { - debugDump("gWindowObserver:observe - domwindowclosed event for " + - "window not being tested - location: " + win.location + - "... returning early"); + debugDump("domwindowclosed event for window not being tested - " + + "location: " + win.location + "... returning early"); return; } // Allow tests the ability to provide their own function (it must be @@ -1197,13 +1283,12 @@ var gWindowObserver = { return; } - win.addEventListener("load", function onLoad() { - win.removeEventListener("load", onLoad, false); + win.addEventListener("load", function WO_observe_onLoad() { + win.removeEventListener("load", WO_observe_onLoad, false); // Ignore windows other than the update UI window. if (win.location != URI_UPDATE_PROMPT_DIALOG) { - debugDump("gWindowObserver:observe:onLoad - load event for window " + - "not being tested - location: " + win.location + - "... returning early"); + debugDump("load event for window not being tested - location: " + + win.location + "... returning early"); return; } @@ -1217,11 +1302,6 @@ var gWindowObserver = { return; } - gTimeoutTimer = AUS_Cc["@mozilla.org/timer;1"]. - createInstance(AUS_Ci.nsITimer); - gTimeoutTimer.initWithCallback(finishTestTimeout, TEST_TIMEOUT, - AUS_Ci.nsITimer.TYPE_ONE_SHOT); - gWin = win; gDocElem = gWin.document.documentElement; gDocElem.addEventListener("pageshow", onPageShowDefault, false); diff --git a/toolkit/mozapps/update/test/shared.js b/toolkit/mozapps/update/test/shared.js index 70bcc91fcee2..25ede2ed1a41 100644 --- a/toolkit/mozapps/update/test/shared.js +++ b/toolkit/mozapps/update/test/shared.js @@ -78,24 +78,18 @@ const NS_GRE_DIR = "GreD"; const NS_XPCOM_CURRENT_PROCESS_DIR = "XCurProcD"; const XRE_UPDATE_ROOT_DIR = "UpdRootD"; -const STATE_NONE = "null"; -const STATE_DOWNLOADING = "downloading"; -const STATE_PENDING = "pending"; -const STATE_APPLYING = "applying"; -const STATE_SUCCEEDED = "succeeded"; -const STATE_DOWNLOAD_FAILED = "download-failed"; -const STATE_FAILED = "failed"; - const CRC_ERROR = 4; const WRITE_ERROR = 7; const FILE_BACKUP_LOG = "backup-update.log"; const FILE_LAST_LOG = "last-update.log"; +const FILE_UPDATER_INI = "updater.ini"; const FILE_UPDATES_DB = "updates.xml"; const FILE_UPDATE_ACTIVE = "active-update.xml"; const FILE_UPDATE_ARCHIVE = "update.mar"; const FILE_UPDATE_LOG = "update.log"; const FILE_UPDATE_STATUS = "update.status"; +const FILE_UPDATE_VERSION = "update.version"; const MODE_RDONLY = 0x01; const MODE_WRONLY = 0x02; @@ -113,48 +107,42 @@ const PR_EXCL = 0x80; const PERMS_FILE = 0644; const PERMS_DIRECTORY = 0755; +#include sharedUpdateXML.js + AUS_Cu.import("resource://gre/modules/Services.jsm"); AUS_Cu.import("resource://gre/modules/XPCOMUtils.jsm"); const URI_UPDATES_PROPERTIES = "chrome://mozapps/locale/update/updates.properties"; const gUpdateBundle = Services.strings.createBundle(URI_UPDATES_PROPERTIES); - -__defineGetter__("gAUS", function() { - delete this.gAUS; - return this.gAUS = AUS_Cc["@mozilla.org/updates/update-service;1"]. - getService(AUS_Ci.nsIApplicationUpdateService). - QueryInterface(AUS_Ci.nsITimerCallback). - QueryInterface(AUS_Ci.nsIObserver); +XPCOMUtils.defineLazyGetter(this, "gAUS", function test_gAUS() { + return AUS_Cc["@mozilla.org/updates/update-service;1"]. + getService(AUS_Ci.nsIApplicationUpdateService). + QueryInterface(AUS_Ci.nsITimerCallback). + QueryInterface(AUS_Ci.nsIObserver); }); -__defineGetter__("gUpdateManager", function() { - delete this.gUpdateManager; - return this.gUpdateManager = AUS_Cc["@mozilla.org/updates/update-manager;1"]. - getService(AUS_Ci.nsIUpdateManager); +XPCOMUtils.defineLazyServiceGetter(this, "gUpdateManager", + "@mozilla.org/updates/update-manager;1", + "nsIUpdateManager"); + +XPCOMUtils.defineLazyGetter(this, "gUpdateChecker", function test_gUC() { + return AUS_Cc["@mozilla.org/updates/update-checker;1"]. + createInstance(AUS_Ci.nsIUpdateChecker); }); -__defineGetter__("gUpdateChecker", function() { - delete this.gUpdateChecker; - return this.gUpdateChecker = AUS_Cc["@mozilla.org/updates/update-checker;1"]. - createInstance(AUS_Ci.nsIUpdateChecker); +XPCOMUtils.defineLazyGetter(this, "gUP", function test_gUP() { + return AUS_Cc["@mozilla.org/updates/update-prompt;1"]. + createInstance(AUS_Ci.nsIUpdatePrompt); }); -__defineGetter__("gUP", function() { - delete this.gUP; - return this.gUP = AUS_Cc["@mozilla.org/updates/update-prompt;1"]. - createInstance(AUS_Ci.nsIUpdatePrompt); +XPCOMUtils.defineLazyGetter(this, "gDefaultPrefBranch", function test_gDPB() { + return Services.prefs.getDefaultBranch(null); }); -__defineGetter__("gDefaultPrefBranch", function() { - delete this.gDefaultPrefBranch; - return this.gDefaultPrefBranch = Services.prefs.getDefaultBranch(null); -}); - -__defineGetter__("gZipW", function() { - delete this.gZipW; - return this.gZipW = AUS_Cc["@mozilla.org/zipwriter;1"]. - createInstance(AUS_Ci.nsIZipWriter); +XPCOMUtils.defineLazyGetter(this, "gZipW", function test_gZipW() { + return AUS_Cc["@mozilla.org/zipwriter;1"]. + createInstance(AUS_Ci.nsIZipWriter); }); /* Initializes the update service stub */ @@ -175,8 +163,9 @@ function reloadUpdateManagerData() { * The update channel. If not specified 'test_channel' will be used. */ function setUpdateChannel(aChannel) { - gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_CHANNEL, - aChannel ? aChannel : "test_channel"); + let channel = aChannel ? aChannel : "test_channel"; + debugDump("setting default pref " + PREF_APP_UPDATE_CHANNEL + " to " + channel); + gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_CHANNEL, channel); } /** @@ -186,292 +175,9 @@ function setUpdateChannel(aChannel) { * used. */ function setUpdateURLOverride(aURL) { - Services.prefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, - aURL ? aURL : URL_HOST + "update.xml"); -} - -/** - * Constructs a string representing a remote update xml file. - * @param aUpdates - * The string representing the update elements. - * @returns The string representing a remote update xml file. - */ -function getRemoteUpdatesXMLString(aUpdates) { - return "\n" + - "\n" + - aUpdates + - "\n"; -} - -/** - * Constructs a string representing an update element for a remote update xml - * file. - * See getUpdateString - * @returns The string representing an update element for an update xml file. - */ -function getRemoteUpdateString(aPatches, aType, aName, aDisplayVersion, - aAppVersion, aPlatformVersion, aBuildID, - aDetailsURL, aBillboardURL, aLicenseURL, - aShowPrompt, aShowNeverForVersion, aShowSurvey, - aVersion, aExtensionVersion, aCustom1, - aCustom2) { - return getUpdateString(aType, aName, aDisplayVersion, aAppVersion, - aPlatformVersion, aBuildID, aDetailsURL, - aBillboardURL, aLicenseURL, aShowPrompt, - aShowNeverForVersion, aShowSurvey, aVersion, - aExtensionVersion, aCustom1, aCustom2) + ">\n" + - aPatches + - " \n"; -} - -/** - * Constructs a string representing a patch element for a remote update xml - * file - * See getPatchString - * @returns The string representing a patch element for a remote update xml - * file. - */ -function getRemotePatchString(aType, aURL, aHashFunction, aHashValue, aSize) { - return getPatchString(aType, aURL, aHashFunction, aHashValue, aSize) + - "/>\n"; -} - -/** - * Constructs a string representing a local update xml file. - * @param aUpdates - * The string representing the update elements. - * @returns The string representing a local update xml file. - */ -function getLocalUpdatesXMLString(aUpdates) { - if (!aUpdates || aUpdates == "") - return "" - return ("" + - aUpdates + - "").replace(/>\s+\n*<'); -} - -/** - * Constructs a string representing an update element for a local update xml - * file. - * See getUpdateString - * @param aServiceURL - * The update's xml url. - * If null will default to 'http://test_service/'. - * @param aIsCompleteUpdate - * The string 'true' if this update was a complete update or the string - * 'false' if this update was a partial update. - * If null will default to 'true'. - * @param aChannel - * The update channel name. - * If null will default to 'test_channel'. - * @param aForegroundDownload - * The string 'true' if this update was manually downloaded or the - * string 'false' if this update was automatically downloaded. - * If null will default to 'true'. - * @param aPreviousAppVersion - * The application version prior to applying the update. - * If null will not be present. - * @returns The string representing an update element for an update xml file. - */ -function getLocalUpdateString(aPatches, aType, aName, aDisplayVersion, - aAppVersion, aPlatformVersion, aBuildID, - aDetailsURL, aBillboardURL, aLicenseURL, - aServiceURL, aInstallDate, aStatusText, - aIsCompleteUpdate, aChannel, aForegroundDownload, - aShowPrompt, aShowNeverForVersion, aShowSurvey, - aVersion, aExtensionVersion, aPreviousAppVersion, - aCustom1, aCustom2) { - var serviceURL = aServiceURL ? aServiceURL : "http://test_service/"; - var installDate = aInstallDate ? aInstallDate : "1238441400314"; - var statusText = aStatusText ? aStatusText : "Install Pending"; - var isCompleteUpdate = typeof(aIsCompleteUpdate) == "string" ? aIsCompleteUpdate : "true"; - var channel = aChannel ? aChannel : "test_channel"; - var foregroundDownload = - typeof(aForegroundDownload) == "string" ? aForegroundDownload : "true"; - var previousAppVersion = aPreviousAppVersion ? "previousAppVersion=\"" + aPreviousAppVersion + "\" " : ""; - return getUpdateString(aType, aName, aDisplayVersion, aAppVersion, - aPlatformVersion, aBuildID, aDetailsURL, aBillboardURL, - aLicenseURL, aShowPrompt, aShowNeverForVersion, - aShowSurvey, aVersion, aExtensionVersion, aCustom1, - aCustom2) + - " " + - previousAppVersion + - "serviceURL=\"" + serviceURL + "\" " + - "installDate=\"" + installDate + "\" " + - "statusText=\"" + statusText + "\" " + - "isCompleteUpdate=\"" + isCompleteUpdate + "\" " + - "channel=\"" + channel + "\" " + - "foregroundDownload=\"" + foregroundDownload + "\">" + - aPatches + - " "; -} - -/** - * Constructs a string representing a patch element for a local update xml file. - * See getPatchString - * @param aSelected - * Whether this patch is selected represented or not. The string 'true' - * denotes selected and the string 'false' denotes not selected. - * If null will default to the string 'true'. - * @param aState - * The patch's state. - * If null will default to STATE_SUCCEEDED (e.g. 'succeeded'). - * @returns The string representing a patch element for a local update xml file. - */ -function getLocalPatchString(aType, aURL, aHashFunction, aHashValue, aSize, - aSelected, aState) { - var selected = typeof(aSelected) == "string" ? aSelected : "true"; - var state = aState ? aState : STATE_SUCCEEDED; - return getPatchString(aType, aURL, aHashFunction, aHashValue, aSize) + " " + - "selected=\"" + selected + "\" " + - "state=\"" + state + "\"/>\n"; -} - -/** - * Constructs a string representing an update element for a remote update xml - * file. - * @param aType - * The update's type which should be major or minor. - * If null will default to 'major'. - * @param aName - * The update's name. - * If null will default to 'App Update Test'. - * @param aDisplayVersion - * The update's display version. - * If null will default to 'version 99.0'. - * @param aAppVersion - * The update's application version. - * If null will default to '99.0'. - * @param aPlatformVersion - * The update's platform version. - * If null will default to '99.0'. - * @param aBuildID - * The update's build id. - * If null will default to '20080811053724'. - * @param aDetailsURL - * The update's details url. - * If null will default to 'http://test_details/' due to due to - * bug 470244. - * @param aBillboardURL - * The update's billboard url. - * If null it will not be added. - * @param aLicenseURL - * The update's license url. - * If null will not be added. - * @param aShowPrompt - * Whether to show the prompt for the update when auto update is - * enabled. - * If null will not be added and the backend will default to false. - * @param aShowNeverForVersion - * Whether to show the 'No Thanks' button in the update prompt. - * If null will not be added and the backend will default to false. - * @param aShowSurvey - * Whether to show the 'No Thanks' button in the update prompt. - * If null will not be added and the backend will default to false. - * @param aVersion - * The update's application version from 1.9.2. - * If null will not be present. - * @param aExtensionVersion - * The update's application version from 1.9.2. - * If null will not be present. - * @param aCustom1 - * A custom attribute name AND attribute value to add to the xml. - * Example: custom1_attribute="custom1 value" - * If null will not be present. - * @param aCustom2 - * A custom attribute name AND attribute value to add to the xml. - * Example: custom2_attribute="custom2 value" - * If null will not be present. - * @returns The string representing an update element for an update xml file. - */ -function getUpdateString(aType, aName, aDisplayVersion, aAppVersion, - aPlatformVersion, aBuildID, aDetailsURL, aBillboardURL, - aLicenseURL, aShowPrompt, aShowNeverForVersion, - aShowSurvey, aVersion, aExtensionVersion, aCustom1, - aCustom2) { - var type = aType ? aType : "major"; - var name = aName ? aName : "App Update Test"; - var displayVersion = ""; - if (aDisplayVersion || !aVersion) { - displayVersion = "displayVersion=\"" + - (aDisplayVersion ? aDisplayVersion - : "version 99.0") + "\" "; - } - // version has been deprecated in favor of displayVersion but it still needs - // to be tested for forward compatibility. - var version = aVersion ? "version=\"" + aVersion + "\" " : ""; - var appVersion = ""; - if (aAppVersion || !aExtensionVersion) { - appVersion = "appVersion=\"" + (aAppVersion ? aAppVersion : "99.0") + "\" "; - } - // extensionVersion has been deprecated in favor of appVersion but it still - // needs to be tested for forward compatibility. - var extensionVersion = aExtensionVersion ? "extensionVersion=\"" + aExtensionVersion + "\" " : ""; - var platformVersion = ""; - if (aPlatformVersion) { - platformVersion = "platformVersion=\"" + (aPlatformVersion ? aPlatformVersion : "99.0") + "\" "; - } - var buildID = aBuildID ? aBuildID : "20080811053724"; - // XXXrstrong - not specifying a detailsURL will cause a leak due to bug 470244 -// var detailsURL = aDetailsURL ? "detailsURL=\"" + aDetailsURL + "\" " : ""; - var detailsURL = "detailsURL=\"" + (aDetailsURL ? aDetailsURL : "http://test_details/") + "\" "; - var billboardURL = aBillboardURL ? "billboardURL=\"" + aBillboardURL + "\" " : ""; - var licenseURL = aLicenseURL ? "licenseURL=\"" + aLicenseURL + "\" " : ""; - var showPrompt = aShowPrompt ? "showPrompt=\"" + aShowPrompt + "\" " : ""; - var showNeverForVersion = aShowNeverForVersion ? "showNeverForVersion=\"" + aShowNeverForVersion + "\" " : ""; - var showSurvey = aShowSurvey ? "showSurvey=\"" + aShowSurvey + "\" " : ""; - var custom1 = aCustom1 ? aCustom1 + " " : ""; - var custom2 = aCustom2 ? aCustom2 + " " : ""; - return " 0) { - var bytes = bis.readByteArray(Math.min(65535, count)); - data.push(String.fromCharCode.apply(null, bytes)); - count -= bytes.length; - if (bytes.length == 0) - do_throw("Nothing read from input stream!"); - } + var bis = AUS_Cc["@mozilla.org/binaryinputstream;1"]. + createInstance(AUS_Ci.nsIBinaryInputStream); + bis.setInputStream(fis); + var data = []; + var count = fis.available(); + while (count > 0) { + var bytes = bis.readByteArray(Math.min(65535, count)); + data.push(String.fromCharCode.apply(null, bytes)); + count -= bytes.length; + if (bytes.length == 0) + do_throw("Nothing read from input stream!"); + } data.join(''); fis.close(); return data.toString(); @@ -737,3 +479,32 @@ function getCurrentProcessDir() { function getGREDir() { return Services.dirsvc.get(NS_GRE_DIR, AUS_Ci.nsIFile); } + +/** + * Logs TEST-INFO messages. + * @param aText + * The text to log. + * @param aCaller (optional) + * An optional Components.stack.caller. If not specified + * Components.stack.caller will be used. + */ +function logTestInfo(aText, aCaller) { + let caller = (aCaller ? aCaller : Components.stack.caller); + dump("TEST-INFO | " + caller.filename + " | [" + caller.name + " : " + + caller.lineNumber + "] " + aText + "\n"); +} + +/** + * Logs TEST-INFO messages when DEBUG_AUS_TEST evaluates to true. + * @param aText + * The text to log. + * @param aCaller (optional) + * An optional Components.stack.caller. If not specified + * Components.stack.caller will be used. + */ +function debugDump(aText, aCaller) { + if (DEBUG_AUS_TEST) { + let caller = aCaller ? aCaller : Components.stack.caller; + logTestInfo(aText, caller); + } +} diff --git a/toolkit/mozapps/update/test/sharedUpdateXML.js b/toolkit/mozapps/update/test/sharedUpdateXML.js new file mode 100644 index 000000000000..b34892653158 --- /dev/null +++ b/toolkit/mozapps/update/test/sharedUpdateXML.js @@ -0,0 +1,343 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +/** + * 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 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" + + "846e350232945dbad2b0c83208a07810cf798b3d11393" + + "99c453"; +const SHA512_HASH_SIMPLE_MAR = "55d3e2a86acaeb0abb7a444c13bba748846fcbac7ff05" + + "8f8ee9c9260ba01e6aef86fa4a6c46a3016b675ef94e7" + + "7e63fbe912f64d155bed9b1c341dd56e575a26"; + +const STATE_NONE = "null"; +const STATE_DOWNLOADING = "downloading"; +const STATE_PENDING = "pending"; +const STATE_APPLYING = "applying"; +const STATE_SUCCEEDED = "succeeded"; +const STATE_DOWNLOAD_FAILED = "download-failed"; +const STATE_FAILED = "failed"; + +/** + * Constructs a string representing a remote update xml file. + * + * @param aUpdates + * The string representing the update elements. + * @return The string representing a remote update xml file. + */ +function getRemoteUpdatesXMLString(aUpdates) { + return "\n" + + "\n" + + aUpdates + + "\n"; +} + +/** + * Constructs a string representing an update element for a remote update xml + * file. See getUpdateString for parameter information not provided below. + * + * @param aPatches + * String representing the application update patches. + * @return The string representing an update element for an update xml file. + */ +function getRemoteUpdateString(aPatches, aType, aName, aDisplayVersion, + aAppVersion, aPlatformVersion, aBuildID, + aDetailsURL, aBillboardURL, aLicenseURL, + aShowPrompt, aShowNeverForVersion, aShowSurvey, + aVersion, aExtensionVersion, aCustom1, + aCustom2) { + return getUpdateString(aType, aName, aDisplayVersion, aAppVersion, + aPlatformVersion, aBuildID, aDetailsURL, + aBillboardURL, aLicenseURL, aShowPrompt, + aShowNeverForVersion, aShowSurvey, aVersion, + aExtensionVersion, aCustom1, aCustom2) + ">\n" + + aPatches + + " \n"; +} + +/** + * Constructs a string representing a patch element for a remote update xml + * file. See getPatchString for parameter information not provided below. + * + * @return The string representing a patch element for a remote update xml file. + */ +function getRemotePatchString(aType, aURL, aHashFunction, aHashValue, aSize) { + return getPatchString(aType, aURL, aHashFunction, aHashValue, aSize) + + "/>\n"; +} + +/** + * Constructs a string representing a local update xml file. + * + * @param aUpdates + * The string representing the update elements. + * @return The string representing a local update xml file. + */ +function getLocalUpdatesXMLString(aUpdates) { + if (!aUpdates || aUpdates == "") + return "" + return ("" + + aUpdates + + "").replace(/>\s+\n*<'); +} + +/** + * Constructs a string representing an update element for a local update xml + * file. See getUpdateString for parameter information not provided below. + * + * @param aPatches + * String representing the application update patches. + * @param aServiceURL (optional) + * The update's xml url. + * If not specified it will default to 'http://test_service/'. + * @param aIsCompleteUpdate (optional) + * The string 'true' if this update was a complete update or the string + * 'false' if this update was a partial update. + * If not specified it will default to 'true'. + * @param aChannel (optional) + * The update channel name. + * If not specified it will default to 'test_channel'. + * @param aForegroundDownload (optional) + * The string 'true' if this update was manually downloaded or the + * string 'false' if this update was automatically downloaded. + * If not specified it will default to 'true'. + * @param aPreviousAppVersion (optional) + * The application version prior to applying the update. + * If not specified it will not be present. + * @return The string representing an update element for an update xml file. + */ +function getLocalUpdateString(aPatches, aType, aName, aDisplayVersion, + aAppVersion, aPlatformVersion, aBuildID, + aDetailsURL, aBillboardURL, aLicenseURL, + aServiceURL, aInstallDate, aStatusText, + aIsCompleteUpdate, aChannel, aForegroundDownload, + aShowPrompt, aShowNeverForVersion, aShowSurvey, + aVersion, aExtensionVersion, aPreviousAppVersion, + aCustom1, aCustom2) { + let serviceURL = aServiceURL ? aServiceURL : "http://test_service/"; + let installDate = aInstallDate ? aInstallDate : "1238441400314"; + let statusText = aStatusText ? aStatusText : "Install Pending"; + let isCompleteUpdate = + typeof(aIsCompleteUpdate) == "string" ? aIsCompleteUpdate : "true"; + let channel = aChannel ? aChannel : "test_channel"; + let foregroundDownload = + typeof(aForegroundDownload) == "string" ? aForegroundDownload : "true"; + let previousAppVersion = aPreviousAppVersion ? "previousAppVersion=\"" + + aPreviousAppVersion + "\" " + : ""; + return getUpdateString(aType, aName, aDisplayVersion, aAppVersion, + aPlatformVersion, aBuildID, aDetailsURL, aBillboardURL, + aLicenseURL, aShowPrompt, aShowNeverForVersion, + aShowSurvey, aVersion, aExtensionVersion, aCustom1, + aCustom2) + + " " + + previousAppVersion + + "serviceURL=\"" + serviceURL + "\" " + + "installDate=\"" + installDate + "\" " + + "statusText=\"" + statusText + "\" " + + "isCompleteUpdate=\"" + isCompleteUpdate + "\" " + + "channel=\"" + channel + "\" " + + "foregroundDownload=\"" + foregroundDownload + "\">" + + aPatches + + " "; +} + +/** + * Constructs a string representing a patch element for a local update xml file. + * See getPatchString for parameter information not provided below. + * + * @param aSelected (optional) + * Whether this patch is selected represented or not. The string 'true' + * denotes selected and the string 'false' denotes not selected. + * If not specified it will default to the string 'true'. + * @param aState (optional) + * The patch's state. + * If not specified it will default to STATE_SUCCEEDED. + * @return The string representing a patch element for a local update xml file. + */ +function getLocalPatchString(aType, aURL, aHashFunction, aHashValue, aSize, + aSelected, aState) { + let selected = typeof(aSelected) == "string" ? aSelected : "true"; + let state = aState ? aState : STATE_SUCCEEDED; + return getPatchString(aType, aURL, aHashFunction, aHashValue, aSize) + " " + + "selected=\"" + selected + "\" " + + "state=\"" + state + "\"/>\n"; +} + +/** + * Constructs a string representing an update element for a remote update xml + * file. + * + * @param aType (optional) + * The update's type which should be major or minor. If not specified it + * will default to 'major'. + * @param aName (optional) + * The update's name. + * If not specified it will default to 'App Update Test'. + * @param aDisplayVersion (optional) + * The update's display version. + * If not specified it will default to 'version 99.0'. + * @param aAppVersion (optional) + * The update's application version. + * If not specified it will default to '99.0'. + * @param aPlatformVersion (optional) + * The update's platform version. + * If not specified it will default to '99.0'. + * @param aBuildID (optional) + * The update's build id. + * If not specified it will default to '20080811053724'. + * @param aDetailsURL (optional) + * The update's details url. + * If not specified it will default to 'http://test_details/' due to due + * to bug 470244. + * @param aBillboardURL (optional) + * The update's billboard url. + * If not specified it will not be present. + * @param aLicenseURL (optional) + * The update's license url. + * If not specified it will not be present. + * @param aShowPrompt (optional) + * Whether to show the prompt for the update when auto update is + * enabled. + * If not specified it will not be present and the update service will + * default to false. + * @param aShowNeverForVersion (optional) + * Whether to show the 'No Thanks' button in the update prompt. + * If not specified it will not be present and the update service will + * default to false. + * @param aShowSurvey (optional) + * Whether to show the 'No Thanks' button in the update prompt. + * If not specified it will not be present and the update service will + * default to false. + * @param aVersion (optional) + * The update's application version from 1.9.2. + * If not specified it will not be present. + * @param aExtensionVersion (optional) + * The update's application version from 1.9.2. + * If not specified it will not be present. + * @param aCustom1 (optional) + * A custom attribute name and attribute value to add to the xml. + * Example: custom1_attribute="custom1 value" + * If not specified it will not be present. + * @param aCustom2 (optional) + * A custom attribute name and attribute value to add to the xml. + * Example: custom2_attribute="custom2 value" + * If not specified it will not be present. + * @return The string representing an update element for an update xml file. + */ +function getUpdateString(aType, aName, aDisplayVersion, aAppVersion, + aPlatformVersion, aBuildID, aDetailsURL, aBillboardURL, + aLicenseURL, aShowPrompt, aShowNeverForVersion, + aShowSurvey, aVersion, aExtensionVersion, aCustom1, + aCustom2) { + let type = aType ? aType : "major"; + let name = aName ? aName : "App Update Test"; + let displayVersion = ""; + if (aDisplayVersion || !aVersion) { + displayVersion = "displayVersion=\"" + + (aDisplayVersion ? aDisplayVersion + : "version 99.0") + "\" "; + } + // version has been deprecated in favor of displayVersion but it still needs + // to be tested for forward compatibility. + let version = aVersion ? "version=\"" + aVersion + "\" " : ""; + let appVersion = ""; + if (aAppVersion || !aExtensionVersion) { + appVersion = "appVersion=\"" + (aAppVersion ? aAppVersion : "99.0") + "\" "; + } + // extensionVersion has been deprecated in favor of appVersion but it still + // needs to be tested for forward compatibility. + let extensionVersion = aExtensionVersion ? "extensionVersion=\"" + + aExtensionVersion + "\" " + : ""; + let platformVersion = ""; + if (aPlatformVersion) { + platformVersion = "platformVersion=\"" + + (aPlatformVersion ? aPlatformVersion : "99.0") + "\" "; + } + let buildID = aBuildID ? aBuildID : "20080811053724"; + // XXXrstrong - not specifying a detailsURL will cause a leak due to bug 470244 +// let detailsURL = aDetailsURL ? "detailsURL=\"" + aDetailsURL + "\" " : ""; + let detailsURL = "detailsURL=\"" + + (aDetailsURL ? aDetailsURL + : "http://test_details/") + "\" "; + let billboardURL = aBillboardURL ? "billboardURL=\"" + + aBillboardURL + "\" " + : ""; + let licenseURL = aLicenseURL ? "licenseURL=\"" + aLicenseURL + "\" " : ""; + let showPrompt = aShowPrompt ? "showPrompt=\"" + aShowPrompt + "\" " : ""; + let showNeverForVersion = aShowNeverForVersion ? "showNeverForVersion=\"" + + aShowNeverForVersion + "\" " + : ""; + let showSurvey = aShowSurvey ? "showSurvey=\"" + aShowSurvey + "\" " : ""; + let custom1 = aCustom1 ? aCustom1 + " " : ""; + let custom2 = aCustom2 ? aCustom2 + " " : ""; + return " KmY&wPy;!o z;OGZN87g@}>M}h94XK3C(X{J*NlxW(XpwmNX2c&@{wh1NO$AX9+>>l@qD)!PL&hmX|Tg4X+ zTtxasyp6W%aN)ad$B;=a9hNc_at)L02*UxovL(B^4%$VHA}kr>8#7by zk0fh$4Xfv})Z zga~dXmBD|82A95FFdQM)l$i-(xBM#kz8v^6goYCil^2_SLgHRz6TI}I<|HK#p;eJmp!y15Q}S&1P>E=Kt-sdFLC6oBN!DJM$znKz_u10BCE{Q zZg=uC_XHhUIX=V71}H9|_rqX8fyf_ecR_MF1mSX0AYM=g2L?vGG*dK%-a%Nwzrw3# zCW7!TGGMftyvs#i!xI6aC(~6#?7nC>g&LZVQglcL76>h{8H-t@)i;%!SxBgwFe6!^ zf~L8|DVf}E4F<8=Uudhw2X!SaG9RX)Zwl2j9XRb?`bo4StX7-tDuN{<2!9%ug5aDD zfNzP%VOHD*@#A%FX!qDwFclm?gFarTF$8IZHYUb2&=COw8ZZ|dS%Z~MniVuDuTcBqO25CBOgx02}}S00;m80^a}t0k(B;WMOn=E^T3MX=Y_} FbO3%kSM70Za=S#2A*V-Dgl>2r*mH=GfWs z)reDQ-U7x27o0AKow~K=gPIZ#+j>=vQdgdTZz>l4b~jqHI`y@Pon*@X*@~@&2?r;C zELRC`hvkGNn`*&2y^M$@#*(Yx>bU z6a7R~G!0~yGa$646!`vTVBiNikAa~P=)7fW=Yg6PSH5DLxNyQUAD?Dr;Ulv|WqHLp zLM!HGENFOm&ra`2SHVJs6Axy819~+Fh&g~bg@J)_TWLW`Vo9oAZem_$T553#P#7$4 tjgX5k0gCH~g4KlpnT{zbZkai$AeGC3*aKZ pipes stdout to a file. + * appConsoleLogPath is the file path to pipe the output from the shell. + * Otherwise the output from the application will end up in the xpchsell log. + * 2>&1 pipes stderr to sdout. + */ +function getProcessArgs() { + let appBinPath = getAppBinPath(); + + // Pipe the output from the launched application to a file so the output from + // its console isn't present in the xpcshell log. + let appConsoleLogPath = getAppConsoleLogPath(); + + let args; + if (IS_UNIX) { + let launchScript = getLaunchScript(); + // Precreate the script with executable permissions + launchScript.create(AUS_Ci.nsILocalFile.NORMAL_FILE_TYPE, PERMS_DIRECTORY); + + let scriptContents = "#! /bin/sh\n"; + // On Mac OS X versions prior to 10.6 the i386 acrhitecture must be used. + if (gIsLessThanMacOSX_10_6) { + scriptContents += "arch -arch i386 "; + } + scriptContents += appBinPath + " -no-remote -process-updates 1> " + + appConsoleLogPath + " 2>&1"; + writeFile(launchScript, scriptContents); + logTestInfo("created " + launchScript.path + " containing:\n" + + scriptContents); + args = [launchScript.path]; + } + else { + args = ["/D", "/Q", "/C", appBinPath, "-no-remote", "-process-updates", + "1>", appConsoleLogPath, "2>&1"]; + } + return args; +} + +/** + * Gets the directory where the update adds / removes the files contained in the + * update. + * + * @return nsIFile for the directory where the update adds / removes the files + * contained in the update mar. + */ +function getUpdateTestDir() { + let updateTestDir = getCurrentProcessDir(); + if (IS_MACOSX) { + updateTestDir = updateTestDir.parent.parent; + } + updateTestDir.append("update_test"); + return updateTestDir; +} + +/** + * Gets a file path for piping the console output from the application so it + * doesn't appear in the xpcshell log file. + * + * @return path to the file for piping the console output from the application. + */ +function getAppConsoleLogPath() { + let appConsoleLog = do_get_file("/", true); + appConsoleLog.append("app_console_log"); + if (appConsoleLog.exists()) { + appConsoleLog.remove(false); + } + let appConsoleLogPath = appConsoleLog.path; + if (/ /.test(appConsoleLogPath)) { + appConsoleLogPath = '"' + appConsoleLogPath + '"'; + } + return appConsoleLogPath; +} + +/** + * Gets the nsIFile references for the shell script to retrieve the Mac OS X + * version and the nsIFile to pipe the output of the shell script. If either of + * these files exist they will be removed by this function. + * + * @return array containing two nsIFile references. The first array member is + * the nsIFile for the shell script to launch to get the Mac OS X + * version and the second array member is the nsIFile for the piped + * output from the shell script. + */ +function getVersionScriptAndFile() { + let versionScript = do_get_file("/", true); + let versionFile = versionScript.clone(); + versionScript.append("get_version.sh"); + if (versionScript.exists()) { + versionScript.remove(false); + } + versionFile.append("version.out"); + if (versionFile.exists()) { + versionFile.remove(false); + } + return [versionScript, versionFile]; +} + +/** + * Gets the nsIFile reference for the shell script to launch the application. If + * the file exists it will be removed by this function. + * + * @return the nsIFile for the shell script to launch the application. + */ +function getLaunchScript() { + let launchScript = do_get_file("/", true); + launchScript.append("launch.sh"); + if (launchScript.exists()) { + launchScript.remove(false); + } + return launchScript; +} + +/** + * Checks if the update has finished and if it has finished performs checks for + * the test. + */ +function checkUpdateFinished() { + // Don't proceed until the update.log has been created. + let log = getUpdatesDir(); + log.append("0"); + log.append(FILE_UPDATE_LOG); + if (!log.exists()) { + do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished); + return; + } + + // Don't proceed until the update status is no longer pending or applying. + let status = readStatusFile(); + if (status == STATE_PENDING || status == STATE_APPLYING) { + do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished); + return; + } + + // Log the contents of the update.log so it is simpler to diagnose a test + // failure. For example, on Windows if the application binary is in use the + // updater will not apply the update. + let contents = readFile(log); + logTestInfo("contents of " + log.path + ":\n" + + contents.replace(/\r\n/g, "\n")); + + if (IS_WIN && contents.indexOf("NS_main: file in use") != -1) { + do_throw("the application can't be in use when running this test"); + } + + do_check_eq(status, STATE_SUCCEEDED); + + standardInit(); + + let update = gUpdateManager.getUpdateAt(0); + do_check_eq(update.state, STATE_SUCCEEDED); + + let updateTestDir = getUpdateTestDir(); + + let file = updateTestDir.clone(); + file.append("UpdateTestRemoveFile"); + do_check_false(file.exists()); + + file = updateTestDir.clone(); + file.append("UpdateTestAddFile"); + do_check_true(file.exists()); + do_check_eq(readFileBytes(file), "UpdateTestAddFile\n"); + + file = updateTestDir.clone(); + file.append("removed-files"); + do_check_true(file.exists()); + do_check_eq(readFileBytes(file), "update_test/UpdateTestRemoveFile\n"); + + let updatesDir = getUpdatesDir(); + let log = updatesDir.clone(); + log.append("0"); + log.append(FILE_UPDATE_LOG); + logTestInfo("testing " + log.path + " shouldn't exist"); + do_check_false(log.exists()); + + log = updatesDir.clone(); + log.append(FILE_LAST_LOG); + logTestInfo("testing " + log.path + " should exist"); + do_check_true(log.exists()); + + log = updatesDir.clone(); + log.append(FILE_BACKUP_LOG); + logTestInfo("testing " + log.path + " shouldn't exist"); + do_check_false(log.exists()); + + updatesDir.append("0"); + logTestInfo("testing " + updatesDir.path + " should exist"); + do_check_true(updatesDir.exists()); + + do_timeout(CHECK_TIMEOUT_MILLI, do_test_finished); +} diff --git a/toolkit/mozapps/update/test/unit/test_bug497578.js b/toolkit/mozapps/update/test/unit/test_bug497578.js index 21e29ba9464b..dff013893508 100644 --- a/toolkit/mozapps/update/test/unit/test_bug497578.js +++ b/toolkit/mozapps/update/test/unit/test_bug497578.js @@ -49,9 +49,11 @@ function run_test() { return; do_test_pending(); - dump("Testing: Bug 497578 - begin download of a complete update after a " + - "failure to apply a partial update with " + - "browser.privatebrowsing.autostart set to true\n"); + do_register_cleanup(end_test); + + logTestInfo("testing Bug 497578 - begin download of a complete update " + + "after a failure to apply a partial update with " + + "browser.privatebrowsing.autostart set to true"); removeUpdateDirsAndFiles(); setUpdateChannel(); @@ -74,7 +76,6 @@ function end_test() { let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar); registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"), WindowWatcherFactory); - do_test_finished(); cleanUp(); } @@ -92,8 +93,8 @@ function run_test_pt1() { standardInit(); - dump("Testing: activeUpdate.state should equal STATE_DOWNLOADING prior to " + - "entering private browsing\n"); + logTestInfo("testing activeUpdate.state should equal STATE_DOWNLOADING " + + "prior to entering private browsing"); do_check_eq(gUpdateManager.activeUpdate.state, STATE_DOWNLOADING); let privBrowsing = AUS_Cc[PRIVATEBROWSING_CONTRACT_ID]. @@ -101,25 +102,26 @@ function run_test_pt1() { QueryInterface(AUS_Ci.nsIObserver); privBrowsing.observe(null, "profile-after-change", ""); - dump("Testing: private mode should be entered automatically\n"); + logTestInfo("Testing: private mode should be entered automatically"); do_check_true(privBrowsing.privateBrowsingEnabled); - dump("Testing: private browsing is auto-started\n"); + logTestInfo("Testing: private browsing is auto-started"); do_check_true(privBrowsing.autoStarted); // Give private browsing time to reset necko. do_execute_soon(run_test_pt2); } function run_test_pt2() { - dump("Testing: update count should equal 1\n"); + logTestInfo("Testing: update count should equal 1"); do_check_eq(gUpdateManager.updateCount, 1); - dump("Testing: activeUpdate should not equal null\n"); + logTestInfo("Testing: activeUpdate should not equal null"); do_check_neq(gUpdateManager.activeUpdate, null); - dump("Testing: activeUpdate.state should not equal null\n"); + logTestInfo("Testing: activeUpdate.state should not equal null"); do_check_neq(gUpdateManager.activeUpdate.state, null); - dump("Testing: activeUpdate.state should equal STATE_DOWNLOADING\n"); + logTestInfo("Testing: activeUpdate.state should equal STATE_DOWNLOADING"); do_check_eq(gUpdateManager.activeUpdate.state, STATE_DOWNLOADING); - end_test(); + + do_test_finished(); } // Prevent the attempt to display the Update wizard for the failed update diff --git a/toolkit/mozapps/update/test/unit/test_bug595059.js b/toolkit/mozapps/update/test/unit/test_bug595059.js index 7cf80277027e..9b47985d1043 100644 --- a/toolkit/mozapps/update/test/unit/test_bug595059.js +++ b/toolkit/mozapps/update/test/unit/test_bug595059.js @@ -9,10 +9,12 @@ function run_test() { do_test_pending(); - dump("Testing: Bug 595059 - calling nsIUpdatePrompt::showUpdateError " + - "should call getNewPrompter and alert on the object returned by " + - "getNewPrompter when the update.state = " + STATE_FAILED + " and the " + - "update.errorCode = " + WRITE_ERROR + "\n"); + do_register_cleanup(end_test); + + logTestInfo("testing Bug 595059 - calling nsIUpdatePrompt::showUpdateError " + + "should call getNewPrompter and alert on the object returned " + + "by getNewPrompter when the update.state = " + STATE_FAILED + + " and the update.errorCode = " + WRITE_ERROR); removeUpdateDirsAndFiles(); setUpdateChannel(); @@ -47,7 +49,6 @@ function end_test() { let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar); registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"), WindowWatcherFactory); - do_test_finished(); cleanUp(); } @@ -62,7 +63,7 @@ var WindowWatcher = { [Services.appinfo.name, Services.appinfo.name], 2); do_check_eq(aText, text); - end_test(); + do_test_finished(); } }; }, diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index e070933e4e6f..b5827cf3c514 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -3279,21 +3279,33 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData) } #if defined(MOZ_UPDATER) && !defined(ANDROID) - // Check for and process any available updates - nsCOMPtr updRoot; - PRBool persistent; - rv = dirProvider.GetFile(XRE_UPDATE_ROOT_DIR, &persistent, - getter_AddRefs(updRoot)); - // XRE_UPDATE_ROOT_DIR may fail. Fallback to appDir if failed - if (NS_FAILED(rv)) - updRoot = dirProvider.GetAppDir(); + // Check for and process any available updates + nsCOMPtr updRoot; + PRBool persistent; + rv = dirProvider.GetFile(XRE_UPDATE_ROOT_DIR, &persistent, + getter_AddRefs(updRoot)); + // XRE_UPDATE_ROOT_DIR may fail. Fallback to appDir if failed + if (NS_FAILED(rv)) + updRoot = dirProvider.GetAppDir(); - ProcessUpdates(dirProvider.GetGREDir(), - dirProvider.GetAppDir(), - updRoot, - gRestartArgc, - gRestartArgv, - appData.version); + // Support for processing an update and exiting. The MOZ_PROCESS_UPDATES + // environment variable will be part of the updater's environment and the + // application that is relaunched by the updater. When the application is + // relaunched by the updater it will be removed below and the application + // will exit. + if (CheckArg("process-updates")) { + SaveToEnv("MOZ_PROCESS_UPDATES=1"); + } + ProcessUpdates(dirProvider.GetGREDir(), + dirProvider.GetAppDir(), + updRoot, + gRestartArgc, + gRestartArgv, + appData.version); + if (PR_GetEnv("MOZ_PROCESS_UPDATES")) { + PR_SetEnv("MOZ_PROCESS_UPDATES="); + return 0; + } #endif nsCOMPtr profileLock; @@ -3350,32 +3362,32 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData) // Also check to see if something has happened to invalidate our // fastload caches, like an extension upgrade or installation. - // If we see .purgecaches, that means someone did a make. - // Re-register components to catch potential changes. - // We only offer this in debug builds, though. - nsCOMPtr flagFile; + // If we see .purgecaches, that means someone did a make. + // Re-register components to catch potential changes. + // We only offer this in debug builds, though. + nsCOMPtr flagFile; - rv = NS_ERROR_FILE_NOT_FOUND; - nsCOMPtr fFlagFile; - if (gAppData->directory) { - rv = gAppData->directory->Clone(getter_AddRefs(fFlagFile)); - } - flagFile = do_QueryInterface(fFlagFile); - if (flagFile) { - flagFile->AppendNative(FILE_INVALIDATE_CACHES); - } + rv = NS_ERROR_FILE_NOT_FOUND; + nsCOMPtr fFlagFile; + if (gAppData->directory) { + rv = gAppData->directory->Clone(getter_AddRefs(fFlagFile)); + } + flagFile = do_QueryInterface(fFlagFile); + if (flagFile) { + flagFile->AppendNative(FILE_INVALIDATE_CACHES); + } PRBool cachesOK; PRBool versionOK = CheckCompatibility(profD, version, osABI, dirProvider.GetGREDir(), gAppData->directory, flagFile, &cachesOK); - if (CheckArg("purgecaches")) { - cachesOK = PR_FALSE; - } - if (PR_GetEnv("MOZ_PURGE_CACHES")) { - cachesOK = PR_FALSE; - } + if (CheckArg("purgecaches")) { + cachesOK = PR_FALSE; + } + if (PR_GetEnv("MOZ_PURGE_CACHES")) { + cachesOK = PR_FALSE; + } // Every time a profile is loaded by a build with a different version, // it updates the compatibility.ini file saying what version last wrote