зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset b04d0b734c52 (bug 1634508) for Browser-chrome failures in modules/test/browser/browser_UsageTelemetry.js. CLOSED TREE
This commit is contained in:
Родитель
95d1bdc7c7
Коммит
3fc1366dd1
|
@ -119,21 +119,19 @@ const URLBAR_SELECTED_RESULT_METHODS = {
|
|||
const MINIMUM_TAB_COUNT_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes, in ms
|
||||
|
||||
function getOpenTabsAndWinsCounts() {
|
||||
let loadedTabCount = 0;
|
||||
let tabCount = 0;
|
||||
let winCount = 0;
|
||||
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
winCount++;
|
||||
tabCount += win.gBrowser.tabs.length;
|
||||
for (const tab of win.gBrowser.tabs) {
|
||||
if (tab.getAttribute("pending") !== "true") {
|
||||
loadedTabCount += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { loadedTabCount, tabCount, winCount };
|
||||
return { tabCount, winCount };
|
||||
}
|
||||
|
||||
function getTabCount() {
|
||||
return getOpenTabsAndWinsCounts().tabCount;
|
||||
}
|
||||
|
||||
function getPinnedTabsCount() {
|
||||
|
@ -266,7 +264,7 @@ let URICountListener = {
|
|||
Services.telemetry.scalarAdd(TOTAL_URI_COUNT_SCALAR_NAME, 1);
|
||||
|
||||
// Update tab count
|
||||
BrowserUsageTelemetry._recordTabCounts(getOpenTabsAndWinsCounts());
|
||||
BrowserUsageTelemetry._recordTabCount();
|
||||
|
||||
// Unique domains should be aggregated by (eTLD + 1): x.test.com and y.test.com
|
||||
// are counted once as test.com.
|
||||
|
@ -334,7 +332,6 @@ let BrowserUsageTelemetry = {
|
|||
|
||||
init() {
|
||||
this._lastRecordTabCount = 0;
|
||||
this._lastRecordLoadedTabCount = 0;
|
||||
this._setupAfterRestore();
|
||||
this._inited = true;
|
||||
},
|
||||
|
@ -387,7 +384,7 @@ let BrowserUsageTelemetry = {
|
|||
handleEvent(event) {
|
||||
switch (event.type) {
|
||||
case "TabOpen":
|
||||
this._onTabOpen(getOpenTabsAndWinsCounts());
|
||||
this._onTabOpen();
|
||||
break;
|
||||
case "TabPinned":
|
||||
this._onTabPinned();
|
||||
|
@ -401,9 +398,6 @@ let BrowserUsageTelemetry = {
|
|||
// |URICountListener| know about them.
|
||||
let browser = event.target.linkedBrowser;
|
||||
URICountListener.addRestoredURI(browser, browser.currentURI);
|
||||
|
||||
const { loadedTabCount } = getOpenTabsAndWinsCounts();
|
||||
this._recordTabCounts({ loadedTabCount });
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
@ -692,14 +686,17 @@ let BrowserUsageTelemetry = {
|
|||
|
||||
/**
|
||||
* Updates the tab counts.
|
||||
* @param {Object} [counts] The counts returned by `getOpenTabsAndWindowCounts`.
|
||||
* @param {Number} [newTabCount=0] The count of the opened tabs across all windows. This
|
||||
* is computed manually if not provided.
|
||||
*/
|
||||
_onTabOpen({ tabCount, loadedTabCount }) {
|
||||
_onTabOpen(tabCount = 0) {
|
||||
// Use the provided tab count if available. Otherwise, go on and compute it.
|
||||
tabCount = tabCount || getOpenTabsAndWinsCounts().tabCount;
|
||||
// Update the "tab opened" count and its maximum.
|
||||
Services.telemetry.scalarAdd(TAB_OPEN_EVENT_COUNT_SCALAR_NAME, 1);
|
||||
Services.telemetry.scalarSetMaximum(MAX_TAB_COUNT_SCALAR_NAME, tabCount);
|
||||
|
||||
this._recordTabCounts({ tabCount, loadedTabCount });
|
||||
this._recordTabCount(tabCount);
|
||||
},
|
||||
|
||||
_onTabPinned(target) {
|
||||
|
@ -745,42 +742,23 @@ let BrowserUsageTelemetry = {
|
|||
|
||||
// We won't receive the "TabOpen" event for the first tab within a new window.
|
||||
// Account for that.
|
||||
this._onTabOpen(counts);
|
||||
this._onTabOpen(counts.tabCount);
|
||||
};
|
||||
win.addEventListener("load", onLoad);
|
||||
},
|
||||
|
||||
/**
|
||||
* Record telemetry about the given tab counts.
|
||||
*
|
||||
* Telemetry for each count will only be recorded if the value isn't
|
||||
* `undefined`.
|
||||
*
|
||||
* @param {object} [counts] The tab counts to register with telemetry.
|
||||
* @param {number} [counts.tabCount] The number of tabs in all browsers.
|
||||
* @param {number} [counts.loadedTabCount] The number of loaded (i.e., not
|
||||
* pending) tabs in all browsers.
|
||||
*/
|
||||
_recordTabCounts({ tabCount, loadedTabCount }) {
|
||||
_recordTabCount(tabCount) {
|
||||
let currentTime = Date.now();
|
||||
if (
|
||||
tabCount !== undefined &&
|
||||
currentTime > this._lastRecordTabCount + MINIMUM_TAB_COUNT_INTERVAL_MS
|
||||
currentTime >
|
||||
this._lastRecordTabCount + MINIMUM_TAB_COUNT_INTERVAL_MS
|
||||
) {
|
||||
if (tabCount === undefined) {
|
||||
tabCount = getTabCount();
|
||||
}
|
||||
Services.telemetry.getHistogramById("TAB_COUNT").add(tabCount);
|
||||
this._lastRecordTabCount = currentTime;
|
||||
}
|
||||
|
||||
if (
|
||||
loadedTabCount !== undefined &&
|
||||
currentTime >
|
||||
this._lastRecordLoadedTabCount + MINIMUM_TAB_COUNT_INTERVAL_MS
|
||||
) {
|
||||
Services.telemetry
|
||||
.getHistogramById("LOADED_TAB_COUNT")
|
||||
.add(loadedTabCount);
|
||||
this._lastRecordLoadedTabCount = currentTime;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -12,18 +12,12 @@ const UNFILTERED_URI_COUNT = "browser.engagement.unfiltered_uri_count";
|
|||
|
||||
const TELEMETRY_SUBSESSION_TOPIC = "internal-telemetry-after-subsession-split";
|
||||
|
||||
const RESTORE_ON_DEMAND_PREF = "browser.sessionstore.restore_on-demand";
|
||||
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"MINIMUM_TAB_COUNT_INTERVAL_MS",
|
||||
"resource:///modules/BrowserUsageTelemetry.jsm"
|
||||
);
|
||||
|
||||
const { SessionStore } = ChromeUtils.import(
|
||||
"resource:///modules/sessionstore/SessionStore.jsm"
|
||||
);
|
||||
|
||||
// Reset internal URI counter in case URIs were opened by other tests.
|
||||
Services.obs.notifyObservers(null, TELEMETRY_SUBSESSION_TOPIC);
|
||||
|
||||
|
@ -424,134 +418,3 @@ add_task(async function test_tabsHistogram() {
|
|||
}
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
||||
add_task(async function test_loadedTabsHistogram() {
|
||||
Services.prefs.setBoolPref(RESTORE_ON_DEMAND_PREF, true);
|
||||
registerCleanupFunction(() =>
|
||||
Services.prefs.clearUserPref(RESTORE_ON_DEMAND_PREF)
|
||||
);
|
||||
|
||||
function resetTimestamps() {
|
||||
BrowserUsageTelemetry._lastRecordTabCount = 0;
|
||||
BrowserUsageTelemetry._lastRecordLoadedTabCount = 0;
|
||||
}
|
||||
|
||||
resetTimestamps();
|
||||
const tabCount = TelemetryTestUtils.getAndClearHistogram("TAB_COUNT");
|
||||
const loadedTabCount = TelemetryTestUtils.getAndClearHistogram(
|
||||
"LOADED_TAB_COUNT"
|
||||
);
|
||||
|
||||
checkTabCountHistogram(tabCount.snapshot(), {}, "TAB_COUNT - initial count");
|
||||
checkTabCountHistogram(
|
||||
loadedTabCount.snapshot(),
|
||||
{},
|
||||
"LOADED_TAB_COUNT - initial count"
|
||||
);
|
||||
|
||||
resetTimestamps();
|
||||
const tabs = [
|
||||
await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank"),
|
||||
];
|
||||
|
||||
// There are two tabs open: the mochi.test tab and the foreground tab.
|
||||
checkTabCountHistogram(
|
||||
tabCount.snapshot(),
|
||||
{ 1: 0, 2: 1, 3: 0 },
|
||||
"TAB_COUNT - new tab"
|
||||
);
|
||||
checkTabCountHistogram(
|
||||
loadedTabCount.snapshot(),
|
||||
{ 1: 0, 2: 1, 3: 0 },
|
||||
"TAB_COUNT - new tab"
|
||||
);
|
||||
|
||||
// Open a pending tab, as if by session restore.
|
||||
resetTimestamps();
|
||||
const lazyTab = BrowserTestUtils.addTab(gBrowser, "about:mozilla", {
|
||||
createLazyBrowser: true,
|
||||
});
|
||||
tabs.push(lazyTab);
|
||||
|
||||
checkTabCountHistogram(
|
||||
tabCount.snapshot(),
|
||||
{ 1: 0, 2: 1, 3: 1, 4: 0 },
|
||||
"TAB_COUNT - Added pending tab"
|
||||
);
|
||||
|
||||
// Only the mochi.test and foreground tab are loaded.
|
||||
checkTabCountHistogram(
|
||||
loadedTabCount.snapshot(),
|
||||
{ 1: 0, 2: 2, 3: 0 },
|
||||
"LOADED_TAB_COUNT - Added pending tab"
|
||||
);
|
||||
|
||||
resetTimestamps();
|
||||
const restoredEvent = BrowserTestUtils.waitForEvent(lazyTab, "SSTabRestored");
|
||||
await BrowserTestUtils.switchTab(gBrowser, lazyTab);
|
||||
await restoredEvent;
|
||||
|
||||
checkTabCountHistogram(
|
||||
tabCount.snapshot(),
|
||||
{ 1: 0, 2: 1, 3: 1, 4: 0 },
|
||||
"TAB_COUNT - Restored pending tab"
|
||||
);
|
||||
|
||||
checkTabCountHistogram(
|
||||
loadedTabCount.snapshot(),
|
||||
{ 1: 0, 2: 2, 3: 1, 4: 0 },
|
||||
"LOADED_TAB_COUNT - Restored pending tab"
|
||||
);
|
||||
|
||||
resetTimestamps();
|
||||
await BrowserTestUtils.loadURI(lazyTab.linkedBrowser, "http://example.com");
|
||||
await BrowserTestUtils.browserLoaded(lazyTab.linkedBrowser);
|
||||
|
||||
checkTabCountHistogram(
|
||||
tabCount.snapshot(),
|
||||
{ 1: 0, 2: 1, 3: 2, 4: 0 },
|
||||
"TAB_COUNT - Navigated in existing tab"
|
||||
);
|
||||
|
||||
checkTabCountHistogram(
|
||||
loadedTabCount.snapshot(),
|
||||
{ 1: 0, 2: 2, 3: 2, 4: 0 },
|
||||
"LOADED_TAB_COUNT - Navigated in existing tab"
|
||||
);
|
||||
|
||||
resetTimestamps();
|
||||
let win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
|
||||
// The new window will have a new tab.
|
||||
checkTabCountHistogram(
|
||||
tabCount.snapshot(),
|
||||
{ 1: 0, 2: 1, 3: 2, 4: 1, 5: 0 },
|
||||
"TAB_COUNT - Opened new window"
|
||||
);
|
||||
|
||||
checkTabCountHistogram(
|
||||
loadedTabCount.snapshot(),
|
||||
{ 1: 0, 2: 2, 3: 2, 4: 1, 5: 0 },
|
||||
"LOADED_TAB_COUNT - Opened new window"
|
||||
);
|
||||
|
||||
resetTimestamps();
|
||||
await BrowserTestUtils.openNewForegroundTab(win.gBrowser, "about:robots");
|
||||
checkTabCountHistogram(
|
||||
tabCount.snapshot(),
|
||||
{ 1: 0, 2: 1, 3: 2, 4: 1, 5: 1, 6: 0 },
|
||||
"TAB_COUNT - Opened new tab in new window"
|
||||
);
|
||||
|
||||
checkTabCountHistogram(
|
||||
loadedTabCount.snapshot(),
|
||||
{ 1: 0, 2: 2, 3: 2, 4: 1, 5: 1, 6: 0 },
|
||||
"LOADED_TAB_COUNT - Opened new tab in new window"
|
||||
);
|
||||
|
||||
for (const tab of tabs) {
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
}
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
|
|
@ -4459,18 +4459,6 @@
|
|||
"releaseChannelCollection": "opt-out",
|
||||
"description": "Number of tabs opened across all windows, collected at most every 5 minutes whenever the user interacts with the browser in the following ways: open tab/window, page load."
|
||||
},
|
||||
"LOADED_TAB_COUNT": {
|
||||
"record_in_processes": ["main"],
|
||||
"products": ["firefox"],
|
||||
"alert_emails": ["barret@mozilla.com", "perfteam@mozilla.com"],
|
||||
"bug_numbers": [1634508],
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"high": 1000,
|
||||
"n_buckets": 100,
|
||||
"releaseChannelCollection": "opt-out",
|
||||
"description": "Number of fully loaded (i.e., not pending from session restore) tabs opened across all windows, collected at most every 5 minutes whenever the user interacts with the browser in the following ways: open tab/window, page load, restoring a pending tab."
|
||||
},
|
||||
"TAP_TO_LOAD_IMAGE_SIZE": {
|
||||
"record_in_processes": ["main", "content"],
|
||||
"products": ["firefox", "fennec", "geckoview"],
|
||||
|
|
Загрузка…
Ссылка в новой задаче