Merge m-c to inbound.
authorRyan VanderMeulen <ryanvm@gmail.com>
Thu, 01 Nov 2012 19:23:07 -0400
changeset 116758 9268740945659fbd43cf25580c7baff9c8c9ecc2
parent 116757 16772d0c770c53992f62a8790ce82ad5e03e1be8 (current diff)
parent 116679 570c7cb5b03dc844b22b7d39cdf05f0c91906fc8 (diff)
child 116759 b027df4ba1e8f2c1ade179f90bbb6cb70bf40861
push id2735
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 23:12:38 +0000
treeherdermozilla-aurora@b3950b0ad29a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone19.0a1
Merge m-c to inbound.
dom/sms/tests/marionette/test_timestamp.js
netwerk/protocol/http/nsHttpHandler.cpp
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1003,17 +1003,16 @@ var gBrowserInit = {
     //                      ignored).
     //                 [1]: character set (string)
     //                 [2]: referrer (nsIURI)
     //                 [3]: postData (nsIInputStream)
     //                 [4]: allowThirdPartyFixup (bool)
     if ("arguments" in window && window.arguments[0])
       var uriToLoad = window.arguments[0];
 
-    var isLoadingBlank = isBlankPageURL(uriToLoad);
     var mustLoadSidebar = false;
 
     gBrowser.addEventListener("DOMUpdatePageReport", gPopupBlockerObserver, false);
 
     gBrowser.addEventListener("PluginNotFound",     gPluginHandler, true);
     gBrowser.addEventListener("PluginCrashed",      gPluginHandler, true);
     gBrowser.addEventListener("PluginBlocklisted",  gPluginHandler, true);
     gBrowser.addEventListener("PluginOutdated",     gPluginHandler, true);
@@ -1090,54 +1089,16 @@ var gBrowserInit = {
 
     // setup our MozApplicationManifest listener
     gBrowser.addEventListener("MozApplicationManifest",
                               OfflineApps, false);
 
     // setup simple gestures support
     gGestureSupport.init(true);
 
-
-    if (uriToLoad && uriToLoad != "about:blank") {
-      if (uriToLoad instanceof Ci.nsISupportsArray) {
-        let count = uriToLoad.Count();
-        let specs = [];
-        for (let i = 0; i < count; i++) {
-          let urisstring = uriToLoad.GetElementAt(i).QueryInterface(Ci.nsISupportsString);
-          specs.push(urisstring.data);
-        }
-
-        // This function throws for certain malformed URIs, so use exception handling
-        // so that we don't disrupt startup
-        try {
-          gBrowser.loadTabs(specs, false, true);
-        } catch (e) {}
-      }
-      else if (uriToLoad instanceof XULElement) {
-        // swap the given tab with the default about:blank tab and then close
-        // the original tab in the other window.
-
-        // Stop the about:blank load
-        gBrowser.stop();
-        // make sure it has a docshell
-        gBrowser.docShell;
-
-        gBrowser.swapBrowsersAndCloseOther(gBrowser.selectedTab, uriToLoad);
-      }
-      else if (window.arguments.length >= 3) {
-        loadURI(uriToLoad, window.arguments[2], window.arguments[3] || null,
-                window.arguments[4] || false);
-        window.focus();
-      }
-      // Note: loadOneOrMoreURIs *must not* be called if window.arguments.length >= 3.
-      // Such callers expect that window.arguments[0] is handled as a single URI.
-      else
-        loadOneOrMoreURIs(uriToLoad);
-    }
-
     if (window.opener && !window.opener.closed) {
       let openerSidebarBox = window.opener.document.getElementById("sidebar-box");
       // If the opener had a sidebar, open the same sidebar in our window.
       // The opener can be the hidden window too, if we're coming from the state
       // where no windows are open, and the hidden window has no sidebar box.
       if (openerSidebarBox && !openerSidebarBox.hidden) {
         let sidebarCmd = openerSidebarBox.getAttribute("sidebarcommand");
         let sidebarCmdElem = document.getElementById(sidebarCmd);
@@ -1237,35 +1198,74 @@ var gBrowserInit = {
     allTabs.readPref();
     TabsOnTop.init();
     BookmarksMenuButton.init();
     TabsInTitlebar.init();
     gPrivateBrowsingUI.init();
     retrieveToolbarIconsizesFromTheme();
 
     // Wait until chrome is painted before executing code not critical to making the window visible
-    this._boundDelayedStartup = this._delayedStartup.bind(this, isLoadingBlank, mustLoadSidebar);
+    this._boundDelayedStartup = this._delayedStartup.bind(this, uriToLoad, mustLoadSidebar);
     window.addEventListener("MozAfterPaint", this._boundDelayedStartup);
 
     gStartupRan = true;
   },
 
   _cancelDelayedStartup: function () {
     window.removeEventListener("MozAfterPaint", this._boundDelayedStartup);
     this._boundDelayedStartup = null;
   },
 
-  _delayedStartup: function(isLoadingBlank, mustLoadSidebar) {
+  _delayedStartup: function(uriToLoad, mustLoadSidebar) {
     let tmp = {};
     Cu.import("resource:///modules/TelemetryTimestamps.jsm", tmp);
     let TelemetryTimestamps = tmp.TelemetryTimestamps;
     TelemetryTimestamps.add("delayedStartupStarted");
 
     this._cancelDelayedStartup();
 
+    var isLoadingBlank = isBlankPageURL(uriToLoad);
+
+    if (uriToLoad && uriToLoad != "about:blank") {
+      if (uriToLoad instanceof Ci.nsISupportsArray) {
+        let count = uriToLoad.Count();
+        let specs = [];
+        for (let i = 0; i < count; i++) {
+          let urisstring = uriToLoad.GetElementAt(i).QueryInterface(Ci.nsISupportsString);
+          specs.push(urisstring.data);
+        }
+
+        // This function throws for certain malformed URIs, so use exception handling
+        // so that we don't disrupt startup
+        try {
+          gBrowser.loadTabs(specs, false, true);
+        } catch (e) {}
+      }
+      else if (uriToLoad instanceof XULElement) {
+        // swap the given tab with the default about:blank tab and then close
+        // the original tab in the other window.
+
+        // Stop the about:blank load
+        gBrowser.stop();
+        // make sure it has a docshell
+        gBrowser.docShell;
+
+        gBrowser.swapBrowsersAndCloseOther(gBrowser.selectedTab, uriToLoad);
+      }
+      else if (window.arguments.length >= 3) {
+        loadURI(uriToLoad, window.arguments[2], window.arguments[3] || null,
+                window.arguments[4] || false);
+        window.focus();
+      }
+      // Note: loadOneOrMoreURIs *must not* be called if window.arguments.length >= 3.
+      // Such callers expect that window.arguments[0] is handled as a single URI.
+      else
+        loadOneOrMoreURIs(uriToLoad);
+    }
+
 #ifdef MOZ_SAFE_BROWSING
     // Bug 778855 - Perf regression if we do this here. To be addressed in bug 779008.
     setTimeout(function() { SafeBrowsing.init(); }, 2000);
 #endif
 
     Services.obs.addObserver(gSessionHistoryObserver, "browser:purge-session-history", false);
     Services.obs.addObserver(gXPInstallObserver, "addon-install-disabled", false);
     Services.obs.addObserver(gXPInstallObserver, "addon-install-started", false);
--- a/browser/branding/aurora/branding.nsi
+++ b/browser/branding/aurora/branding.nsi
@@ -10,16 +10,17 @@
 # instead of BrandFullName and typically should not be modified.
 !define BrandFullNameInternal "Aurora"
 !define CompanyName           "mozilla.org"
 !define URLInfoAbout          "http://www.mozilla.org"
 !define URLUpdateInfo         "http://www.mozilla.org/projects/firefox"
 
 !define URLStubDownload "http://download.mozilla.org/?product=firefox-aurora-latest&os=win&lang=${AB_CD}"
 !define URLManualDownload "https://www.mozilla.org/firefox/installer-help/?channel=aurora"
+!define Channel "aurora"
 
 # The installer's certificate name and issuer expected by the stub installer
 !define CertNameDownload   "Mozilla Corporation"
 !define CertIssuerDownload "Thawte Code Signing CA - G2"
 
 # Dialog units are used so the UI displays correctly with the system's DPI
 # settings.
 # The dialog units for the bitmap's dimensions should match exactly with the
--- a/browser/branding/nightly/branding.nsi
+++ b/browser/branding/nightly/branding.nsi
@@ -10,16 +10,17 @@
 # instead of BrandFullName and typically should not be modified.
 !define BrandFullNameInternal "Nightly"
 !define CompanyName           "mozilla.org"
 !define URLInfoAbout          "http://www.mozilla.org"
 !define URLUpdateInfo         "http://www.mozilla.org/projects/firefox"
 
 !define URLStubDownload "http://download.mozilla.org/?product=firefox-nightly-latest&os=win&lang=${AB_CD}"
 !define URLManualDownload "https://www.mozilla.org/firefox/installer-help/?channel=nightly"
+!define Channel "nightly"
 
 # The installer's certificate name and issuer expected by the stub installer
 !define CertNameDownload   "Mozilla Corporation"
 !define CertIssuerDownload "Thawte Code Signing CA - G2"
 
 # Dialog units are used so the UI displays correctly with the system's DPI
 # settings.
 # The dialog units for the bitmap's dimensions should match exactly with the
--- a/browser/branding/official/branding.nsi
+++ b/browser/branding/official/branding.nsi
@@ -13,16 +13,17 @@
 !define URLInfoAbout          "http://www.mozilla.com/${AB_CD}/"
 !define URLUpdateInfo         "http://www.mozilla.com/${AB_CD}/firefox/"
 
 ; Prevents the beta channel urls in stub.nsi from being used when not using
 ; official branding
 !define Official
 !define URLStubDownload "http://download.mozilla.org/?product=firefox-latest&os=win&lang=${AB_CD}"
 !define URLManualDownload "https://www.mozilla.org/firefox/installer-help/?channel=release"
+!define Channel "release"
 
 # The installer's certificate name and issuer expected by the stub installer
 !define CertNameDownload   "Mozilla Corporation"
 !define CertIssuerDownload "Thawte Code Signing CA - G2"
 
 # Dialog units are used so the UI displays correctly with the system's DPI
 # settings.
 # The dialog units for the bitmap's dimensions should match exactly with the
--- a/browser/branding/unofficial/branding.nsi
+++ b/browser/branding/unofficial/branding.nsi
@@ -10,16 +10,17 @@
 # instead of BrandFullName and typically should not be modified.
 !define BrandFullNameInternal "Mozilla Developer Preview"
 !define CompanyName           "mozilla.org"
 !define URLInfoAbout          "http://www.mozilla.org"
 !define URLUpdateInfo         "http://www.mozilla.org/projects/firefox"
 
 !define URLStubDownload "http://download.mozilla.org/?product=firefox-latest&os=win&lang=${AB_CD}"
 !define URLManualDownload "https://www.mozilla.org/firefox/installer-help/?channel=release"
+!define Channel "unofficial"
 
 # The installer's certificate name and issuer expected by the stub installer
 !define CertNameDownload   "Mozilla Corporation"
 !define CertIssuerDownload "Thawte Code Signing CA - G2"
 
 # Dialog units are used so the UI displays correctly with the system's DPI
 # settings.
 # The dialog units for the bitmap's dimensions should match exactly with the
--- a/browser/installer/windows/nsis/defines.nsi.in
+++ b/browser/installer/windows/nsis/defines.nsi.in
@@ -30,16 +30,18 @@
 !define LSP_CATEGORIES "0x00000000"
 
 # Due to official and beta using the same branding this is needed to
 # differentiante between the url used by the stub for downloading.
 !if "@MOZ_UPDATE_CHANNEL@" == "beta"
 !define BETA_UPDATE_CHANNEL
 !endif
 
+!define BaseURLStubPing "http://download-stats.mozilla.org/stub/v1/"
+
 # NO_INSTDIR_FROM_REG is defined for pre-releases which have a PreReleaseSuffix
 # (e.g. Alpha X, Beta X, etc.) to prevent finding a non-default installation
 # directory in the registry and using that as the default. This prevents
 # Beta releases built with official branding from finding an existing install
 # of an official release and defaulting to its installation directory.
 !if "@PRE_RELEASE_SUFFIX@" != ""
 !define NO_INSTDIR_FROM_REG
 !endif
--- a/browser/installer/windows/nsis/stub.nsi
+++ b/browser/installer/windows/nsis/stub.nsi
@@ -28,16 +28,17 @@ Var LabelDownloadingDown
 Var LabelDownloadingInProgress
 Var LabelInstallingInProgress
 Var LabelInstallingToBeDone
 Var LabelFreeSpace
 Var CheckboxSetAsDefault
 Var CheckboxShortcutOnBar ; Used for Quicklaunch or Taskbar as appropriate
 Var CheckboxShortcutInStartMenu
 Var CheckboxShortcutOnDesktop
+Var CheckboxSendPing
 Var CheckboxInstallMaintSvc
 Var DirRequest
 Var ButtonBrowse
 Var LabelBlurb1
 Var LabelBlurb2
 Var LabelBlurb3
 Var BitmapBlurb1
 Var BitmapBlurb2
@@ -61,19 +62,35 @@ Var DownloadReset
 Var ExistingTopDir
 Var SpaceAvailableBytes
 Var InitialInstallDir
 Var HandleDownload
 Var CanSetAsDefault
 Var TmpVal
 Var InstallCounterStep
 
+Var ExitCode
+Var SecondsToDownload
+Var ExistingProfile
+Var ExistingInstall
+Var DownloadedAmount
+Var FirefoxLaunch
+
 Var HEIGHT_PX
 Var CTL_RIGHT_PX
 
+!define ERR_SUCCESS 0
+!define ERR_CANCEL_DOWNLOAD 10
+!define ERR_INVALID_HANDLE 11
+!define ERR_CERT_UNTRUSTED 12
+!define ERR_CERT_ATTRIBUTES 13
+!define ERR_CERT_UNTRUSTED_AND_ATTRIBUTES 14
+!define ERR_CHECK_INSTALL_TIMEOUT 15
+!define ERR_UNKNOWN 99
+
 !define DownloadIntervalMS 200 ; Interval for the download timer
 !define InstallIntervalMS 100 ; Interval for the install timer
 
 ; Number of steps for the install progress.
 ; This is 120 seconds with a 100 millisecond timer and a first step of 20 as
 ; defined by InstallProgressFirstStep. This might not be enough when installing
 ; on a slow network drive so it will fallback to downloading the full installer
 ; if it reaches this number. The size of the install progress step increases
@@ -117,16 +134,18 @@ Var CTL_RIGHT_PX
 ; Workaround to support different urls for Official and Beta since they share
 ; the same branding.
 !ifdef Official
 !ifdef BETA_UPDATE_CHANNEL
 !undef URLStubDownload
 !define URLStubDownload "http://download.mozilla.org/?product=firefox-beta-latest&os=win&lang=${AB_CD}"
 !undef URLManualDownload
 !define URLManualDownload "https://www.mozilla.org/firefox/installer-help/?channel=beta"
+!undef Channel
+!define Channel "beta"
 !endif
 !endif
 
 !include "common.nsh"
 
 !insertmacro ElevateUAC
 !insertmacro GetLongPath
 !insertmacro GetPathFromString
@@ -291,16 +310,20 @@ Function .onInit
   ${OrIf} ${AtLeastWin8}
     StrCpy $CanSetAsDefault "false"
     StrCpy $CheckboxSetAsDefault "0"
   ${Else}
     DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
     StrCpy $CanSetAsDefault "true"
   ${EndIf}
 
+  StrCpy $IsDownloadFinished ""
+  StrCpy $FirefoxLaunch 0
+  StrCpy $ExitCode ${ERR_UNKNOWN}
+
   CreateFont $FontBlurb "$(^Font)" "12" "500"
   CreateFont $FontNormal "$(^Font)" "11" "500"
   CreateFont $FontItalic "$(^Font)" "11" "500" /ITALIC
 
   InitPluginsDir
   File /oname=$PLUGINSDIR\bgintro.bmp "bgintro.bmp"
   File /oname=$PLUGINSDIR\bgplain.bmp "bgplain.bmp"
   File /oname=$PLUGINSDIR\appname.bmp "appname.bmp"
@@ -321,40 +344,58 @@ Function .onGUIInit
   ${NSD_AddExStyle} $HWNDPARENT ${WS_EX_LAYOUTRTL}
   ${RemoveExStyle} $HWNDPARENT ${WS_EX_RTLREADING}
   ${RemoveExStyle} $HWNDPARENT ${WS_EX_RIGHT}
   ${NSD_AddExStyle} $HWNDPARENT ${WS_EX_LEFT}|${WS_EX_LTRREADING}
 FunctionEnd
 !endif
 
 Function .onGUIEnd
+  ; The value of $IsDownloadFinished will be false if the download was attempted
+  ; and wasn't completed. Get the seconds elapsed trying to download.
+  ${If} $IsDownloadFinished == "false"
+    Call GetSecondsToDownload
+  ${EndIf}
+
+  ; Try to send a ping if a download was attempted
+  ${If} $IsDownloadFinished != ""
+  ${AndIf} $CheckboxSendPing == 1
+    System::Int64Op $DownloadedAmount / 1024
+    Pop $DownloadedAmount
+    InetBgDL::Get "${BaseURLStubPing}${Channel}/${AB_CD}/$ExitCode/" \
+                  "$FirefoxLaunch/$SecondsToDownload/$DownloadedAmount/" \
+                  "$ExistingProfile/$ExistingInstall/" "$PLUGINSDIR\_temp" /END
+  ${EndIf}
+
   ${UnloadUAC}
 FunctionEnd
 
 Function .onUserAbort
   ${NSD_KillTimer} StartDownload
   ${NSD_KillTimer} OnDownload
   ${NSD_KillTimer} StartInstall
   ${NSD_KillTimer} CheckInstall
   ${NSD_KillTimer} FinishInstall
   ${NSD_KillTimer} DisplayDownloadError
 
+  Delete "$PLUGINSDIR\_temp"
   Delete "$PLUGINSDIR\download.exe"
   Delete "$PLUGINSDIR\${CONFIG_INI}"
 FunctionEnd
 
 Function createDummy
 FunctionEnd
 
 Function createIntro
   ; If Back is clicked on the options page reset variables
   StrCpy $INSTDIR "$InitialInstallDir"
   StrCpy $CheckboxShortcutOnBar 1
   StrCpy $CheckboxShortcutInStartMenu 1
   StrCpy $CheckboxShortcutOnDesktop 1
+  StrCpy $CheckboxSendPing 1
 !ifdef MOZ_MAINTENANCE_SERVICE
   StrCpy $CheckboxInstallMaintSvc 1
 !else
   StrCpy $CheckboxInstallMaintSvc 0
 !endif
 
   nsDialogs::Create /NOUNLOAD 1018
   Pop $Dialog
@@ -585,16 +626,26 @@ Function createOptions
   ; UpdateFreeSpaceLabel
   ${NSD_CreateLabel} $CTL_RIGHT_PX 145u 100% $HEIGHT_PX " "
   Pop $LabelFreeSpace
   SetCtlColors $LabelFreeSpace ${OPTIONS_TEXT_COLOR_NORMAL} ${OPTIONS_BKGRD_COLOR}
   SendMessage $LabelFreeSpace ${WM_SETFONT} $FontNormal 0
 
   Call UpdateFreeSpaceLabel
 
+  ${NSD_CreateCheckbox} ${OPTIONS_ITEM_EDGE_DU} 168u ${OPTIONS_SUBITEM_WIDTH_DU} \
+                        12u "$(SEND_PING)"
+  Pop $CheckboxSendPing
+  ; The uxtheme must be disabled on checkboxes in order to override the system
+  ; font color.
+  System::Call 'uxtheme::SetWindowTheme(i $CheckboxSendPing, w " ", w " ")'
+  SetCtlColors $CheckboxSendPing ${OPTIONS_TEXT_COLOR_NORMAL} ${OPTIONS_BKGRD_COLOR}
+  SendMessage $CheckboxSendPing ${WM_SETFONT} $FontNormal 0
+  ${NSD_Check} $CheckboxSendPing
+
 !ifdef MOZ_MAINTENANCE_SERVICE
   ; Only show the maintenance service checkbox if we have write access to HKLM
   Call IsUserAdmin
   Pop $0
   ClearErrors
   WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" \
                    "Write Test"
   ${If} ${Errors}
@@ -602,17 +653,17 @@ Function createOptions
     StrCpy $CheckboxInstallMaintSvc "0"
   ${Else}
     DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
     ; Read the registry instead of using ServicesHelper::IsInstalled so the
     ; plugin isn't included in the stub installer to lessen its size.
     ClearErrors
     ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\services\MozillaMaintenance" "ImagePath"
     ${If} ${Errors}
-      ${NSD_CreateCheckbox} ${OPTIONS_ITEM_EDGE_DU} 175u ${OPTIONS_ITEM_WIDTH_DU} \
+      ${NSD_CreateCheckbox} ${OPTIONS_ITEM_EDGE_DU} 184u ${OPTIONS_ITEM_WIDTH_DU} \
                             12u "$(INSTALL_MAINT_SERVICE)"
       Pop $CheckboxInstallMaintSvc
       System::Call 'uxtheme::SetWindowTheme(i $CheckboxInstallMaintSvc, w " ", w " ")'
       SetCtlColors $CheckboxInstallMaintSvc ${OPTIONS_TEXT_COLOR_NORMAL} ${OPTIONS_BKGRD_COLOR}
       SendMessage $CheckboxInstallMaintSvc ${WM_SETFONT} $FontNormal 0
       ${NSD_Check} $CheckboxInstallMaintSvc
     ${EndIf}
   ${EndIf}
@@ -663,16 +714,17 @@ Function leaveOptions
     LockWindow off
     MessageBox MB_OK|MB_ICONEXCLAMATION "$(WARN_DISK_SPACE)"
     Abort ; Stay on the page
   ${EndIf}
 
   ${NSD_GetState} $CheckboxShortcutOnBar $CheckboxShortcutOnBar
   ${NSD_GetState} $CheckboxShortcutInStartMenu $CheckboxShortcutInStartMenu
   ${NSD_GetState} $CheckboxShortcutOnDesktop $CheckboxShortcutOnDesktop
+  ${NSD_GetState} $CheckboxSendPing $CheckboxSendPing
 !ifdef MOZ_MAINTENANCE_SERVICE
   ${NSD_GetState} $CheckboxInstallMaintSvc $CheckboxInstallMaintSvc
 !endif
 
 FunctionEnd
 
 Function createInstall
   nsDialogs::Create /NOUNLOAD 1018
@@ -811,33 +863,73 @@ Function createInstall
   ${EndIf}
 
   GetDlgItem $0 $HWNDPARENT 11
   SendMessage $0 ${WM_SETTEXT} 0 "STR:$(ONE_MOMENT)"
   SendMessage $0 ${WM_SETFONT} $FontNormal 0
   SetCtlColors $0 ${FOOTER_CONTROL_TEXT_COLOR_FADED} ${FOOTER_BKGRD_COLOR}
   ShowWindow $0 ${SW_SHOW}
 
+  StrCpy $IsDownloadFinished "false"
   StrCpy $DownloadReset "false"
+  StrCpy $ExitCode ${ERR_CANCEL_DOWNLOAD}
+  ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
+    StrCpy $ExistingInstall 1
+  ${Else}
+    StrCpy $ExistingInstall 0
+  ${EndIf}
+
+  ${If} ${FileExists} "$LOCALAPPDATA\Mozilla\Firefox"
+    StrCpy $ExistingProfile 1
+  ${Else}
+    StrCpy $ExistingProfile 0
+  ${EndIf}
+
+  GetTempFileName $2
+  GetFileTime $2 $1 $0
+  Delete $2
+  System::Int64Op $1 * 0x100000000
+  Pop $1
+  System::Int64Op $1 + $0
+  Pop $SecondsToDownload
+
   ${NSD_CreateTimer} StartDownload ${DownloadIntervalMS}
 
   LockWindow off
   nsDialogs::Show
 
   ${NSD_FreeImage} $0
   ${NSD_FreeImage} $1
   ${NSD_FreeImage} $HwndBitmapBlurb1
   ${NSD_FreeImage} $HwndBitmapBlurb2
   ${NSD_FreeImage} $HWndBitmapBlurb3
 FunctionEnd
 
 Function leaveInstall
 # Need a ping?
 FunctionEnd
 
+; This function is not idempotent. It calculates the amount of time between now
+; and $SecondsToDownload and stores the results back into $SecondsToDownload.
+; For that reason it should only be called once for the purpose of determining
+; the number of elapsed seconds to download.
+Function GetSecondsToDownload
+  GetTempFileName $2
+  GetFileTime $2 $1 $0
+  Delete $2
+  System::Int64Op $1 * 0x100000000
+  Pop $1
+  System::Int64Op $1 + $0
+  Pop $0
+  System::Int64Op $0 - $SecondsToDownload
+  Pop $SecondsToDownload
+  System::Int64Op $SecondsToDownload / 10000000
+  Pop $SecondsToDownload
+FunctionEnd
+
 Function StartDownload
   ${NSD_KillTimer} StartDownload
   InetBgDL::Get "${URLStubDownload}" "$PLUGINSDIR\download.exe" /END
   StrCpy $4 ""
   ${NSD_CreateTimer} OnDownload ${DownloadIntervalMS}
   ${If} ${FileExists} "$INSTDIR\${TO_BE_DELETED}"
     RmDir /r "$INSTDIR\${TO_BE_DELETED}"
   ${EndIf}
@@ -850,16 +942,17 @@ Function OnDownload
   # $2 = Remaining files
   # $3 = Number of downloaded bytes for the current file
   # $4 = Size of current file (Empty string if the size is unknown)
   # /RESET must be used if status $0 > 299 (e.g. failure)
   # When status is $0 =< 299 it is handled by InetBgDL
   ${If} $0 > 299
     ${NSD_KillTimer} OnDownload
     ${If} "$DownloadReset" != "true"
+      StrCpy $DownloadedAmount 0
       ${NSD_AddStyle} $ProgressbarDownload ${PBS_MARQUEE}
       SendMessage $ProgressbarDownload ${PBM_SETMARQUEE} 1 10 ; start=1|stop=0 interval(ms)=+N
     ${EndIf}
     InetBgDL::Get /RESET /END
     ${NSD_CreateTimer} StartDownload ${DownloadIntervalMS}
     StrCpy $DownloadReset "true"
     StrCpy $DownloadSize ""
     Return
@@ -888,16 +981,18 @@ Function OnDownload
   ${If} $IsDownloadFinished != "true"
     ${If} $2 == 0
       ${NSD_KillTimer} OnDownload
       StrCpy $IsDownloadFinished "true"
       ; The first step of the install progress bar is determined by the
       ; InstallProgressFirstStep define and provides the user with immediate
       ; feedback.
       StrCpy $InstallCounterStep ${InstallProgressFirstStep}
+      Call GetSecondsToDownload
+      StrCpy $DownloadedAmount $DownloadSize
       LockWindow on
       ; Update the progress bars first in the UI change so they take affect
       ; before other UI changes.
       SendMessage $ProgressbarDownload ${PBM_SETPOS} $DownloadSize 0
       SendMessage $ProgressbarInstall ${PBM_SETPOS} $InstallCounterStep 0
       ShowWindow $LabelDownloadingInProgress ${SW_HIDE}
       ShowWindow $LabelInstallingToBeDone ${SW_HIDE}
       ShowWindow $LabelInstallingInProgress ${SW_SHOW}
@@ -915,24 +1010,33 @@ Function OnDownload
       StrCpy $R9 "${INVALID_HANDLE_VALUE}"
       System::Call 'kernel32::CreateFileW(w "$PLUGINSDIR\download.exe", \
                                           i ${GENERIC_READ}, \
                                           i ${FILE_SHARE_READ}, i 0, \
                                           i ${OPEN_EXISTING}, i 0, i 0) i .R9'
       StrCpy $HandleDownload "$R9"
 
       ${If} $HandleDownload == ${INVALID_HANDLE_VALUE}
+        StrCpy $ExitCode ${ERR_INVALID_HANDLE}
         StrCpy $0 "0"
         StrCpy $1 "0"
       ${Else}
         CertCheck::VerifyCertTrust "$PLUGINSDIR\download.exe"
         Pop $0
         CertCheck::VerifyCertNameIssuer "$PLUGINSDIR\download.exe" \
                                         "${CertNameDownload}" "${CertIssuerDownload}"
         Pop $1
+        ${If} $0 == 0
+        ${AndIf} $1 == 0
+          StrCpy $ExitCode ${ERR_CERT_UNTRUSTED_AND_ATTRIBUTES}
+        ${ElseIf} $0 == 0
+          StrCpy $ExitCode ${ERR_CERT_UNTRUSTED}
+        ${ElseIf}  $1 == 0
+          StrCpy $ExitCode ${ERR_CERT_ATTRIBUTES}
+        ${EndIf}
       ${EndIf}
 
       ${If} $0 == 0
       ${OrIf} $1 == 0
         ; Use a timer so the UI has a chance to update
         ${NSD_CreateTimer} DisplayDownloadError ${InstallIntervalMS}
         Return
       ${EndIf}
@@ -993,16 +1097,17 @@ Function OnDownload
         StrCpy $HalfOfDownload "true"
         LockWindow on
         ShowWindow $LabelBlurb1 ${SW_HIDE}
         ShowWindow $BitmapBlurb1 ${SW_HIDE}
         ShowWindow $LabelBlurb2 ${SW_SHOW}
         ShowWindow $BitmapBlurb2 ${SW_SHOW}
         LockWindow off
       ${EndIf}
+      StrCpy $DownloadedAmount $3
       SendMessage $ProgressbarDownload ${PBM_SETPOS} $3 0
     ${EndIf}
   ${EndIf}
 FunctionEnd
 
 Function StartInstall
   ${NSD_KillTimer} StartInstall
 
@@ -1016,16 +1121,17 @@ Function StartInstall
 FunctionEnd
 
 Function CheckInstall
   IntOp $InstallCounterStep $InstallCounterStep + 1
   ${If} $InstallCounterStep >= ${InstallProgresSteps} 
     ${NSD_KillTimer} CheckInstall
     ; Close the handle that prevents modification of the full installer
     System::Call 'kernel32::CloseHandle(i $HandleDownload)'
+    StrCpy $ExitCode ${ERR_CHECK_INSTALL_TIMEOUT}
     ; Use a timer so the UI has a chance to update
     ${NSD_CreateTimer} DisplayDownloadError ${InstallIntervalMS}
     Return
   ${EndIf}
 
   SendMessage $ProgressbarInstall ${PBM_SETPOS} $InstallCounterStep 0
 
   ${If} ${FileExists} "$INSTDIR\install.log"
@@ -1090,16 +1196,18 @@ Function FinishInstall
     ${EndIf}
   ${EndIf}
 
   ${If} ${FileExists} "$INSTDIR\${FileMainEXE}.moz-upgrade"
     Delete "$INSTDIR\${FileMainEXE}"
     Rename "$INSTDIR\${FileMainEXE}.moz-upgrade" "$INSTDIR\${FileMainEXE}"
   ${EndIf}
 
+  StrCpy $ExitCode ${ERR_SUCCESS}
+
   Call LaunchApp
 
   ; The following will exit the installer
   SetAutoClose true
   StrCpy $R9 2
   Call RelativeGotoPage
 FunctionEnd
 
@@ -1304,20 +1412,23 @@ Function ExecSetAsDefaultAppUser
   ; Using the helper.exe lessens the stub installer size.
   ; This could ask for elevatation when the user doesn't install as admin.
   Exec "$\"$INSTDIR\uninstall\helper.exe$\" /SetAsDefaultAppUser"
 FunctionEnd
 
 Function LaunchApp
   FindWindow $0 "${WindowClass}"
   ${If} $0 <> 0 ; integer comparison
+    StrCpy $FirefoxLaunch 1
     MessageBox MB_OK|MB_ICONQUESTION "$(WARN_MANUALLY_CLOSE_APP_LAUNCH)"
     Return
   ${EndIf}
 
+  StrCpy $FirefoxLaunch 2
+
   ClearErrors
   ${GetParameters} $0
   ${GetOptions} "$0" "/UAC:" $1
   ${If} ${Errors}
     Exec "$\"$INSTDIR\${FileMainEXE}$\""
   ${Else}
     GetFunctionAddress $0 LaunchAppFromElevatedProcess
     UAC::ExecCodeSegment $0
--- a/browser/locales/en-US/installer/nsisstrings.properties
+++ b/browser/locales/en-US/installer/nsisstrings.properties
@@ -44,16 +44,17 @@ CREATE_SHORTCUTS=Create Shortcuts for $B
 ADD_SC_TASKBAR=On my &Task bar
 ADD_SC_QUICKLAUNCHBAR=On my &Quick Launch bar
 ADD_CheckboxShortcutInStartMenu=In my &Start Menu Programs Folder
 ADD_CheckboxShortcutOnDesktop=On my &Desktop
 SPACE_REQUIRED=Space Required:
 SPACE_AVAILABLE=Space Available:
 ONE_MOMENT=One moment, $BrandShortName will launch as soon as the install is complete…
 INSTALL_MAINT_SERVICE=&Install the $BrandShortName background update service
+SEND_PING=S&end information about this installation to Mozilla
 BROWSE_BUTTON=B&rowse…
 DEST_FOLDER=Destination Folder
 
 DOWNLOADING_IN_PROGRESS=Downloading…
 DOWNLOADING_DONE=Downloaded
 INSTALLING_TO_BE_DONE=Installing
 INSTALLING_IN_PROGRESS=Installing…
 
--- a/dom/sms/tests/marionette/manifest.ini
+++ b/dom/sms/tests/marionette/manifest.ini
@@ -6,9 +6,8 @@ qemu = true
 ;[test_between_emulators.py]
 [test_incoming.js]
 [test_outgoing.js]
 [test_message_classes.js]
 [test_incoming_delete.js]
 [test_outgoing_delete.js]
 [test_getmessage.js]
 [test_getmessage_notfound.js]
-[test_timestamp.js]
deleted file mode 100644
--- a/dom/sms/tests/marionette/test_timestamp.js
+++ /dev/null
@@ -1,189 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-MARIONETTE_TIMEOUT = 15000;
-
-SpecialPowers.setBoolPref("dom.sms.enabled", true);
-SpecialPowers.addPermission("sms", true, document);
-
-let sms = window.navigator.mozSms;
-let inText;
-let remoteNumber = "5559997777";
-let outText;
-let gotSmsOnsent;
-let gotReqOnsuccess;
-let inSmsId = 0;
-let outSmsId = 0;
-let inSmsTime = 0;
-let outSmsTime = 0;
-let testCount = 10;
-
-function verifyInitialState() {
-  log("Verifying initial state.");
-  ok(sms, "mozSms");
-  simulateIncomingSms();  
-}
-
-function simulateIncomingSms() {
-  log("Simulating incoming SMS.");
-
-  sms.onreceived = function onreceived(event) {
-    log("Received 'onreceived' smsmanager event.");
-    let incomingSms = event.message;
-    ok(incomingSms, "incoming sms");
-    ok(incomingSms.id, "sms id");
-    inSmsId = incomingSms.id;
-    is(incomingSms.body, inText, "msg body");
-    is(incomingSms.delivery, "received", "delivery");
-    is(incomingSms.read, false, "read");
-    is(incomingSms.receiver, null, "receiver");
-    is(incomingSms.sender, remoteNumber, "sender");
-    is(incomingSms.messageClass, "normal", "messageClass");
-    ok(incomingSms.timestamp instanceof Date, "timestamp is instanceof date");
-    // The max resolution of the SCTS (SMS Centre TimeStamp) is one second
-    // therefore we want to compare in seconds not milliseconds. No need to
-    // round received sms timestamp, the value is in milliseconds but at
-    // seconds resolution already (always ends with 000) so just convert
-    inSmsTime = Math.floor(incomingSms.timestamp.getTime() / 1000);
-    log("Received SMS (id: " + inSmsId + ") timestamp: " + inSmsTime + ".");
-    if(outSmsTime) {
-      // Test is repeating; compare received SMS timestamp with last sent sms.
-      // Can be some time drift between the SCTS and host/emulator, but we are
-      // comparing seconds (not milliseconds) so should be ok. If this test
-      // goes random orange, then may need to add a 1 second lee-way here.
-      if(inSmsTime >= outSmsTime) {
-        log("Timestamp in sms " + inSmsId + " is >= timestamp in sms "
-            + outSmsId + ".");
-      } else {
-        log("* Timestamp in sms " + inSmsId + " is < timestamp in sms "
-            + outSmsId + ".");
-        ok(false, "sms timestamp is incorrect");
-      }
-    }
-    sendSms();
-  };
-  // Simulate incoming sms sent from remoteNumber to our emulator
-  inText = "Incoming SMS " + Date.now();
-  runEmulatorCmd("sms send " + remoteNumber + " " + inText, function(result) {
-    is(result[0], "OK", "emulator output");
-  });
-}
-
-function sendSms() {
-  log("Sending an SMS.");
-  let gotSmsOnsent = false;
-  let gotReqOnsuccess = false;  
-  sms.onsent = function(event) {
-    log("Received 'onsent' smsmanager event.");
-    gotSmsOnsent = true;
-    let sentSms = event.message;
-    ok(sentSms, "outgoing sms");
-    ok(sentSms.id, "sms id");
-    outSmsId = sentSms.id;
-    is(sentSms.body, outText, "msg body");
-    is(sentSms.delivery, "sent", "delivery");
-    is(sentSms.read, true, "read");
-    is(sentSms.receiver, remoteNumber, "receiver");
-    is(sentSms.sender, null, "sender");
-    is(sentSms.messageClass, "normal", "messageClass");
-    ok(sentSms.timestamp instanceof Date, "timestamp is instanceof date");
-    // The max resolution of the SCTS (SMS Centre TimeStamp) is one second
-    // therefore we want to compare in seconds not milliseconds. Round the
-    // sent sms timestamp to nearest second.
-    outSmsTime = Math.round(sentSms.timestamp.getTime() / 1000);
-    log("Sent SMS (id: " + outSmsId + ") timestamp: " + outSmsTime + ".");
-
-    if (gotSmsOnsent && gotReqOnsuccess) { verifyTimeStamps(); }
-  };
-  outText = "Outgoing SMS " + Date.now();
-  let requestRet = sms.send(remoteNumber, outText);
-  ok(requestRet, "smsrequest obj returned");
-
-  requestRet.onsuccess = function(event) {
-    log("Received 'onsuccess' smsrequest event.");
-    gotReqOnsuccess = true;
-    if(event.target.result){
-      if (gotSmsOnsent && gotReqOnsuccess) { verifyTimeStamps(); }
-    } else {
-      log("smsrequest returned false for sms.send");
-      ok(false,"SMS send failed");
-      cleanUp();
-    }
-  };
-
-  requestRet.onerror = function(event) {
-    log("Received 'onerror' smsrequest event.");
-    ok(event.target.error, "domerror obj");
-    ok(false, "sms.send request returned unexpected error: "
-        + event.target.error.name );
-    cleanUp();
-  };
-}
-
-function verifyTimeStamps() {
-  // Compare sent sms timestamp with that of the previously received sms.
-  // Can be some time drift between the SCTS and host/emulator, but we are
-  // comparing seconds (not milliseconds) so should be ok. If this test
-  // goes random orange, then may need to add a 1 second lee-way here.
-  if(outSmsTime >= inSmsTime) {
-    log("Timestamp in sms " + outSmsId + " is >= timestamp in sms "
-        + inSmsId + ".");
-  } else {
-    log("* Timestamp in sms " + outSmsId + " is < timestamp in sms "
-        + inSmsId + ".");
-    ok(false, "sms timestamp is incorrect");
-  }
-  deleteMsgs();
-}
-
-function deleteMsgs() {
-  log("Deleting SMS (id: " + inSmsId + ").");
-  let requestRet = sms.delete(inSmsId);
-  ok(requestRet,"smsrequest obj returned");
-
-  requestRet.onsuccess = function(event) {
-    log("Received 'onsuccess' smsrequest event.");
-    if(event.target.result){
-      log("Deleting SMS (id: " + outSmsId + ").");
-      let nextReqRet = sms.delete(outSmsId);
-      ok(nextReqRet,"smsrequest obj returned");
-
-      nextReqRet.onsuccess = function(event) {
-        log("Received 'onsuccess' smsrequest event.");
-        if(event.target.result) {
-          if(--testCount) {
-            simulateIncomingSms();
-          } else {
-            cleanUp();
-          }
-        } else {
-          log("smsrequest returned false for sms.delete");
-          ok(false,"SMS delete failed");
-          cleanUp();
-        }
-      };
-    } else {
-      log("smsrequest returned false for sms.delete");
-      ok(false,"SMS delete failed");
-      cleanUp();
-    }
-  };
-
-  requestRet.onerror = function(event) {
-    log("Received 'onerror' smsrequest event.");
-    ok(event.target.error, "domerror obj");
-    ok(false, "sms.delete request returned unexpected error: "
-        + event.target.error.name );
-    cleanUp();
-  };
-}
-
-function cleanUp() {
-  sms.onreceived = null;
-  SpecialPowers.removePermission("sms", document);
-  SpecialPowers.setBoolPref("dom.sms.enabled", false);
-  finish();
-}
-
-// Start the test
-verifyInitialState();
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -1410,17 +1410,16 @@ nsHttpHandler::GetProtocolFlags(uint32_t
 }
 
 NS_IMETHODIMP
 nsHttpHandler::NewURI(const nsACString &aSpec,
                       const char *aCharset,
                       nsIURI *aBaseURI,
                       nsIURI **aURI)
 {
-    LOG(("nsHttpHandler::NewURI\n"));
     return ::NewURI(aSpec, aCharset, aBaseURI, NS_HTTP_DEFAULT_PORT, aURI);
 }
 
 NS_IMETHODIMP
 nsHttpHandler::NewChannel(nsIURI *uri, nsIChannel **result)
 {
     LOG(("nsHttpHandler::NewChannel\n"));
 
--- a/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -91,18 +91,21 @@ Tester.prototype = {
     if (!gConfig)
       gConfig = readConfig();
     this.repeat = gConfig.repeat;
     this.dumper.dump("*** Start BrowserChrome Test Results ***\n");
     Services.console.registerListener(this);
     Services.obs.addObserver(this, "chrome-document-global-created", false);
     Services.obs.addObserver(this, "content-document-global-created", false);
     this._globalProperties = Object.keys(window);
-    this._globalPropertyWhitelist = ["navigator", "constructor", "Application",
-      "__SS_tabsToRestore", "__SSi", "webConsoleCommandController",
+    this._globalPropertyWhitelist = [
+      "navigator", "constructor", "top",
+      "Application",
+      "__SS_tabsToRestore", "__SSi",
+      "webConsoleCommandController",
     ];
 
     if (this.tests.length)
       this.nextTest();
     else
       this.finish();
   },
 
--- a/toolkit/mozapps/installer/windows/nsis/makensis.mk
+++ b/toolkit/mozapps/installer/windows/nsis/makensis.mk
@@ -41,16 +41,19 @@ CUSTOM_UI = \
 
 $(CONFIG_DIR)/setup.exe::
 	$(INSTALL) $(addprefix $(MOZILLA_DIR)/toolkit/mozapps/installer/windows/nsis/,$(TOOLKIT_NSIS_FILES)) $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(MOZILLA_DIR)/other-licenses/nsis/Plugins/,$(CUSTOM_NSIS_PLUGINS)) $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(MOZILLA_DIR)/other-licenses/nsis/,$(CUSTOM_UI)) $(CONFIG_DIR)
 	cd $(CONFIG_DIR) && $(MAKENSISU) installer.nsi
 ifdef MOZ_STUB_INSTALLER
 	cd $(CONFIG_DIR) && $(MAKENSISU) stub.nsi
+ifdef MOZ_EXTERNAL_SIGNING_FORMAT
+	$(MOZ_SIGN_CMD) $(foreach f,$(MOZ_EXTERNAL_SIGNING_FORMAT),-f $(f)) $(CONFIG_DIR)/stub.exe
+endif
 endif
 # Support for building the uninstaller when repackaging locales
 ifeq ($(CONFIG_DIR),l10ngen)
 	cd $(CONFIG_DIR) && $(MAKENSISU) uninstaller.nsi
 endif
 ifdef MOZ_EXTERNAL_SIGNING_FORMAT
 	$(MOZ_SIGN_CMD) $(foreach f,$(MOZ_EXTERNAL_SIGNING_FORMAT),-f $(f)) "$@"
 endif
@@ -66,19 +69,16 @@ installer::
 	cat $(CONFIG_DIR)/7zSD.sfx $(CONFIG_DIR)/app.tag $(CONFIG_DIR)/app.7z > "$(DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe"
 	chmod 0755 "$(DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe"
 ifdef MOZ_STUB_INSTALLER
 	cp $(CONFIG_DIR)/stub.exe "$(DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME)-stub.exe"
 	chmod 0755 "$(DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME)-stub.exe"
 endif
 ifdef MOZ_EXTERNAL_SIGNING_FORMAT
 	$(MOZ_SIGN_CMD) $(foreach f,$(MOZ_EXTERNAL_SIGNING_FORMAT),-f $(f)) "$(DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe"
-ifdef MOZ_STUB_INSTALLER
-	$(MOZ_SIGN_CMD) $(foreach f,$(MOZ_EXTERNAL_SIGNING_FORMAT),-f $(f)) "$(DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME)-stub.exe"
-endif
 endif
 
 # For building the uninstaller during the application build so it can be
 # included for mar file generation.
 uninstaller::
 	$(INSTALL) $(addprefix $(MOZILLA_DIR)/toolkit/mozapps/installer/windows/nsis/,$(TOOLKIT_NSIS_FILES)) $(CONFIG_DIR)
 	$(INSTALL) $(addprefix $(MOZILLA_DIR)/other-licenses/nsis/Plugins/,$(CUSTOM_NSIS_PLUGINS)) $(CONFIG_DIR)
 	cd $(CONFIG_DIR) && $(MAKENSISU) uninstaller.nsi