forked from mirrors/gecko-dev
Bug 1848459 - add telemetry to count closed tabs lost in session restore r=sfoster,sessionstore-reviewers
* Add histogram to sessionrestore code to count how often and the number of closed tabs that aren't saved on window close due to no open saveable tabs * Add test coverage Differential Revision: https://phabricator.services.mozilla.com/D193055
This commit is contained in:
parent
4ab2bf820c
commit
b8cd7eaa7f
3 changed files with 44 additions and 3 deletions
|
|
@ -2360,7 +2360,7 @@ var SessionStoreInternal = {
|
||||||
// It's possible that a tab switched its privacy state at some point
|
// It's possible that a tab switched its privacy state at some point
|
||||||
// before our flush, so we need to filter again.
|
// before our flush, so we need to filter again.
|
||||||
lazy.PrivacyFilter.filterPrivateTabs(winData);
|
lazy.PrivacyFilter.filterPrivateTabs(winData);
|
||||||
this.maybeSaveClosedWindow(winData, isLastWindow);
|
this.maybeSaveClosedWindow(winData, isLastWindow, true);
|
||||||
|
|
||||||
if (!isLastWindow && winData.closedId > -1) {
|
if (!isLastWindow && winData.closedId > -1) {
|
||||||
this._addClosedAction(
|
this._addClosedAction(
|
||||||
|
|
@ -2439,7 +2439,7 @@ var SessionStoreInternal = {
|
||||||
* to call this method again asynchronously (for example, after
|
* to call this method again asynchronously (for example, after
|
||||||
* a window flush).
|
* a window flush).
|
||||||
*/
|
*/
|
||||||
maybeSaveClosedWindow(winData, isLastWindow) {
|
maybeSaveClosedWindow(winData, isLastWindow, recordTelemetry = false) {
|
||||||
// Make sure SessionStore is still running, and make sure that we
|
// Make sure SessionStore is still running, and make sure that we
|
||||||
// haven't chosen to forget this window.
|
// haven't chosen to forget this window.
|
||||||
if (
|
if (
|
||||||
|
|
@ -2498,6 +2498,14 @@ var SessionStoreInternal = {
|
||||||
}
|
}
|
||||||
if (alreadyStored) {
|
if (alreadyStored) {
|
||||||
this._removeClosedWindow(winIndex);
|
this._removeClosedWindow(winIndex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// we only do this after the TabStateFlusher promise resolves in ssi_onClose
|
||||||
|
if (recordTelemetry) {
|
||||||
|
let closedTabsHistogram = Services.telemetry.getHistogramById(
|
||||||
|
"FX_SESSION_RESTORE_CLOSED_TABS_NOT_SAVED"
|
||||||
|
);
|
||||||
|
closedTabsHistogram.add(winData._closedTabs.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* 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
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
const { TelemetryTestUtils } = ChromeUtils.import(
|
||||||
|
"resource://testing-common/TelemetryTestUtils.jsm"
|
||||||
|
);
|
||||||
const TEST_URLS = [
|
const TEST_URLS = [
|
||||||
"http://mochi.test:8888/browser/",
|
"http://mochi.test:8888/browser/",
|
||||||
"https://www.example.com/",
|
"https://www.example.com/",
|
||||||
|
|
@ -74,17 +76,37 @@ async function prepareClosedData() {
|
||||||
closedIds.tab5 =
|
closedIds.tab5 =
|
||||||
SessionStore.getClosedTabDataForWindow(privateWin)[0].closedId;
|
SessionStore.getClosedTabDataForWindow(privateWin)[0].closedId;
|
||||||
|
|
||||||
|
const testWindow6 = await BrowserTestUtils.openNewBrowserWindow();
|
||||||
|
|
||||||
|
const testWindow7 = await BrowserTestUtils.openNewBrowserWindow();
|
||||||
|
await openAndCloseTab(testWindow7, TEST_URLS[4]);
|
||||||
|
|
||||||
|
let closedTabsHistogram = TelemetryTestUtils.getAndClearHistogram(
|
||||||
|
"FX_SESSION_RESTORE_CLOSED_TABS_NOT_SAVED"
|
||||||
|
);
|
||||||
|
|
||||||
await BrowserTestUtils.closeWindow(testWindow1);
|
await BrowserTestUtils.closeWindow(testWindow1);
|
||||||
closedIds.testWindow1 = SessionStore.getClosedWindowData()[0].closedId;
|
closedIds.testWindow1 = SessionStore.getClosedWindowData()[0].closedId;
|
||||||
await BrowserTestUtils.closeWindow(testWindow2);
|
await BrowserTestUtils.closeWindow(testWindow2);
|
||||||
|
|
||||||
closedIds.testWindow2 = SessionStore.getClosedWindowData()[0].closedId;
|
closedIds.testWindow2 = SessionStore.getClosedWindowData()[0].closedId;
|
||||||
await BrowserTestUtils.closeWindow(testWindow3);
|
await BrowserTestUtils.closeWindow(testWindow3);
|
||||||
|
|
||||||
closedIds.testWindow3 = SessionStore.getClosedWindowData()[0].closedId;
|
closedIds.testWindow3 = SessionStore.getClosedWindowData()[0].closedId;
|
||||||
await BrowserTestUtils.closeWindow(privateWin);
|
await BrowserTestUtils.closeWindow(privateWin);
|
||||||
Assert.ok(
|
Assert.ok(
|
||||||
closedIds.testWindow2 > closedIds.testWindow1,
|
closedIds.testWindow2 > closedIds.testWindow1,
|
||||||
"We got the closedIds in the expected order"
|
"We got the closedIds in the expected order"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await BrowserTestUtils.closeWindow(testWindow6);
|
||||||
|
TelemetryTestUtils.assertHistogram(closedTabsHistogram, 0, 1);
|
||||||
|
closedTabsHistogram.clear();
|
||||||
|
|
||||||
|
await BrowserTestUtils.closeWindow(testWindow7);
|
||||||
|
TelemetryTestUtils.assertHistogram(closedTabsHistogram, 1, 1);
|
||||||
|
closedTabsHistogram.clear();
|
||||||
|
|
||||||
return closedIds;
|
return closedIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9307,6 +9307,17 @@
|
||||||
"n_values": 50,
|
"n_values": 50,
|
||||||
"description": "Session restore: Number of tabs restored eagerly in the session that has just been restored."
|
"description": "Session restore: Number of tabs restored eagerly in the session that has just been restored."
|
||||||
},
|
},
|
||||||
|
"FX_SESSION_RESTORE_CLOSED_TABS_NOT_SAVED": {
|
||||||
|
"record_in_processes": ["main", "content"],
|
||||||
|
"products": ["firefox"],
|
||||||
|
"expires_in_version": "127",
|
||||||
|
"alert_emails": ["firefox-view-engineers@mozilla.com"],
|
||||||
|
"releaseChannelCollection": "opt-out",
|
||||||
|
"bug_numbers": [1848459],
|
||||||
|
"kind": "enumerated",
|
||||||
|
"n_values": 25,
|
||||||
|
"description": "Session restore: Number of closed tabs that are NOT saved due to lack of open tabs worth saving on window close."
|
||||||
|
},
|
||||||
"FX_TABLETMODE_PAGE_LOAD": {
|
"FX_TABLETMODE_PAGE_LOAD": {
|
||||||
"record_in_processes": ["main", "content"],
|
"record_in_processes": ["main", "content"],
|
||||||
"products": ["firefox", "fennec"],
|
"products": ["firefox", "fennec"],
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue