diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 67bfdacef252..290e0cb8b7d8 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -3478,10 +3478,29 @@ const BrowserSearch = { if (!submission) return; + let newTab; + function newTabHandler(event) { + newTab = event.target; + } + gBrowser.tabContainer.addEventListener("TabOpen", newTabHandler); + openLinkIn(submission.uri.spec, useNewTab ? "tab" : "current", { postData: submission.postData, relatedToCurrent: true }); + + gBrowser.tabContainer.removeEventListener("TabOpen", newTabHandler); + if (newTab && !newTab.selected) { + let tabSelected = false; + function tabSelectHandler() { + tabSelected = true; + } + newTab.addEventListener("TabSelect", tabSelectHandler); + setTimeout(function () { + newTab.removeEventListener("TabSelect", tabSelectHandler); + Services.telemetry.getHistogramById("FX_CONTEXT_SEARCH_AND_TAB_SELECT").add(tabSelected); + }, 5000); + } }, /** diff --git a/toolkit/components/telemetry/TelemetryHistograms.h b/toolkit/components/telemetry/TelemetryHistograms.h index 0e74bcdac946..1ad2c243754a 100644 --- a/toolkit/components/telemetry/TelemetryHistograms.h +++ b/toolkit/components/telemetry/TelemetryHistograms.h @@ -275,6 +275,13 @@ HISTOGRAM(THUNDERBIRD_CONVERSATIONS_TIME_TO_2ND_GLODA_QUERY_MS, 1, 10000, 30, EX HISTOGRAM(THUNDERBIRD_INDEXING_RATE_MSG_PER_S, 1, 100, 20, LINEAR, "Gloda: indexing rate (message/s)") #endif +/** + * Firefox-specific telemetry. + */ +#ifdef MOZ_PHOENIX +HISTOGRAM(FX_CONTEXT_SEARCH_AND_TAB_SELECT, 0, 1, 2, BOOLEAN, "Firefox: Background tab was selected within 5 seconds of searching from the context menu") +#endif + HISTOGRAM_BOOLEAN(INNERWINDOWS_WITH_MUTATION_LISTENERS, "Deleted or to-be-reused innerwindow which has had mutation event listeners.") HISTOGRAM(XUL_REFLOW_MS, 1, 3000, 10, EXPONENTIAL, "xul reflows") HISTOGRAM(XUL_INITIAL_FRAME_CONSTRUCTION, 1, 3000, 10, EXPONENTIAL, "initial xul frame construction")