Bug 1452890 - Move address bar right-click selection from 'enterSelection' to its own histogram bucket. r=adw
authorMarco Bonardo <mbonardo@mozilla.com>
Fri, 13 Apr 2018 16:11:19 +0200
changeset 467442 eb41147ad8b7973a13912c774977ef729ecfa5bd
parent 467441 7e193e0b874428ab3905591d34b4e2090bc172cc
child 467443 9bab179fb575d83e037804e4457058033a0043b7
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1452890
milestone61.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 1452890 - Move address bar right-click selection from 'enterSelection' to its own histogram bucket. r=adw MozReview-Commit-ID: AcP7Spl0sdZ
browser/base/content/urlbarBindings.xml
browser/modules/BrowserUsageTelemetry.jsm
browser/modules/test/browser/browser_UsageTelemetry_urlbar.js
toolkit/components/telemetry/Histograms.json
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -2452,23 +2452,27 @@ file, You can obtain one at http://mozil
       <handler event="mousedown"><![CDATA[
         // Required to make the xul:label.text-link elements in the search
         // suggestions notification work correctly when clicked on Linux.
         // This is copied from the mousedown handler in
         // browser-search-autocomplete-result-popup, which apparently had a
         // similar problem.
         event.preventDefault();
 
+        if (event.button == 2) {
+          // Right mouse button currently allows to select.
+          this.input.userSelectionBehavior = "rightClick";
+          // Ignore right-clicks.
+          return;
+        }
+
         if (!this.input.speculativeConnectEnabled) {
           return;
         }
-        if (event.button == 2) {
-          // Ignore right-clicks.
-          return;
-        }
+
         // Ensure the user is clicking on an url instead of other buttons
         // on the popup.
         let elt = event.originalTarget;
         while (elt && elt.localName != "richlistitem" && elt != this) {
           elt = elt.parentNode;
         }
         if (!elt || elt.localName != "richlistitem") {
           return;
--- a/browser/modules/BrowserUsageTelemetry.jsm
+++ b/browser/modules/BrowserUsageTelemetry.jsm
@@ -78,16 +78,17 @@ const URLBAR_SELECTED_RESULT_TYPES = {
  * these category names directly when they add to a histogram.
  */
 const URLBAR_SELECTED_RESULT_METHODS = {
   enter: 0,
   enterSelection: 1,
   click: 2,
   arrowEnterSelection: 3,
   tabEnterSelection: 4,
+  rightClickEnter: 5,
 };
 
 
 const MINIMUM_TAB_COUNT_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes, in ms
 
 
 function getOpenTabsAndWinsCounts() {
   let tabCount = 0;
@@ -560,16 +561,20 @@ let BrowserUsageTelemetry = {
     } else if (highlightedIndex >= 0) {
       switch (userSelectionBehavior) {
       case "tab":
         category = "tabEnterSelection";
         break;
       case "arrow":
         category = "arrowEnterSelection";
         break;
+      case "rightClick":
+        // Selected by right mouse button.
+        category = "rightClickEnter";
+        break;
       default:
         category = "enterSelection";
       }
     } else {
       category = "enter";
     }
     histogram.add(category);
   },
--- a/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js
+++ b/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js
@@ -47,33 +47,63 @@ let searchInAwesomebar = async function(
                                                 Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH);
 };
 
 /**
  * Click one of the entries in the urlbar suggestion popup.
  *
  * @param {String} entryName
  *        The name of the elemet to click on.
+ * @param {Number} button [optional]
+ *        which button to click.
  */
-function clickURLBarSuggestion(entryName) {
+function clickURLBarSuggestion(entryName, button = 1) {
   // The entry in the suggestion list should follow the format:
   // "<search term> <engine name> Search"
   const expectedSuggestionName = entryName + " " + SUGGESTION_ENGINE_NAME + " Search";
   return BrowserTestUtils.waitForCondition(() => {
     for (let child of gURLBar.popup.richlistbox.children) {
       if (child.label === expectedSuggestionName) {
         // This entry is the search suggestion we're looking for.
-        child.click();
+        if (button == 1)
+          child.click();
+        else if (button == 2) {
+          EventUtils.synthesizeMouseAtCenter(child, {type: "mousedown", button: 2});
+        }
         return true;
       }
     }
     return false;
   }, "Waiting for the expected suggestion to appear");
 }
 
+/**
+ * Create an engine to generate search suggestions and add it as default
+ * for this test.
+ */
+async function withNewSearchEngine(taskFn) {
+  const url = getRootDirectory(gTestPath) + "usageTelemetrySearchSuggestions.xml";
+  let suggestionEngine = await new Promise((resolve, reject) => {
+    Services.search.addEngine(url, null, "", false, {
+      onSuccess(engine) { resolve(engine); },
+      onError() { reject(); }
+    });
+  });
+
+  let previousEngine = Services.search.currentEngine;
+  Services.search.currentEngine = suggestionEngine;
+
+  try {
+    await taskFn(suggestionEngine);
+  } finally {
+    Services.search.currentEngine = previousEngine;
+    Services.search.removeEngine(suggestionEngine);
+  }
+}
+
 add_task(async function setup() {
   // Create a new search engine.
   Services.search.addEngineWithDetails("MozSearch", "", "mozalias", "", "GET",
                                        "http://example.com/?q={searchTerms}");
 
   // Make it the default search engine.
   let engine = Services.search.getEngineByName("MozSearch");
   let originalEngine = Services.search.currentEngine;
@@ -115,17 +145,16 @@ add_task(async function setup() {
     Services.prefs.setBoolPref(SUGGEST_URLBAR_PREF, suggestionsEnabled);
     Services.prefs.clearUserPref(ONEOFF_URLBAR_PREF);
     await PlacesUtils.history.clear();
     Services.telemetry.setEventRecordingEnabled("navigation", false);
   });
 });
 
 add_task(async function test_simpleQuery() {
-  // Let's reset the counts.
   Services.telemetry.clearScalars();
   Services.telemetry.clearEvents();
 
   let resultIndexHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_INDEX");
   let resultTypeHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_TYPE");
   let resultIndexByTypeHist = getAndClearKeyedHistogram("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
   let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
   let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS");
@@ -170,17 +199,16 @@ add_task(async function test_simpleQuery
   checkHistogramResults(resultMethods,
     URLBAR_SELECTED_RESULT_METHODS.enter,
     "FX_URLBAR_SELECTED_RESULT_METHOD");
 
   BrowserTestUtils.removeTab(tab);
 });
 
 add_task(async function test_searchAlias() {
-  // Let's reset the counts.
   Services.telemetry.clearScalars();
   Services.telemetry.clearEvents();
 
   let resultIndexHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_INDEX");
   let resultTypeHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_TYPE");
   let resultIndexByTypeHist = getAndClearKeyedHistogram("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
   let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
   let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS");
@@ -227,17 +255,16 @@ add_task(async function test_searchAlias
     "FX_URLBAR_SELECTED_RESULT_METHOD");
 
   BrowserTestUtils.removeTab(tab);
 });
 
 // Performs a search using the first result, a one-off button, and the Return
 // (Enter) key.
 add_task(async function test_oneOff_enter() {
-  // Let's reset the counts.
   Services.telemetry.clearScalars();
   Services.telemetry.clearEvents();
 
   let resultIndexHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_INDEX");
   let resultTypeHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_TYPE");
   let resultIndexByTypeHist = getAndClearKeyedHistogram("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
   let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
   let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS");
@@ -288,61 +315,45 @@ add_task(async function test_oneOff_ente
 
   BrowserTestUtils.removeTab(tab);
 });
 
 // Performs a search using the second result, a one-off button, and the Return
 // (Enter) key.  This only tests the FX_URLBAR_SELECTED_RESULT_METHOD histogram
 // since test_oneOff_enter covers everything else.
 add_task(async function test_oneOff_enterSelection() {
-  // Let's reset the counts.
   Services.telemetry.clearScalars();
-
   let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
 
-  // Create an engine to generate search suggestions and add it as default
-  // for this test.
-  const url = getRootDirectory(gTestPath) + "usageTelemetrySearchSuggestions.xml";
-  let suggestionEngine = await new Promise((resolve, reject) => {
-    Services.search.addEngine(url, null, "", false, {
-      onSuccess(engine) { resolve(engine); },
-      onError() { reject(); }
-    });
-  });
+  await withNewSearchEngine(async function() {
+    let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
 
-  let previousEngine = Services.search.currentEngine;
-  Services.search.currentEngine = suggestionEngine;
-
-  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
+    info("Type a query. Suggestions should be generated by the test engine.");
+    let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
+    await searchInAwesomebar("query");
 
-  info("Type a query. Suggestions should be generated by the test engine.");
-  let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
-  await searchInAwesomebar("query");
+    info("Select the second result, press Alt+Down to take us to the first one-off engine.");
+    EventUtils.synthesizeKey("KEY_ArrowDown");
+    EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true});
+    EventUtils.synthesizeKey("KEY_Enter");
+    await p;
 
-  info("Select the second result, press Alt+Down to take us to the first one-off engine.");
-  EventUtils.synthesizeKey("KEY_ArrowDown");
-  EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true});
-  EventUtils.synthesizeKey("KEY_Enter");
-  await p;
+    let resultMethods = resultMethodHist.snapshot();
+    checkHistogramResults(resultMethods,
+      URLBAR_SELECTED_RESULT_METHODS.arrowEnterSelection,
+      "FX_URLBAR_SELECTED_RESULT_METHOD");
 
-  let resultMethods = resultMethodHist.snapshot();
-  checkHistogramResults(resultMethods,
-    URLBAR_SELECTED_RESULT_METHODS.arrowEnterSelection,
-    "FX_URLBAR_SELECTED_RESULT_METHOD");
-
-  Services.search.currentEngine = previousEngine;
-  Services.search.removeEngine(suggestionEngine);
-  BrowserTestUtils.removeTab(tab);
+    BrowserTestUtils.removeTab(tab);
+  });
 });
 
 // Performs a search using a click on a one-off button.  This only tests the
 // FX_URLBAR_SELECTED_RESULT_METHOD histogram since test_oneOff_enter covers
 // everything else.
 add_task(async function test_oneOff_click() {
-  // Let's reset the counts.
   Services.telemetry.clearScalars();
 
   let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
 
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
 
   info("Type a query.");
   let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
@@ -356,202 +367,168 @@ add_task(async function test_oneOff_clic
     URLBAR_SELECTED_RESULT_METHODS.click,
     "FX_URLBAR_SELECTED_RESULT_METHOD");
 
   BrowserTestUtils.removeTab(tab);
 });
 
 // Clicks the first suggestion offered by the test search engine.
 add_task(async function test_suggestion_click() {
-  // Let's reset the counts.
   Services.telemetry.clearScalars();
   Services.telemetry.clearEvents();
 
   let resultIndexHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_INDEX");
   let resultTypeHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_TYPE");
   let resultIndexByTypeHist = getAndClearKeyedHistogram("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
   let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
   let search_hist = getAndClearKeyedHistogram("SEARCH_COUNTS");
 
-  // Create an engine to generate search suggestions and add it as default
-  // for this test.
-  const url = getRootDirectory(gTestPath) + "usageTelemetrySearchSuggestions.xml";
-  let suggestionEngine = await new Promise((resolve, reject) => {
-    Services.search.addEngine(url, null, "", false, {
-      onSuccess(engine) { resolve(engine); },
-      onError() { reject(); }
-    });
-  });
+  await withNewSearchEngine(async function(engine) {
+    let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
 
-  let previousEngine = Services.search.currentEngine;
-  Services.search.currentEngine = suggestionEngine;
+    info("Type a query. Suggestions should be generated by the test engine.");
+    let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
+    await searchInAwesomebar("query");
+    info("Clicking the urlbar suggestion.");
+    await clickURLBarSuggestion("queryfoo");
+    await p;
 
-  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
+    // Check if the scalars contain the expected values.
+    const scalars = getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false);
+    checkKeyedScalar(scalars, SCALAR_URLBAR, "search_suggestion", 1);
+    Assert.equal(Object.keys(scalars[SCALAR_URLBAR]).length, 1,
+                "This search must only increment one entry in the scalar.");
 
-  info("Type a query. Suggestions should be generated by the test engine.");
-  let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
-  await searchInAwesomebar("query");
-  info("Clicking the urlbar suggestion.");
-  await clickURLBarSuggestion("queryfoo");
-  await p;
-
-  // Check if the scalars contain the expected values.
-  const scalars = getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, true, false);
-  checkKeyedScalar(scalars, SCALAR_URLBAR, "search_suggestion", 1);
-  Assert.equal(Object.keys(scalars[SCALAR_URLBAR]).length, 1,
-               "This search must only increment one entry in the scalar.");
+    // Make sure SEARCH_COUNTS contains identical values.
+    let searchEngineId = "other-" + engine.name;
+    checkKeyedHistogram(search_hist, searchEngineId + ".urlbar", 1);
 
-  // Make sure SEARCH_COUNTS contains identical values.
-  let searchEngineId = "other-" + suggestionEngine.name;
-  checkKeyedHistogram(search_hist, searchEngineId + ".urlbar", 1);
+    // Also check events.
+    let events = Services.telemetry.snapshotEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
+    events = (events.parent || []).filter(e => e[1] == "navigation" && e[2] == "search");
+    checkEvents(events, [["navigation", "search", "urlbar", "suggestion", {engine: searchEngineId}]]);
 
-  // Also check events.
-  let events = Services.telemetry.snapshotEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
-  events = (events.parent || []).filter(e => e[1] == "navigation" && e[2] == "search");
-  checkEvents(events, [["navigation", "search", "urlbar", "suggestion", {engine: searchEngineId}]]);
-
-  // Check the histograms as well.
-  let resultIndexes = resultIndexHist.snapshot();
-  checkHistogramResults(resultIndexes, 3, "FX_URLBAR_SELECTED_RESULT_INDEX");
+    // Check the histograms as well.
+    let resultIndexes = resultIndexHist.snapshot();
+    checkHistogramResults(resultIndexes, 3, "FX_URLBAR_SELECTED_RESULT_INDEX");
 
-  let resultTypes = resultTypeHist.snapshot();
-  checkHistogramResults(resultTypes,
-    URLBAR_SELECTED_RESULT_TYPES.searchsuggestion,
-    "FX_URLBAR_SELECTED_RESULT_TYPE");
+    let resultTypes = resultTypeHist.snapshot();
+    checkHistogramResults(resultTypes,
+      URLBAR_SELECTED_RESULT_TYPES.searchsuggestion,
+      "FX_URLBAR_SELECTED_RESULT_TYPE");
 
-  let resultIndexByType = resultIndexByTypeHist.snapshot("searchsuggestion");
-  checkHistogramResults(resultIndexByType,
-    3,
-    "FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
+    let resultIndexByType = resultIndexByTypeHist.snapshot("searchsuggestion");
+    checkHistogramResults(resultIndexByType,
+      3,
+      "FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
 
-  let resultMethods = resultMethodHist.snapshot();
-  checkHistogramResults(resultMethods,
-    URLBAR_SELECTED_RESULT_METHODS.click,
-    "FX_URLBAR_SELECTED_RESULT_METHOD");
+    let resultMethods = resultMethodHist.snapshot();
+    checkHistogramResults(resultMethods,
+      URLBAR_SELECTED_RESULT_METHODS.click,
+      "FX_URLBAR_SELECTED_RESULT_METHOD");
 
-  Services.search.currentEngine = previousEngine;
-  Services.search.removeEngine(suggestionEngine);
-  BrowserTestUtils.removeTab(tab);
+    BrowserTestUtils.removeTab(tab);
+  });
 });
 
 // Selects and presses the Return (Enter) key on the first suggestion offered by
 // the test search engine.  This only tests the FX_URLBAR_SELECTED_RESULT_METHOD
 // histogram since test_suggestion_click covers everything else.
 add_task(async function test_suggestion_arrowEnterSelection() {
-  // Let's reset the counts.
   Services.telemetry.clearScalars();
-
   let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
 
-  // Create an engine to generate search suggestions and add it as default
-  // for this test.
-  const url = getRootDirectory(gTestPath) + "usageTelemetrySearchSuggestions.xml";
-  let suggestionEngine = await new Promise((resolve, reject) => {
-    Services.search.addEngine(url, null, "", false, {
-      onSuccess(engine) { resolve(engine); },
-      onError() { reject(); }
-    });
-  });
-
-  let previousEngine = Services.search.currentEngine;
-  Services.search.currentEngine = suggestionEngine;
-
-  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
+  await withNewSearchEngine(async function() {
+    let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
 
-  info("Type a query. Suggestions should be generated by the test engine.");
-  let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
-  await searchInAwesomebar("query");
-  info("Select the second result and press Return.");
-  EventUtils.synthesizeKey("KEY_ArrowDown");
-  EventUtils.synthesizeKey("KEY_Enter");
-  await p;
+    info("Type a query. Suggestions should be generated by the test engine.");
+    let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
+    await searchInAwesomebar("query");
+    info("Select the second result and press Return.");
+    EventUtils.synthesizeKey("KEY_ArrowDown");
+    EventUtils.synthesizeKey("KEY_Enter");
+    await p;
 
-  let resultMethods = resultMethodHist.snapshot();
-  checkHistogramResults(resultMethods,
-    URLBAR_SELECTED_RESULT_METHODS.arrowEnterSelection,
-    "FX_URLBAR_SELECTED_RESULT_METHOD");
+    let resultMethods = resultMethodHist.snapshot();
+    checkHistogramResults(resultMethods,
+      URLBAR_SELECTED_RESULT_METHODS.arrowEnterSelection,
+      "FX_URLBAR_SELECTED_RESULT_METHOD");
 
-  Services.search.currentEngine = previousEngine;
-  Services.search.removeEngine(suggestionEngine);
-  BrowserTestUtils.removeTab(tab);
+    BrowserTestUtils.removeTab(tab);
+  });
 });
 
 // Selects through tab and presses the Return (Enter) key on the first
 // suggestion offered by the test search engine.
 add_task(async function test_suggestion_tabEnterSelection() {
-  // Let's reset the counts.
   Services.telemetry.clearScalars();
-
   let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
 
-  // Create an engine to generate search suggestions and add it as default
-  // for this test.
-  const url = getRootDirectory(gTestPath) + "usageTelemetrySearchSuggestions.xml";
-  let suggestionEngine = await new Promise((resolve, reject) => {
-    Services.search.addEngine(url, null, "", false, {
-      onSuccess(engine) { resolve(engine); },
-      onError() { reject(); }
-    });
-  });
-
-  let previousEngine = Services.search.currentEngine;
-  Services.search.currentEngine = suggestionEngine;
-
-  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
+  await withNewSearchEngine(async function() {
+    let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
 
-  info("Type a query. Suggestions should be generated by the test engine.");
-  let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
-  await searchInAwesomebar("query");
-  info("Select the second result and press Return.");
-  EventUtils.synthesizeKey("KEY_Tab");
-  EventUtils.synthesizeKey("KEY_Enter");
-  await p;
+    info("Type a query. Suggestions should be generated by the test engine.");
+    let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
+    await searchInAwesomebar("query");
+    info("Select the second result and press Return.");
+    EventUtils.synthesizeKey("KEY_Tab");
+    EventUtils.synthesizeKey("KEY_Enter");
+    await p;
 
-  let resultMethods = resultMethodHist.snapshot();
-  checkHistogramResults(resultMethods,
-    URLBAR_SELECTED_RESULT_METHODS.tabEnterSelection,
-    "FX_URLBAR_SELECTED_RESULT_METHOD");
+    let resultMethods = resultMethodHist.snapshot();
+    checkHistogramResults(resultMethods,
+      URLBAR_SELECTED_RESULT_METHODS.tabEnterSelection,
+      "FX_URLBAR_SELECTED_RESULT_METHOD");
 
-  Services.search.currentEngine = previousEngine;
-  Services.search.removeEngine(suggestionEngine);
-  BrowserTestUtils.removeTab(tab);
+    BrowserTestUtils.removeTab(tab);
+  });
 });
 
 // Selects through code and presses the Return (Enter) key on the first
 // suggestion offered by the test search engine.
 add_task(async function test_suggestion_enterSelection() {
-  // Let's reset the counts.
   Services.telemetry.clearScalars();
-
   let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
 
-  // Create an engine to generate search suggestions and add it as default
-  // for this test.
-  const url = getRootDirectory(gTestPath) + "usageTelemetrySearchSuggestions.xml";
-  let suggestionEngine = await new Promise((resolve, reject) => {
-    Services.search.addEngine(url, null, "", false, {
-      onSuccess(engine) { resolve(engine); },
-      onError() { reject(); }
-    });
+  await withNewSearchEngine(async function() {
+    let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
+
+    info("Type a query. Suggestions should be generated by the test engine.");
+    let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
+    await searchInAwesomebar("query");
+    info("Select the second result and press Return.");
+    gURLBar.popup.selectedIndex = 1;
+    EventUtils.synthesizeKey("KEY_Enter");
+    await p;
+
+    let resultMethods = resultMethodHist.snapshot();
+    checkHistogramResults(resultMethods,
+      URLBAR_SELECTED_RESULT_METHODS.enterSelection,
+      "FX_URLBAR_SELECTED_RESULT_METHOD");
+
+    BrowserTestUtils.removeTab(tab);
   });
-
-  let previousEngine = Services.search.currentEngine;
-  Services.search.currentEngine = suggestionEngine;
-
-  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
+});
 
-  info("Type a query. Suggestions should be generated by the test engine.");
-  let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
-  await searchInAwesomebar("query");
-  info("Select the second result and press Return.");
-  gURLBar.popup.selectedIndex = 1;
-  EventUtils.synthesizeKey("KEY_Enter");
-  await p;
+// Selects through mouse right button and press the Return (Enter) key.
+add_task(async function test_suggestion_rightclick() {
+  Services.telemetry.clearScalars();
+  let resultMethodHist = getAndClearHistogram("FX_URLBAR_SELECTED_RESULT_METHOD");
+
+  await withNewSearchEngine(async function() {
+    let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
 
-  let resultMethods = resultMethodHist.snapshot();
-  checkHistogramResults(resultMethods,
-    URLBAR_SELECTED_RESULT_METHODS.enterSelection,
-    "FX_URLBAR_SELECTED_RESULT_METHOD");
+    info("Type a query. Suggestions should be generated by the test engine.");
+    let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
+    await searchInAwesomebar("query");
+    info("Right click the the second result and then press Return.");
+    await clickURLBarSuggestion("queryfoo", 2);
+    EventUtils.synthesizeKey("KEY_Enter");
+    await p;
 
-  Services.search.currentEngine = previousEngine;
-  Services.search.removeEngine(suggestionEngine);
-  BrowserTestUtils.removeTab(tab);
+    let resultMethods = resultMethodHist.snapshot();
+    checkHistogramResults(resultMethods,
+      URLBAR_SELECTED_RESULT_METHODS.rightClickEnter,
+      "FX_URLBAR_SELECTED_RESULT_METHOD");
+
+    BrowserTestUtils.removeTab(tab);
+  });
 });
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -6619,20 +6619,21 @@
     "expires_in_version": "63",
     "releaseChannelCollection": "opt-out",
     "kind": "categorical",
     "labels": [
       "enter",
       "enterSelection",
       "click",
       "arrowEnterSelection",
-      "tabEnterSelection"
+      "tabEnterSelection",
+      "rightClickEnter"
     ],
     "bug_numbers": [1334615],
-    "description": "The input method the user used to select a result in the urlbar. 'enter' => The user hit the Enter key on the heuristic result at index 0. 'enterSelection' => The user chose a non-heuristic result (in exotic ways) and then hit the Enter key. 'click' => The user clicked a result with the mouse. 'arrowEnterSelection' => The user chose a non-heuristic result using arrow keys and then hit the Enter key. 'tabEnterSelection' => The user chose a non-heuristic result using tab at least once and then hit the Enter key."
+    "description": "The input method the user used to select a result in the urlbar. 'enter' => The user hit the Enter key on the heuristic result at index 0. 'enterSelection' => The user chose a non-heuristic result (in exotic ways) and then hit the Enter key. 'click' => The user clicked a result with the mouse. 'arrowEnterSelection' => The user chose a non-heuristic result using arrow keys and then hit the Enter key. 'tabEnterSelection' => The user chose a non-heuristic result using tab at least once and then hit the Enter key. 'rightClickEnter' => The user chose a non-heuristic result using right click and then hit the Enter key."
   },
   "FX_SEARCHBAR_SELECTED_RESULT_METHOD": {
     "record_in_processes": ["main", "content"],
     "alert_emails": ["dzeber@mozilla.com"],
     "expires_in_version": "63",
     "releaseChannelCollection": "opt-out",
     "kind": "categorical",
     "labels": [