Bug 1556612: Hardcode considering this an upgrade if the last build to run was run in safe mode. r=froydnj a=jcristau
authorDave Townsend <dtownsend@oxymoronical.com>
Wed, 05 Jun 2019 16:17:16 +0000
changeset 536723 f78bcf6d473ed6a6c9828fc9e37a07e9e6886f81
parent 536722 d147de264bb9067c4815c36d1e8ccd7642eee3ee
child 536724 b25d2ea5cf47fc4e0c01214acad7c30162b1b1d8
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, jcristau
bugs1556612, 1556831, 1556832, 1556829
milestone68.0
Bug 1556612: Hardcode considering this an upgrade if the last build to run was run in safe mode. r=froydnj a=jcristau When safe mode runs it writes out "Safe Mode" as the compatibility version (bug 1556831). Due to bug 1556832 and bug 1556829 this makes us think that the next run is a downgrade. This is the simplest possible fix that should be totally safe to upload to release. Differential Revision: https://phabricator.services.mozilla.com/D33698
toolkit/xre/nsAppRunner.cpp
toolkit/xre/test/gtest/TestCompatVersionCompare.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2432,16 +2432,24 @@ bool CheckCompatVersions(const nsACStrin
   if (aOldCompatVersion.Equals(aNewCompatVersion)) {
     *aIsDowngrade = false;
     return true;
   }
 
   // The versions differ for some reason so we will only ever return false from
   // here onwards. We just have to figure out if this is a downgrade or not.
 
+  // Hardcode the case where the last run was in safe mode (Bug 1556612). We
+  // cannot tell if this is a downgrade or not so just assume it isn't and let
+  // the user proceed.
+  if (aOldCompatVersion.EqualsLiteral("Safe Mode")) {
+    *aIsDowngrade = false;
+    return false;
+  }
+
   nsCString oldVersion;
   nsCString oldAppBuildID;
   nsCString oldPlatformBuildID;
   ExtractCompatVersionInfo(aOldCompatVersion, oldVersion, oldAppBuildID,
                            oldPlatformBuildID);
 
   nsCString newVersion;
   nsCString newAppBuildID;
--- a/toolkit/xre/test/gtest/TestCompatVersionCompare.cpp
+++ b/toolkit/xre/test/gtest/TestCompatVersionCompare.cpp
@@ -2,34 +2,41 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 #include "gtest/gtest.h"
 #include "nsAppRunner.h"
 #include "nsString.h"
 
+void CheckCompatVersionCompare(const nsCString& aOldCompatVersion,
+                               const nsCString& aNewCompatVersion,
+                               bool aExpectedSame, bool aExpectedDowngrade) {
+  printf("Comparing '%s' to '%s'.\n", aOldCompatVersion.get(), aNewCompatVersion.get());
+
+  bool isDowngrade = false;
+  bool isSame = CheckCompatVersions(aOldCompatVersion, aNewCompatVersion, &isDowngrade);
+
+  ASSERT_EQ(aExpectedSame, isSame) << "Version sameness check should match.";
+  ASSERT_EQ(aExpectedDowngrade, isDowngrade) << "Version downgrade check should match.";
+}
+
 void CheckExpectedResult(
   const char* aOldAppVersion, const char* aOldAppID, const char* aOldToolkitID,
   const char* aNewAppVersion, const char* aNewAppID, const char* aNewToolkitID,
   bool aExpectedSame, bool aExpectedDowngrade) {
 
   nsCString oldCompatVersion;
   BuildCompatVersion(aOldAppVersion, aOldAppID, aOldToolkitID, oldCompatVersion);
 
   nsCString newCompatVersion;
   BuildCompatVersion(aNewAppVersion, aNewAppID, aNewToolkitID, newCompatVersion);
 
-  printf("Comparing '%s' to '%s'.\n", oldCompatVersion.get(), newCompatVersion.get());
-
-  bool isDowngrade = false;
-  bool isSame = CheckCompatVersions(oldCompatVersion, newCompatVersion, &isDowngrade);
-
-  ASSERT_EQ(aExpectedSame, isSame) << "Version sameness check should match.";
-  ASSERT_EQ(aExpectedDowngrade, isDowngrade) << "Version downgrade check should match.";
+  CheckCompatVersionCompare(oldCompatVersion, newCompatVersion,
+                            aExpectedSame, aExpectedDowngrade);
 }
 
 TEST(CompatVersionCompare, CompareVersionChange) {
   // Identical
   CheckExpectedResult(
     "67.0",   "20000000000000", "20000000000000",
     "67.0",   "20000000000000", "20000000000000",
     true, false);
@@ -115,9 +122,15 @@ TEST(CompatVersionCompare, CompareVersio
   CheckExpectedResult(
     "67.0",   "20190516215225", "20190516215225",
     "67.0.5", "20190523030228","20190523030228",
     false, false);
   CheckExpectedResult(
     "67.0.5", "20190523030228","20190523030228",
     "67.0",   "20190516215225", "20190516215225",
     false, true);
+
+  // Check that if the last run was safe mode then we consider this an upgrade.
+  CheckCompatVersionCompare(
+    NS_LITERAL_CSTRING("Safe Mode"),
+    NS_LITERAL_CSTRING("67.0.1_20000000000000/20000000000000"),
+    false, false);
 }