Backed out changeset 7dbcb63aa3e3 (bug 774144) for frequent Android mochitest-4 failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Sun, 13 Apr 2014 23:46:31 -0400
changeset 196802 0a1315c30090e8df8b90096e375b6b067a54c1ba
parent 196801 93caa1abf5a34b32dabc263d9896914b84078949
child 196803 c153aa5be1088073e57fe2a63d806f3b7a161b23
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs774144
milestone31.0a1
backs out7dbcb63aa3e3fe699319c19fa7da95fc459f66cc
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 7dbcb63aa3e3 (bug 774144) for frequent Android mochitest-4 failures. CLOSED TREE
toolkit/webapps/WebappOSUtils.jsm
webapprt/win/webapp-uninstaller.nsi.in
--- a/toolkit/webapps/WebappOSUtils.jsm
+++ b/toolkit/webapps/WebappOSUtils.jsm
@@ -5,17 +5,16 @@
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const CC = Components.Constructor;
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/FileUtils.jsm");
 Cu.import("resource://gre/modules/osfile.jsm");
-Cu.import("resource://gre/modules/Promise.jsm");
 
 this.EXPORTED_SYMBOLS = ["WebappOSUtils"];
 
 // Returns the MD5 hash of a string.
 function computeHash(aString) {
   let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
                   createInstance(Ci.nsIScriptableUnicodeConverter);
   converter.charset = "UTF-8";
@@ -39,91 +38,73 @@ function computeHash(aString) {
 }
 
 this.WebappOSUtils = {
   getUniqueName: function(aApp) {
     return this.sanitizeStringForFilename(aApp.name).toLowerCase() + "-" +
            computeHash(aApp.manifestURL);
   },
 
-#ifdef XP_WIN
-  /**
-   * Returns the registry key associated to the given app and a boolean that
-   * specifies whether we're using the old naming scheme or the new one.
-   */
-  getAppRegKey: function(aApp) {
-    let regKey = Cc["@mozilla.org/windows-registry-key;1"].
-                 createInstance(Ci.nsIWindowsRegKey);
-
-    try {
-      regKey.open(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
-                  "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" +
-                  this.getUniqueName(aApp), Ci.nsIWindowsRegKey.ACCESS_READ);
-
-      return { value: regKey,
-               namingSchemeVersion: 2};
-    } catch (ex) {}
-
-    // Fall back to the old installation naming scheme
-    try {
-      regKey.open(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
-                  "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" +
-                  aApp.origin, Ci.nsIWindowsRegKey.ACCESS_READ);
-
-      return { value: regKey,
-               namingSchemeVersion: 1 };
-    } catch (ex) {}
-
-    return null;
-  },
-#endif
-
   /**
    * Returns the executable of the given app, identifying it by its unique name,
    * which is in either the new format or the old format.
    * On Mac OS X, it returns the identifier of the app.
    *
    * The new format ensures a readable and unique name for an app by combining
    * its name with a hash of its manifest URL.  The old format uses its origin,
    * which is only unique until we support multiple apps per origin.
    */
   getLaunchTarget: function(aApp) {
-#ifdef XP_WIN
-    let appRegKey = this.getAppRegKey(aApp);
+    let uniqueName = this.getUniqueName(aApp);
 
-    if (!appRegKey) {
-      return null;
+#ifdef XP_WIN
+    let isOldNamingScheme = false;
+    let appRegKey;
+    try {
+      let open = CC("@mozilla.org/windows-registry-key;1",
+                    "nsIWindowsRegKey", "open");
+      appRegKey = open(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
+                       "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" +
+                       uniqueName, Ci.nsIWindowsRegKey.ACCESS_READ);
+    } catch (ex) {
+      // Fall back to the old installation naming scheme
+      try {
+        appRegKey = open(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
+                         "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" +
+                         aApp.origin, Ci.nsIWindowsRegKey.ACCESS_READ);
+        isOldNamingScheme = true;
+      } catch (ex) {
+        return null;
+      }
     }
 
     let appFilename, installLocation;
     try {
-      appFilename = appRegKey.value.readStringValue("AppFilename");
-      installLocation = appRegKey.value.readStringValue("InstallLocation");
+      appFilename = appRegKey.readStringValue("AppFilename");
+      installLocation = appRegKey.readStringValue("InstallLocation");
     } catch (ex) {
       return null;
     } finally {
-      appRegKey.value.close();
+      appRegKey.close();
     }
 
     installLocation = installLocation.substring(1, installLocation.length - 1);
 
-    if (appRegKey.namingSchemeVersion == 1 &&
+    if (isOldNamingScheme &&
         !this.isOldInstallPathValid(aApp, installLocation)) {
       return null;
     }
 
     let initWithPath = CC("@mozilla.org/file/local;1",
                           "nsILocalFile", "initWithPath");
     let launchTarget = initWithPath(installLocation);
     launchTarget.append(appFilename + ".exe");
 
     return launchTarget;
 #elifdef XP_MACOSX
-    let uniqueName = this.getUniqueName(aApp);
-
     let mwaUtils = Cc["@mozilla.org/widget/mac-web-app-utils;1"]
                      .createInstance(Ci.nsIMacWebAppUtils);
 
     try {
       let path;
       if (path = mwaUtils.pathForAppWithIdentifier(uniqueName)) {
         return [ uniqueName, path ];
       }
@@ -135,18 +116,16 @@ this.WebappOSUtils = {
       if ((path = mwaUtils.pathForAppWithIdentifier(aApp.origin)) &&
            this.isOldInstallPathValid(aApp, path)) {
         return [ aApp.origin, path ];
       }
     } catch(ex) {}
 
     return [ null, null ];
 #elifdef XP_UNIX
-    let uniqueName = this.getUniqueName(aApp);
-
     let exeFile = Services.dirsvc.get("Home", Ci.nsIFile);
     exeFile.append("." + uniqueName);
     exeFile.append("webapprt-stub");
 
     // Fall back to the old installation naming scheme
     if (!exeFile.exists()) {
       exeFile = Services.dirsvc.get("Home", Ci.nsIFile);
 
@@ -238,26 +217,26 @@ this.WebappOSUtils = {
 
     return packagePath;
   },
 
   launch: function(aApp) {
     let uniqueName = this.getUniqueName(aApp);
 
 #ifdef XP_WIN
+    let initProcess = CC("@mozilla.org/process/util;1",
+                         "nsIProcess", "init");
+
     let launchTarget = this.getLaunchTarget(aApp);
     if (!launchTarget) {
       return false;
     }
 
     try {
-      let process = Cc["@mozilla.org/process/util;1"].
-                    createInstance(Ci.nsIProcess);
-
-      process.init(launchTarget);
+      let process = initProcess(launchTarget);
       process.runwAsync([], 0);
     } catch (e) {
       return false;
     }
 
     return true;
 #elifdef XP_MACOSX
     let [ launchIdentifier, path ] = this.getLaunchTarget(aApp);
@@ -291,77 +270,37 @@ this.WebappOSUtils = {
       return false;
     }
 
     return true;
 #endif
   },
 
   uninstall: function(aApp) {
-#ifdef XP_WIN
-    let appRegKey = this.getAppRegKey(aApp);
-
-    if (!appRegKey) {
-      return Promise.reject("App registry key not found");
-    }
-
-    let deferred = Promise.defer();
-
-    try {
-      let uninstallerPath = appRegKey.value.readStringValue("UninstallString");
-      uninstallerPath = uninstallerPath.substring(1, uninstallerPath.length - 1);
-
-      let uninstaller = Cc["@mozilla.org/file/local;1"].
-                        createInstance(Ci.nsIFile);
-      uninstaller.initWithPath(uninstallerPath);
+    let uniqueName = this.getUniqueName(aApp);
 
-      let process = Cc["@mozilla.org/process/util;1"].
-                    createInstance(Ci.nsIProcess);
-      process.init(uninstaller);
-      process.runwAsync(["/S"], 1, (aSubject, aTopic) => {
-        if (aTopic == "process-finished") {
-          deferred.resolve(true);
-        } else {
-          deferred.reject("Uninstaller failed with exit code: " + aSubject.exitValue);
-        }
-      });
-    } catch (e) {
-      deferred.reject(e);
-    } finally {
-      appRegKey.value.close();
-    }
-
-    return deferred.promise;
-#elifdef XP_MACOSX
-    return Promise.reject("Uninstallation not yet implemented");
-#elifdef XP_UNIX
+#ifdef XP_UNIX
+#ifndef XP_MACOSX
     let exeFile = this.getLaunchTarget(aApp);
     if (!exeFile) {
-      return Promise.reject("App executable file not found");
+      return false;
     }
 
-    let deferred = Promise.defer();
-
     try {
       let process = Cc["@mozilla.org/process/util;1"]
                       .createInstance(Ci.nsIProcess);
 
       process.init(exeFile);
-      process.runAsync(["-remove"], 1, (aSubject, aTopic) => {
-        if (aTopic == "process-finished") {
-          deferred.resolve(true);
-        } else {
-          deferred.reject("Uninstaller failed with exit code: " + aSubject.exitValue);
-        }
-      });
+      process.runAsync(["-remove"], 1);
     } catch (e) {
-      deferred.reject(e);
+      return false;
     }
 
-    return deferred.promise;
+    return true;
+#endif
 #endif
   },
 
   /**
    * Returns true if the given install path (in the old naming scheme) actually
    * belongs to the given application.
    */
   isOldInstallPathValid: function(aApp, aInstallPath) {
--- a/webapprt/win/webapp-uninstaller.nsi.in
+++ b/webapprt/win/webapp-uninstaller.nsi.in
@@ -3,17 +3,20 @@
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # Required Plugins:
 # ShellLink   http://nsis.sourceforge.net/ShellLink_plug-in
 
 ; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs
 !verbose 3
 
+; 7-Zip provides better compression than the lzma from NSIS so we add the files
+; uncompressed and let the application installer compress it.
 SetDatablockOptimize on
+SetCompress off
 CRCCheck on
 SilentInstall silent
 
 RequestExecutionLevel user
 
 !addplugindir ./
 
 ; prevents compiling of the reg write logging.
@@ -62,67 +65,59 @@ Name "Mozilla Web App Runtime App"
 OutFile "${UninstallerFilename}"
 ShowUnInstDetails nevershow
 
 # Create a blank page so that the default pages (instfiles) don't appear
 UninstPage custom un.blankPage
 
 ################################################################################
 # Install Sections
-# The "installer" that is generated by this file is a stub that generates the
-# uninstaller at runtime in a temp directory and launches it.
-# We call `WriteUninstaller` during `onInit` so this section is empty.
+# The "installer" that is generated by this file will be run during the build
+# process to generate an uninstaller.  We call `WriteUninstaller` during
+# `onInit` so this section is empty.
 Section ""
 SectionEnd
 
 ################################################################################
 # This is where uninstallation happens
 ################################################################################
-Function un.webappUninstall
+Function un.blankPage
+  MessageBox MB_OKCANCEL "$(UN_CONFIRM_UNINSTALL)" /SD IDOK IDCANCEL done
+
   ; Delete the app exe to prevent launching the app while we are uninstalling.
   ClearErrors
   ${DeleteFile} "$INSTDIR\${FileMainEXE}"
   ${If} ${Errors}
     ; If the app is running, rename the EXE out of the way
     CreateDirectory "$AppRTTempDir"
     Rename "$INSTDIR\${FileMainEXE}" "$AppRTTempDir\${FileMainEXE}"
     ClearErrors
   ${EndIf}
 
+
   SetShellVarContext current  ; Set SHCTX to HKCU
 
   ; Remove our entry in the "Uninstall" key
   ${un.RegCleanUninstall}
 
   ; Remove our shortcuts from start menu, desktop, and taskbar
   ${un.DeleteShortcuts}
 
   ; Parse the uninstall log to remove all installed
   ; files / directories this install is responsible for.
   ${un.ParseUninstallLog}
 
-  ; Remove the uninstall directory that we control.
-  ; The installer is in the uninstall directory, it generates
-  ; the uninstaller in a temp directory and waits for its
-  ; execution. Thus, we can't remove the uninstall directory
-  ; now and need to wait for a restart.
-  ; See bug 994965.
-  RmDir /r /REBOOTOK "$INSTDIR\uninstall"
+  ; Remove the uninstall directory that we control
+  RmDir /r "$INSTDIR\uninstall"
 
   ; Remove the installation directory if it is empty
   ${RemoveDir} "$INSTDIR"
 
   ; Refresh shell icons to reflect the changes we've made
   ${un.RefreshShellIcons}
-FunctionEnd
-
-Function un.blankPage
-  MessageBox MB_OKCANCEL "$(UN_CONFIRM_UNINSTALL)" /SD IDOK IDCANCEL done
-
-  Call un.webappUninstall
 
   done:
 FunctionEnd
 
 ################################################################################
 # Language
 
 !verbose push
@@ -144,18 +139,18 @@ Function .onInit
   Delete "$0"
   CreateDirectory "$0"
   SetOutPath "$0"
 
   StrCpy $1 "$0\${UninstallerFilename}"
   WriteUninstaller "$1"
 
   ${GetParameters} $2
-  StrCpy $2 "$2 _?=$EXEDIR"
-  ExecWait '"$1" $2'
+  StrCpy $2 "_?=$EXEDIR $2"
+  Exec '"$1" $2'
   Quit
 FunctionEnd
 
 Function un.onInit
   ; Remove the current exe directory from the search order.
   ; This only effects LoadLibrary calls and not implicitly loaded DLLs.
   System::Call 'kernel32::SetDllDirectoryW(w "")'
 
@@ -168,13 +163,9 @@ Function un.onInit
   ReadINIStr $AppName "$INSTDIR\webapp.ini" "Webapp" "Name"
 
   ${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}"
     Abort
   ${EndUnless}
 
   StrCpy $AppRTTempDir "$TEMP\moz_webapprt"
   RmDir /r "$AppRTTempDir"
-
-  ${If} ${Silent}
-    Call un.webappUninstall
-  ${EndIf}
 FunctionEnd