diff --git a/browser/modules/BrowserUsageTelemetry.jsm b/browser/modules/BrowserUsageTelemetry.jsm index daddacdbfdf3..b8d6674d6dbc 100644 --- a/browser/modules/BrowserUsageTelemetry.jsm +++ b/browser/modules/BrowserUsageTelemetry.jsm @@ -19,7 +19,6 @@ const { XPCOMUtils } = ChromeUtils.import( XPCOMUtils.defineLazyModuleGetters(this, { AppConstants: "resource://gre/modules/AppConstants.jsm", ClientID: "resource://gre/modules/ClientID.jsm", - BrowserTelemetryUtils: "resource://gre/modules/BrowserTelemetryUtils.jsm", CustomizableUI: "resource:///modules/CustomizableUI.jsm", PageActions: "resource:///modules/PageActions.jsm", PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm", @@ -250,22 +249,6 @@ let URICountListener = { this._restoredURIsMap.set(browser, uri.spec); }, - onStateChange(browser, webProgress, request, stateFlags, status) { - if ( - !webProgress.isTopLevel || - !(stateFlags & Ci.nsIWebProgressListener.STATE_STOP) || - !(stateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW) - ) { - return; - } - - if (!(request instanceof Ci.nsIChannel) || !this.isHttpURI(request.URI)) { - return; - } - - BrowserUsageTelemetry._recordSiteOriginsPerLoadedTabs(); - }, - onLocationChange(browser, webProgress, request, uri, flags) { if ( !(flags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT) && @@ -444,7 +427,6 @@ let BrowserUsageTelemetry = { init() { this._lastRecordTabCount = 0; this._lastRecordLoadedTabCount = 0; - this._lastRecordSiteOriginsPerLoadedTabs = 0; this._setupAfterRestore(); this._inited = true; @@ -1286,70 +1268,6 @@ let BrowserUsageTelemetry = { ); }, - /** - * Record telemetry about the ratio of number of site origins per number of - * loaded tabs. - * - * This will only record the telemetry if it has been five minutes since the - * last recording. - */ - _recordSiteOriginsPerLoadedTabs() { - const currentTime = Date.now(); - if ( - currentTime > - this._lastRecordSiteOriginsPerLoadedTabs + MINIMUM_TAB_COUNT_INTERVAL_MS - ) { - this._lastRecordSiteOriginsPerLoadedTabs = currentTime; - // If this is the first load, we discard it because it is likely just the - // browser opening for the first time. - if (this._lastRecordSiteOriginsPerLoadedTabs === 0) { - return; - } - - const { loadedTabCount } = getOpenTabsAndWinsCounts(); - const siteOrigins = BrowserTelemetryUtils.computeSiteOriginCount( - Services.wm.getEnumerator("navigator:browser"), - false - ); - const histogramId = this._getSiteOriginHistogram(loadedTabCount); - // Telemetry doesn't support float values. - Services.telemetry - .getHistogramById(histogramId) - .add(Math.trunc((100 * siteOrigins) / loadedTabCount)); - } - }, - - _siteOriginHistogramIds: [ - [1, 1, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_1"], - [2, 4, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_2_4"], - [5, 9, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_5_9"], - [10, 14, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_10_14"], - [15, 19, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_15_19"], - [20, 24, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_20_24"], - [25, 29, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_25_29"], - [31, 34, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_30_34"], - [35, 39, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_35_39"], - [40, 44, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_40_44"], - [45, 49, "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_45_49"], - ], - - /** - * Return the appropriate histogram ID for the given loaded tab count. - * - * Unique site origin telemetry is split across several histograms so that it - * can approximate a unique site origin vs loaded tab count curve. - * - * @param {number} [loadedTabCount] The number of loaded tabs. - */ - _getSiteOriginHistogram(loadedTabCount) { - for (const [min, max, histogramId] of this._siteOriginHistogramIds) { - if (min <= loadedTabCount && loadedTabCount <= max) { - return histogramId; - } - } - return "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_50_PLUS"; - }, - /** * Record the number of content processes. */ diff --git a/browser/modules/test/browser/browser.ini b/browser/modules/test/browser/browser.ini index af1aedfdcc49..0ad7aeda2856 100644 --- a/browser/modules/test/browser/browser.ini +++ b/browser/modules/test/browser/browser.ini @@ -61,9 +61,6 @@ skip-if = verify && debug [browser_UsageTelemetry_toolbars.js] [browser_UsageTelemetry_uniqueOriginsVisitedInPast24Hours.js] [browser_UsageTelemetry_content_aboutRestartRequired.js] -[browser_UsageTelemetry_numberOfSiteOriginsPerTabs.js] -support-files = - multiple_iframes.html [browser_Telemetry_numberOfSiteOrigins.js] support-files = contain_iframe.html diff --git a/browser/modules/test/browser/browser_UsageTelemetry_numberOfSiteOriginsPerTabs.js b/browser/modules/test/browser/browser_UsageTelemetry_numberOfSiteOriginsPerTabs.js deleted file mode 100644 index d46621a1e191..000000000000 --- a/browser/modules/test/browser/browser_UsageTelemetry_numberOfSiteOriginsPerTabs.js +++ /dev/null @@ -1,145 +0,0 @@ -"use strict"; - -const TEST_ROOT = getRootDirectory(gTestPath).replace( - "chrome://mochitests/content", - "http://mochi.test:8888" -); - -function assertHistograms(histograms, expected, message) { - for (let i = 0; i < histograms.length; i++) { - const [name, histogram] = histograms[i]; - const actual = histogram.snapshot().values; - const expectedValues = i < expected.length ? expected[i] : {}; - - Assert.deepEqual(expectedValues, actual, `${name} - ${message}`); - } -} - -async function loadAndWaitForStop(tab, uri) { - BrowserUsageTelemetry._lastRecordSiteOriginsPerLoadedTabs = 0; - - await Promise.all([ - BrowserTestUtils.loadURI(tab.linkedBrowser, uri), - BrowserTestUtils.browserStopped(tab.linkedBrowser, uri), - ]); - - // Yield the event loop after the document loads to wait for the telemetry - // publish in the Fission case. - await new Promise(resolve => executeSoon(resolve)); - await new Promise(resolve => executeSoon(resolve)); -} - -async function openNewForegroundTab(uri) { - BrowserUsageTelemetry._lastRecordSiteOriginsPerLoadedTabs = 0; - - const tab = await BrowserTestUtils.openNewForegroundTab({ - gBrowser, - url: uri, - waitForStateStop: true, - }); - - // Yield the event loop after the document loads to wait for the telemetry - // publish in the Fission case. - await new Promise(resolve => executeSoon(resolve)); - return tab; -} - -add_task(async function test_siteOriginsPerLoadedTabsHistogram() { - const histograms = BrowserUsageTelemetry._siteOriginHistogramIds.map( - ([, , name]) => [name, TelemetryTestUtils.getAndClearHistogram(name)] - ); - assertHistograms(histograms, [], "initial"); - - dump("*** *** load example.com (1)\n"); - await loadAndWaitForStop(gBrowser.selectedTab, "http://example.com/"); - - // We have one origin open in one tab. (100 * 1 / 1) - assertHistograms( - histograms, - [ - { 75: 0, 88: 1, 103: 0 }, // 1 loaded tab. - ], - "navigate to https://example.com" - ); - - let tabs = [await openNewForegroundTab("http://example.com/")]; - - // We have one origin open in two tabs. (100 * 1 / 2) - assertHistograms( - histograms, - [ - { 75: 0, 88: 1, 103: 0 }, // 1 loaded tab. - { 40: 0, 47: 1, 55: 0 }, // 2 <= N < 5 loaded tabs. - ], - "opening a new tab containing to https://example.com" - ); - - // Open three new tabs - tabs.push( - await openNewForegroundTab("http://example.com/"), - await openNewForegroundTab("http://example.com/"), - await openNewForegroundTab("http://example.com/") - ); - - // We have one origin open in five tabs. (100 * 1 / 5) - assertHistograms( - histograms, - [ - { 75: 0, 88: 1, 103: 0 }, // 1 loaded tab. - { 21: 0, 25: 1, 29: 1, 47: 1, 55: 0 }, // 2 <= N < 5 loaded tabs. - { 15: 0, 18: 1, 21: 0 }, // 5 <= N < 10 loaded tabs. - ], - "open a three new tabs containing https://example.com" - ); - - for (const tab of tabs) { - BrowserTestUtils.removeTab(tab); - } - tabs = []; - - await loadAndWaitForStop( - gBrowser.selectedTab, - `${TEST_ROOT}/multiple_iframes.html` - ); - - // We have 10 origins open in 1 tab (100 * 10 / 1) - assertHistograms( - histograms, - [ - { 75: 0, 88: 1, 907: 1, 1059: 0 }, // 1 loaded tab. - { 21: 0, 25: 1, 29: 1, 47: 1, 55: 0 }, // 2 <= N < 5 loaded tabs. - { 15: 0, 18: 1, 21: 0 }, // 5 <= N < 10 loaded tabs. - ], - "navigate to a new tab containing multiple origins" - ); - - tabs.push(await openNewForegroundTab(`${TEST_ROOT}/multiple_iframes.html`)); - - // We have 10 origins open in 2 tabs (100 * 10 / 2) - assertHistograms( - histograms, - [ - { 75: 0, 88: 1, 907: 1, 1059: 0 }, // 1 loaded tab. - { 21: 0, 25: 1, 29: 1, 47: 1, 487: 1, 569: 0 }, // 2 <= N < 5 loaded tabs. - { 15: 0, 18: 1, 21: 0 }, // 5 <= N < 10 loaded tabs. - ], - "navigate to a new tab containing multiple origins" - ); - - tabs.push(await openNewForegroundTab(`${TEST_ROOT}/multiple_iframes.html`)); - - // We have 10 origins open in 3 tabs (100 * 10 / 3) - assertHistograms( - histograms, - [ - { 75: 0, 88: 1, 907: 1, 1059: 0 }, // 1 loaded tab. - { 21: 0, 25: 1, 29: 1, 47: 1, 306: 1, 487: 1, 569: 0 }, // 2 <= N < 5 loaded tabs. - { 15: 0, 18: 1, 21: 0 }, // 5 <= N < 10 loaded tabs. - ], - "navigate to a new tab containing multiple origins" - ); - - for (const tab of tabs) { - BrowserTestUtils.removeTab(tab); - } -}); diff --git a/browser/modules/test/browser/multiple_iframes.html b/browser/modules/test/browser/multiple_iframes.html deleted file mode 100644 index 50721387db24..000000000000 --- a/browser/modules/test/browser/multiple_iframes.html +++ /dev/null @@ -1,17 +0,0 @@ - - -
- - - - - - - - - - - - - - diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 768c8496ebf8..726de4cbf7ed 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -7635,150 +7635,6 @@ "alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"], "releaseChannelCollection": "opt-out" }, - "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_1": { - "record_in_processes": ["main"], - "products": ["firefox"], - "expires_in_version": "93", - "kind": "exponential", - "high": 5000, - "n_buckets": 50, - "description": "When a document is loaded, if the user has exactly one loaded tab, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection", - "bug_numbers": [1655138], - "alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"], - "releaseChannelCollection": "opt-out" - }, - "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_2_4": { - "record_in_processes": ["main"], - "products": ["firefox"], - "expires_in_version": "93", - "kind": "exponential", - "high": 5000, - "n_buckets": 50, - "description": "When a document is loaded, if the user has a number of loaded tabs in the range 2 <= N <= 4, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection", - "bug_numbers": [1655138], - "alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"], - "releaseChannelCollection": "opt-out" - }, - "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_5_9": { - "record_in_processes": ["main"], - "products": ["firefox"], - "expires_in_version": "93", - "kind": "exponential", - "high": 5000, - "n_buckets": 50, - "description": "When a document is loaded, if the user has a number of loaded tabs in the range 5 <= N <= 9, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection", - "bug_numbers": [1655138], - "alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"], - "releaseChannelCollection": "opt-out" - }, - "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_10_14": { - "record_in_processes": ["main"], - "products": ["firefox"], - "expires_in_version": "93", - "kind": "exponential", - "high": 5000, - "n_buckets": 50, - "description": "When a document is loaded, if the user has a number of loaded tabs in the range 10 <= N <= 14, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection", - "bug_numbers": [1655138], - "alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"], - "releaseChannelCollection": "opt-out" - }, - "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_15_19": { - "record_in_processes": ["main"], - "products": ["firefox"], - "expires_in_version": "93", - "kind": "exponential", - "high": 5000, - "n_buckets": 50, - "description": "When a document is loaded, if the user has a number of loaded tabs in the range 15 <= N <= 19, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection", - "bug_numbers": [1655138], - "alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"], - "releaseChannelCollection": "opt-out" - }, - "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_20_24": { - "record_in_processes": ["main"], - "products": ["firefox"], - "expires_in_version": "93", - "kind": "exponential", - "high": 5000, - "n_buckets": 50, - "description": "When a document is loaded, if the user has a number of loaded tabs in the range 20 <= N <= 24, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection", - "bug_numbers": [1655138], - "alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"], - "releaseChannelCollection": "opt-out" - }, - "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_25_29": { - "record_in_processes": ["main"], - "products": ["firefox"], - "expires_in_version": "93", - "kind": "exponential", - "high": 5000, - "n_buckets": 50, - "description": "When a document is loaded, if the user has a number of loaded tabs in the range 25 <= N <= 29, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection", - "bug_numbers": [1655138], - "alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"], - "releaseChannelCollection": "opt-out" - }, - "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_30_34": { - "record_in_processes": ["main"], - "products": ["firefox"], - "expires_in_version": "93", - "kind": "exponential", - "high": 5000, - "n_buckets": 50, - "description": "When a document is loaded, if the user has a number of loaded tabs in the range 30 <= N <= 34, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection", - "bug_numbers": [1655138], - "alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"], - "releaseChannelCollection": "opt-out" - }, - "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_35_39": { - "record_in_processes": ["main"], - "products": ["firefox"], - "expires_in_version": "93", - "kind": "exponential", - "high": 5000, - "n_buckets": 50, - "description": "When a document is loaded, if the user has a number of loaded tabs in the range 35 <= N <= 39, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection", - "bug_numbers": [1655138], - "alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"], - "releaseChannelCollection": "opt-out" - }, - "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_40_44": { - "record_in_processes": ["main"], - "products": ["firefox"], - "expires_in_version": "93", - "kind": "exponential", - "high": 5000, - "n_buckets": 50, - "description": "When a document is loaded, if the user has a number of loaded tabs in the range 40 <= N <= 44, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection", - "bug_numbers": [1655138], - "alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"], - "releaseChannelCollection": "opt-out" - }, - "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_45_49": { - "record_in_processes": ["main"], - "products": ["firefox"], - "expires_in_version": "93", - "kind": "exponential", - "high": 5000, - "n_buckets": 50, - "description": "When a document is loaded, if the user has a number of loaded tabs in the range 45 <= N <= 49, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection", - "bug_numbers": [1655138], - "alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"], - "releaseChannelCollection": "opt-out" - }, - "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_PER_LOADED_TABS_50_PLUS": { - "record_in_processes": ["main"], - "products": ["firefox"], - "expires_in_version": "93", - "kind": "exponential", - "high": 5000, - "n_buckets": 50, - "description": "When a document is loaded, if the user has 50 or more loaded tabs, report the ratio of unique site origins loaded to number of loaded tabs (multiplied by 100) if it has been at least 5 minutes since the last collection", - "bug_numbers": [1655138], - "alert_emails": ["barret@mozilla.com", "perf-telemetry-alerts@mozilla.com"], - "releaseChannelCollection": "opt-out" - }, "FX_TAB_SWITCH_REQUEST_TAB_WARMING_STATE": { "record_in_processes": ["main"], "products": ["firefox"],