Bug 1786356 - Create Firefox View open Tracker r=niklas,jprickett

Differential Revision: https://phabricator.services.mozilla.com/D155432
This commit is contained in:
Meg Viar 2022-08-26 16:16:17 +00:00
parent 236776ef99
commit 4120ecafe3
3 changed files with 30 additions and 0 deletions

View File

@ -2719,3 +2719,5 @@ pref("browser.places.snapshots.expiration.userManaged.days", 420);
// If the user has seen the Firefox View feature tour this value reflects the tour
// message id, the id of the last screen they saw, and whether they completed the tour
pref("browser.firefox-view.feature-tour", "{\"message\":\"FIREFOX_VIEW_FEATURE_TOUR\",\"screen\":\"\",\"complete\":true}");
// Number of times the user visited about:firefoxview
pref("browser.firefox-view.view-count", 0);

View File

@ -9927,6 +9927,7 @@ var FirefoxViewHandler = {
this.button?.toggleAttribute("open", e.target == this.tab);
this.button?.setAttribute("aria-selected", e.target == this.tab);
this._removeNotificationDotIfTabSelected();
this._recordViewIfTabSelected();
break;
case "TabClose":
this.tab = null;
@ -9958,6 +9959,16 @@ var FirefoxViewHandler = {
);
}
},
_recordViewIfTabSelected() {
if (this.tab?.selected) {
const PREF_NAME = "browser.firefox-view.view-count";
const MAX_VIEW_COUNT = 10;
let viewCount = Services.prefs.getIntPref(PREF_NAME, 0);
if (viewCount < MAX_VIEW_COUNT) {
Services.prefs.setIntPref(PREF_NAME, viewCount + 1);
}
}
},
_toggleNotificationDot(shouldShow) {
this.button?.toggleAttribute("attention", shouldShow);
},

View File

@ -123,3 +123,20 @@ add_task(async function undo_close_tab() {
);
await BrowserTestUtils.closeWindow(win);
});
add_task(async function test_firefoxview_view_count() {
const startViews = 2;
await SpecialPowers.pushPrefEnv({
set: [["browser.firefox-view.view-count", startViews]],
});
let tab = await openFirefoxViewTab(window);
ok(
SpecialPowers.getIntPref("browser.firefox-view.view-count") ===
startViews + 1,
"View count pref value is incremented when tab is selected"
);
BrowserTestUtils.removeTab(tab);
});