Commit 5c3af9b8 authored by Csoregi Natalia's avatar Csoregi Natalia
Browse files

Backed out changeset adae65ae94ec (bug 1801290) for causing failures on...

Backed out changeset adae65ae94ec (bug 1801290) for causing failures on browser_places_search_telemetry.js. CLOSED TREE
parent c63d2547
Loading
Loading
Loading
Loading
+2 −43
Original line number Diff line number Diff line
@@ -30,12 +30,8 @@ XPCOMUtils.defineLazyScriptGetter(
var gHistoryTree;
var gSearchBox;
var gHistoryGrouping = "";
var gCumulativeSearches = 0;
var gCumulativeFilterCount = 0;

function HistorySidebarInit() {
  Services.telemetry.keyedScalarAdd("sidebar.opened", "history", 1);

  let uidensity = window.top.document.documentElement.getAttribute("uidensity");
  if (uidensity) {
    document.documentElement.setAttribute("uidensity", uidensity);
@@ -49,7 +45,7 @@ function HistorySidebarInit() {
    .getAttribute("selectedsort");

  this.groupHistogram = Services.telemetry.getHistogramById(
    "PLACES_SEARCHBAR_FILTER_TYPE"
    "HISTORY_SIDEBAR_VIEW_TYPE"
  );
  this.groupHistogram.add(gHistoryGrouping);

@@ -73,28 +69,9 @@ function GroupBy(groupingType) {
    this.groupHistogram.add(groupingType);
  }
  gHistoryGrouping = groupingType;
  gCumulativeFilterCount++;
  searchHistory(gSearchBox.value);
}

function selectLink(event) {
  let searchesHistogram = Services.telemetry.getHistogramById(
    "PLACES_SEARCHBAR_CUMULATIVE_SEARCHES"
  );
  searchesHistogram.add(gCumulativeSearches);
  let filterCountHistogram = Services.telemetry.getHistogramById(
    "PLACES_SEARCHBAR_CUMULATIVE_FILTER_COUNT"
  );
  filterCountHistogram.add(gCumulativeFilterCount);
  clearCumulativeCounters();

  if (event.type == "click") {
    PlacesUIUtils.onSidebarTreeClick(event);
  } else if (event.type == "keypress") {
    PlacesUIUtils.onSidebarTreeKeyPress(event);
  }
}

function searchHistory(aInput) {
  var query = PlacesUtils.history.getNewQuery();
  var options = PlacesUtils.history.getNewQueryOptions();
@@ -144,30 +121,12 @@ function searchHistory(aInput) {
  // call load() on the tree manually
  // instead of setting the place attribute in historySidebar.xhtml
  // otherwise, we will end up calling load() twice
  gHistoryTree.load(query, options);

  // Sometimes search is activated without an input string. For example, when
  // the history sidbar is first opened or when a search filter is selected.
  // Since we're trying to measure how often the searchbar was used, we should first
  // check if there's an input string before collecting telemetry.
  if (aInput) {
  Services.telemetry.keyedScalarAdd("sidebar.search", "history", 1);
    gCumulativeSearches++;
  }
  gHistoryTree.load(query, options);

  if (gHistoryGrouping == "lastvisited") {
    TelemetryStopwatch.finish("HISTORY_LASTVISITED_TREE_QUERY_TIME_MS");
  }
}

function clearCumulativeCounters() {
  gCumulativeSearches = 0;
  gCumulativeFilterCount = 0;
}

function unloadHistorySidebar() {
  clearCumulativeCounters();
  PlacesUIUtils.setMouseoverURL("", window);
}

window.addEventListener("SidebarFocused", () => gSearchBox.focus());
+3 −3
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
        xmlns:html="http://www.w3.org/1999/xhtml"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        onload="HistorySidebarInit();"
        onunload="unloadHistorySidebar();"
        onunload="PlacesUIUtils.setMouseoverURL('', window);"
        data-l10n-id="places-history">

  <script src="chrome://browser/content/places/historySidebar.js"/>
@@ -84,8 +84,8 @@
        hidecolumnpicker="true"
        context="placesContext"
        singleclickopens="true"
        onclick="selectLink(event);"
        onkeypress="selectLink(event);"
        onkeypress="PlacesUIUtils.onSidebarTreeKeyPress(event);"
        onclick="PlacesUIUtils.onSidebarTreeClick(event);"
        onmousemove="PlacesUIUtils.onSidebarTreeMouseMove(event);"
        onmouseout="PlacesUIUtils.setMouseoverURL('', window);">
    <treecols>
+0 −1
Original line number Diff line number Diff line
@@ -128,7 +128,6 @@ skip-if = os == "linux" && (tsan || asan) # Bug 1714384
skip-if = os == "linux" && (tsan || asan) # Bug 1714384
[browser_paste_resets_cut_highlights.js]
skip-if = os == "linux" && (tsan || asan) # Bug 1714384
[browser_places_search_telemetry.js]
[browser_remove_bookmarks.js]
skip-if = os == "linux" && (tsan || asan) # Bug 1714384
[browser_sidebar_open_bookmarks.js]
+0 −100
Original line number Diff line number Diff line
/* 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";

const { TelemetryTestUtils } = ChromeUtils.import(
  "resource://testing-common/TelemetryTestUtils.jsm"
);

add_task(async function test_places_search_telemetry() {
  // Visited pages listed by descending visit date.
  let pages = [
    "https://sidebar.mozilla.org/a",
    "https://sidebar.mozilla.org/b",
    "https://sidebar.mozilla.org/c",
    "https://www.mozilla.org/d",
  ];

  await PlacesUtils.history.clear();

  // Add some visited page.
  let time = Date.now();
  let places = [];
  for (let i = 0; i < pages.length; i++) {
    places.push({
      uri: NetUtil.newURI(pages[i]),
      visitDate: (time - i) * 1000,
      transition: PlacesUtils.history.TRANSITION_TYPED,
    });
  }

  await PlacesTestUtils.addVisits(places);
  await withSidebarTree("history", function() {
    let sidebar = window.SidebarUI.browser;

    // Apply a search filter.
    sidebar.contentDocument.getElementById("bylastvisited").doCommand();
    let tree = sidebar.contentDocument.getElementById("historyTree");

    // Search the tree.
    let searchBox = sidebar.contentDocument.getElementById("search-box");
    searchBox.value = "sidebar.mozilla";
    searchBox.doCommand();

    info("Reset the search");
    searchBox.value = "";
    searchBox.doCommand();

    // Perform a second search.
    searchBox.value = "sidebar.mozilla";
    searchBox.doCommand();

    // Select the first link and click on it.
    const firstNodeIndex = 0;
    tree.selectNode(tree.view.nodeForTreeIndex(firstNodeIndex));
    synthesizeClickOnSelectedTreeCell(tree, { button: 1 });
  });

  let cumulativeSearchesHistogram = Services.telemetry.getHistogramById(
    "PLACES_SEARCHBAR_CUMULATIVE_SEARCHES"
  );
  TelemetryTestUtils.assertHistogram(cumulativeSearchesHistogram, 2, 1);

  let cumulativeFilterCountHistogram = Services.telemetry.getHistogramById(
    "PLACES_SEARCHBAR_CUMULATIVE_FILTER_COUNT"
  );
  TelemetryTestUtils.assertHistogram(cumulativeFilterCountHistogram, 1, 1);

  cumulativeSearchesHistogram.clear();
  cumulativeFilterCountHistogram.clear();

  await withSidebarTree("history", function() {
    let sidebar = window.SidebarUI.browser;
    let tree = sidebar.contentDocument.getElementById("historyTree");

    // Apply a search filter.
    sidebar.contentDocument.getElementById("byday").doCommand();

    // Apply another search filter.
    sidebar.contentDocument.getElementById("bylastvisited").doCommand();

    // Search the tree.
    let searchBox = sidebar.contentDocument.getElementById("search-box");
    searchBox.value = "sidebar.mozilla";
    searchBox.doCommand();

    // Select the first link and click on it.
    const firstNodeIndex = 0;
    tree.selectNode(tree.view.nodeForTreeIndex(firstNodeIndex));
    synthesizeClickOnSelectedTreeCell(tree, { button: 1 });
  });

  TelemetryTestUtils.assertHistogram(cumulativeSearchesHistogram, 1, 1);
  TelemetryTestUtils.assertHistogram(cumulativeFilterCountHistogram, 2, 1);

  await PlacesUtils.history.clear();
  BrowserTestUtils.removeTab(gBrowser.selectedTab);
  BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
+5 −27
Original line number Diff line number Diff line
@@ -15916,38 +15916,16 @@
    "releaseChannelCollection": "opt-out",
    "description": "The type of update manifest served for a given update request."
  },
  "PLACES_SEARCHBAR_FILTER_TYPE": {
  "HISTORY_SIDEBAR_VIEW_TYPE": {
    "record_in_processes": ["main"],
    "products": ["firefox"],
    "expires_in_version": "never",
    "alert_emails": ["pguruprasad@mozilla.com", "rfambro@mozilla.com"],
    "releaseChannelCollection": "opt-in",
    "bug_numbers": [1801290],
    "alert_emails": ["emalysz@mozilla.com", "rtestard@mozilla.com"],
    "releaseChannelCollection": "opt-out",
    "bug_numbers": [1648524],
    "kind": "categorical",
    "labels": ["visited", "lastvisited", "dayandsite", "site", "day"],
    "description": "The type of search filters used for the sidebar search."
  },
  "PLACES_SEARCHBAR_CUMULATIVE_SEARCHES": {
    "record_in_processes": ["main"],
    "products": ["firefox"],
    "expires_in_version": "never",
    "alert_emails": ["pguruprasad@mozilla.com", "rfambro@mozilla.com"],
    "releaseChannelCollection": "opt-in",
    "bug_numbers": [1801290],
    "kind": "enumerated",
    "n_values": 20,
    "description": "Cumulative no. of searches performed before selecting a link."
  },
  "PLACES_SEARCHBAR_CUMULATIVE_FILTER_COUNT": {
    "record_in_processes": ["main"],
    "products": ["firefox"],
    "expires_in_version": "never",
    "alert_emails": ["pguruprasad@mozilla.com", "rfambro@mozilla.com"],
    "releaseChannelCollection": "opt-in",
    "bug_numbers": [1801290],
    "kind": "enumerated",
    "n_values": 20,
    "description": "Cumulative no. of search filters applied performed before selecting a link."
    "description": "The type of view used for the history sidebar."
  },
  "NOTIFY_OBSERVERS_LATENCY_MS": {
    "record_in_processes": ["main", "content", "gpu"],