Bug 1546828 - Improve the stub installer's method for finding the most recent release. r=agashlin
authorMatt Howell <mhowell@mozilla.com>
Mon, 29 Apr 2019 15:44:47 +0000
changeset 474099 87212d664f1fc3fa828bf6f6f9e25ca20e5d2a5f
parent 474098 862aa43181c3bcb046b6159141c29a4c960680a6
child 474100 b2867d2df9a3ddbd1bc3f1127eda13eed334f67d
push id36022
push userncsoregi@mozilla.com
push dateThu, 16 May 2019 21:55:16 +0000
treeherdermozilla-central@96802be91766 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersagashlin
bugs1546828
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1546828 - Improve the stub installer's method for finding the most recent release. r=agashlin The nsJSON plugin turns out not to handle waiting for an entire HTTP respoonse correctly, so replace it with our InetBgDl plugin, which does. Differential Revision: https://phabricator.services.mozilla.com/D28884
browser/installer/windows/nsis/stub.nsi
--- a/browser/installer/windows/nsis/stub.nsi
+++ b/browser/installer/windows/nsis/stub.nsi
@@ -1899,38 +1899,78 @@ Function ShouldPromptForProfileCleanup
 
   end:
   SetRegView lastused
   SetShellVarContext all
 FunctionEnd
 
 Function GetLatestReleasedVersion
   ClearErrors
-  nsJSON::Set /tree requestConfig /value \
-    `{"Url": "https://product-details.mozilla.org/1.0/firefox_versions.json", "Async": false}`
-  IfErrors end
-  nsJSON::Set /http requestConfig
+  Push $0 ; InetBgDl::GetStats uses $0 for the HTTP error code
+  ; $1 is our return value, so don't save it
+  Push $2 ; InetBgDl::GetStats uses $2 to tell us when the transfer is done
+  Push $3 ; $3 - $5 are also set by InetBgDl::GetStats, but we don't use them
+  Push $4
+  Push $5
+  Push $6 ; This is our response timeout counter
+
+  InetBgDL::Get /RESET /END
+  InetBgDL::Get "https://product-details.mozilla.org/1.0/firefox_versions.json" \
+                "$PLUGINSDIR\firefox_versions.json" \
+                /CONNECTTIMEOUT 120 /RECEIVETIMEOUT 120 /END
+
+  ; Wait for the response, but only give it half a second since this is on the
+  ; installer startup path (we haven't even shown a window yet).
+  StrCpy $6 0
+  ${Do}
+    Sleep 100
+    InetBgDL::GetStats
+    IntOp $6 $6 + 1
+
+    ${If} $2 == 0
+      ${Break}
+    ${ElseIf} $6 >= 5
+      InetBgDL::Get /RESET /END
+      SetErrors
+      GoTo end
+    ${EndIf}
+  ${Loop}
+
+  StrCpy $1 0
+  nsJSON::Set /file "$PLUGINSDIR\firefox_versions.json"
   IfErrors end
   ${Select} ${Channel}
   ${Case} "unofficial"
     StrCpy $1 "FIREFOX_NIGHTLY"
   ${Case} "nightly"
     StrCpy $1 "FIREFOX_NIGHTLY"
   ${Case} "aurora"
     StrCpy $1 "FIREFOX_DEVEDITION"
   ${Case} "beta"
     StrCpy $1 "LATEST_FIREFOX_RELEASED_DEVEL_VERSION"
   ${Case} "release"
     StrCpy $1 "LATEST_FIREFOX_VERSION"
   ${EndSelect}
-  nsJSON::Get "Output" $1 /end
-  IfErrors end
-  Pop $1
+  nsJSON::Get $1 /end
 
   end:
+  ${If} ${Errors}
+  ${OrIf} $1 == 0
+    SetErrors
+    StrCpy $1 0
+  ${Else}
+    Pop $1
+  ${EndIf}
+
+  Pop $6
+  Pop $5
+  Pop $4
+  Pop $3
+  Pop $2
+  Pop $0
 FunctionEnd
 
 Function GetExistingInstallArch
   StrCpy $0 "unknown"
 
   ClearErrors
   FileOpen $R1 "$0\install.log" r
   ${If} ${Errors}