Bug 1361855 - Record TAB_COUNT histogram when a browser window is closed; r?bsmedberg,Gijs
MozReview-Commit-ID: Et635S6j0p4
--- a/browser/modules/BrowserUsageTelemetry.jsm
+++ b/browser/modules/BrowserUsageTelemetry.jsm
@@ -603,16 +603,19 @@ let BrowserUsageTelemetry = {
win.removeEventListener("TabClose", this, true);
// Don't include URI and domain counts when in private mode.
if (PrivateBrowsingUtils.isWindowPrivate(win.defaultView)) {
return;
}
win.defaultView.gBrowser.tabContainer.removeEventListener(TAB_RESTORING_TOPIC, this);
win.defaultView.gBrowser.removeTabsProgressListener(URICountListener);
+
+ let tabCount = getOpenTabsAndWinsCounts().tabCount;
+ this._recordTabCount(tabCount);
},
/**
* Updates the tab counts.
* @param {Number} [newTabCount=0] The count of the opened tabs across all windows. This
* is computed manually if not provided.
*/
_onTabOpen(tabCount = 0) {
--- a/browser/modules/test/browser/browser_UsageTelemetry.js
+++ b/browser/modules/test/browser/browser_UsageTelemetry.js
@@ -343,14 +343,17 @@ add_task(async function test_tabsHistogr
ok(BrowserUsageTelemetry._lastRecordTabCount != oldLastRecordTabCount, "TAB_COUNT telemetry - _lastRecordTabCount updated");
ok(BrowserUsageTelemetry._lastRecordTabCount > new Date().getTime() - BrowserUsageTelemetry._tabCountIntervalMillis, "TAB_COUNT telemetry - _lastRecordTabCount invariant");
}
BrowserUsageTelemetry._lastRecordTabCount = 0;
await BrowserTestUtils.removeTab(openedTabs2.pop());
checkTabCountHistogram(tabCountHist.snapshot(), [0,0,1,2,1,1,1,2], "TAB_COUNT telemetry - closing a tab");
+ BrowserUsageTelemetry._lastRecordTabCount = 0;
+ await BrowserTestUtils.closeWindow(win);
+ checkTabCountHistogram(tabCountHist.snapshot(), [0,0,1,2,2,1,1,2], "TAB_COUNT telemetry - closing a window");
+
// Remove all the extra windows and tabs.
for (let tab of openedTabs) {
await BrowserTestUtils.removeTab(tab);
}
- await BrowserTestUtils.closeWindow(win);
});