Bug 1176112 - A/B test for default browser setting UI on Windows 10. r=Gijs
authorJared Wein <jwein@mozilla.com>
Sat, 20 Jun 2015 01:16:05 -0400
changeset 249963 8a504c99c379341f06e02f68474b9a6c02d48e0a
parent 249962 bdb753f106949373c889007851291e2a2794c512
child 249964 84552fc81f5f2d3570b7d50ad925dbe7bc5ed89e
push id61393
push usercbook@mozilla.com
push dateMon, 22 Jun 2015 12:44:45 +0000
treeherdermozilla-inbound@4b47c3f074a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1176112
milestone41.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 1176112 - A/B test for default browser setting UI on Windows 10. r=Gijs
browser/app/profile/firefox.js
browser/components/nsBrowserGlue.js
browser/components/shell/nsWindowsShellService.cpp
toolkit/components/telemetry/Histograms.json
toolkit/modules/AppConstants.jsm
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -266,16 +266,17 @@ pref("general.autoScroll", false);
 #else
 pref("general.autoScroll", true);
 #endif
 
 // At startup, check if we're the default browser and prompt user if not.
 pref("browser.shell.checkDefaultBrowser", true);
 pref("browser.shell.shortcutFavicons",true);
 pref("browser.shell.mostRecentDateSetAsDefault", "");
+pref("browser.shell.windows10DefaultBrowserABTest", -1);
 
 // 0 = blank, 1 = home (browser.startup.homepage), 2 = last visited page, 3 = resume previous browser session
 // The behavior of option 3 is detailed at: http://wiki.mozilla.org/Session_Restore
 pref("browser.startup.page",                1);
 pref("browser.startup.homepage",            "chrome://branding/locale/browserconfig.properties");
 
 pref("browser.slowStartup.notificationDisabled", false);
 pref("browser.slowStartup.timeThreshold", 40000);
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -161,16 +161,19 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource:///modules/ReaderParent.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "AddonWatcher",
                                   "resource://gre/modules/AddonWatcher.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
                                   "resource://gre/modules/LightweightThemeManager.jsm");
 
+XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
+                                  "resource://gre/modules/AppConstants.jsm");
+
 const PREF_PLUGINS_NOTIFYUSER = "plugins.update.notifyUser";
 const PREF_PLUGINS_UPDATEURL  = "plugins.update.url";
 
 // Seconds of idle before trying to create a bookmarks backup.
 const BOOKMARKS_BACKUP_IDLE_TIME_SEC = 8 * 60;
 // Minimum interval between backups.  We try to not create more than one backup
 // per interval.
 const BOOKMARKS_BACKUP_MIN_INTERVAL_DAYS = 1;
@@ -1120,16 +1123,27 @@ BrowserGlue.prototype = {
       }
       catch (ex) { /* Don't break the default prompt if telemetry is broken. */ }
 
       if (isDefault) {
         let now = Date.now().toString().slice(0, -3);
         Services.prefs.setCharPref("browser.shell.mostRecentDateSetAsDefault", now);
       }
 
+      if (Services.prefs.getIntPref("browser.shell.windows10DefaultBrowserABTest") == -1) {
+        let abTest = Math.round(Math.random());
+        Services.prefs.setIntPref("browser.shell.windows10DefaultBrowserABTest", abTest);
+      }
+
+      if (AppConstants.isPlatformAndVersionAtLeast("win", "10")) {
+        let abTest = Services.prefs.getIntPref("browser.shell.windows10DefaultBrowserABTest");
+        let result = abTest * 2 + Number(isDefault);
+        Services.telemetry.getHistogramById("WIN_10_DEFAULT_BROWSER_AB_TEST").add(result);
+      }
+
       if (shouldCheck && !isDefault && !willRecoverSession) {
         Services.tm.mainThread.dispatch(function() {
           DefaultBrowserCheck.prompt(RecentWindow.getMostRecentBrowserWindow());
         }.bind(this), Ci.nsIThread.DISPATCH_NORMAL);
       }
     }
 
 #ifdef E10S_TESTING_ONLY
--- a/browser/components/shell/nsWindowsShellService.cpp
+++ b/browser/components/shell/nsWindowsShellService.cpp
@@ -739,16 +739,17 @@ nsWindowsShellService::SetDefaultBrowser
 
   if (aForAllUsers) {
     appHelperPath.AppendLiteral(" /SetAsDefaultAppGlobal");
   } else {
     appHelperPath.AppendLiteral(" /SetAsDefaultAppUser");
   }
 
   nsresult rv = LaunchHelper(appHelperPath);
+  nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
   if (NS_SUCCEEDED(rv) && IsWin8OrLater()) {
     if (aClaimAllTypes) {
       if (IsWin10OrLater()) {
         rv = LaunchModernSettingsDialogDefaultApps();
       } else {
         rv = LaunchControlPanelDefaultPrograms();
       }
       // The above call should never really fail, but just in case
@@ -756,38 +757,44 @@ nsWindowsShellService::SetDefaultBrowser
       if (NS_FAILED(rv)) {
         if (IsWin10OrLater()) {
           rv = InvokeHTTPOpenAsVerb();
         } else {
           rv = LaunchHTTPHandlerPane();
         }
       }
     } else {
-      // Windows 10 blocks attempts to load the HTTP Handler
-      // association dialog, so the modern Settings dialog
-      // is opened with the Default Apps view loaded.
+      // Windows 10 blocks attempts to load the
+      // HTTP Handler association dialog.
       if (IsWin10OrLater()) {
-        rv = InvokeHTTPOpenAsVerb();
+        if (prefs) {
+          int32_t abTest;
+          rv = prefs->GetIntPref("browser.shell.windows10DefaultBrowserABTest", &abTest);
+          if (NS_SUCCEEDED(rv) && abTest == 0) {
+            rv = InvokeHTTPOpenAsVerb();
+          } else {
+            rv = LaunchModernSettingsDialogDefaultApps();
+          }
+        }
       } else {
         rv = LaunchHTTPHandlerPane();
       }
 
       // The above call should never really fail, but just in case
       // fall back to showing control panel for all defaults
       if (NS_FAILED(rv)) {
         if (IsWin10OrLater()) {
           rv = LaunchModernSettingsDialogDefaultApps();
         } else {
           rv = LaunchControlPanelDefaultPrograms();
         }
       }
     }
   }
 
-  nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
   if (prefs) {
     (void) prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, true);
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -6875,16 +6875,23 @@
     "n_buckets": "100",
     "description": "The mean number of pinned tabs (app tabs) in all windows for a session for devtools users."
   },
   "BROWSER_IS_USER_DEFAULT": {
     "expires_in_version": "never",
     "kind": "boolean",
     "description": "The result of the startup default desktop browser check."
   },
+  "WIN_10_DEFAULT_BROWSER_AB_TEST": {
+    "alert_emails": ["jwein@mozilla.com"],
+    "expires_in_version": "45",
+    "kind": "enumerated",
+    "n_values": 4,
+    "description": "A/B test of different default browser dialogs on Windows 10 (0=openas-notdefault, 1=openas-default, 2=modernsettings-notdefault, 3=modernsettings-default)."
+  },
   "BROWSER_IS_ASSIST_DEFAULT": {
     "expires_in_version": "never",
     "kind": "boolean",
     "description": "The result of the default browser check for assist intent."
   },
   "MIXED_CONTENT_PAGE_LOAD": {
     "expires_in_version": "never",
     "kind": "enumerated",
--- a/toolkit/modules/AppConstants.jsm
+++ b/toolkit/modules/AppConstants.jsm
@@ -1,15 +1,18 @@
 #filter substitution
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm");
+
 this.EXPORTED_SYMBOLS = ["AppConstants"];
 
 // Immutable for export.
 this.AppConstants = Object.freeze({
   // See this wiki page for more details about channel specific build
   // defines: https://wiki.mozilla.org/Platform/Channel-specific_build_defines
   NIGHTLY_BUILD:
 #ifdef NIGHTLY_BUILD
@@ -125,16 +128,22 @@ this.AppConstants = Object.freeze({
 #elif MOZ_WIDGET_GONK
   "gonk",
 #elif XP_LINUX
   "linux",
 #else
   "other",
 #endif
 
+  isPlatformAndVersionAtLeast(platform, version) {
+    let platformVersion = Services.sysinfo.getProperty("version");
+    return platform == this.platform &&
+           Services.vc.compare(platformVersion, version) >= 0;
+  },
+
   MOZ_CRASHREPORTER:
 #ifdef MOZ_CRASHREPORTER
   true,
 #else
   false,
 #endif
 
   MOZ_MAINTENANCE_SERVICE: