forked from mirrors/gecko-dev
Bug 1852036 - Add an entered probe to firefoxview next r=jsudiaman,fxview-reviewers,sfoster
Differential Revision: https://phabricator.services.mozilla.com/D188283
This commit is contained in:
parent
d5b2a4ac5a
commit
8016a76331
4 changed files with 113 additions and 9 deletions
|
|
@ -24,7 +24,7 @@ function changePage(page) {
|
|||
}
|
||||
}
|
||||
|
||||
function recordTelemetry(source, eventTarget) {
|
||||
function recordNavigationTelemetry(source, eventTarget) {
|
||||
let page = "recentbrowsing";
|
||||
if (source === "category-navigation") {
|
||||
page = eventTarget.parentNode.currentCategory;
|
||||
|
|
@ -46,6 +46,7 @@ function recordTelemetry(source, eventTarget) {
|
|||
|
||||
window.addEventListener("DOMContentLoaded", async () => {
|
||||
Services.telemetry.setEventRecordingEnabled("firefoxview_next", true);
|
||||
recordEnteredTelemetry();
|
||||
let navigation = document.querySelector("fxview-category-navigation");
|
||||
for (const item of navigation.categoryButtons) {
|
||||
pageList.push(item.getAttribute("name"));
|
||||
|
|
@ -53,10 +54,10 @@ window.addEventListener("DOMContentLoaded", async () => {
|
|||
window.addEventListener("hashchange", onHashChange);
|
||||
window.addEventListener("change-category", function (event) {
|
||||
location.hash = event.target.getAttribute("name");
|
||||
recordTelemetry("category-navigation", event.target);
|
||||
recordNavigationTelemetry("category-navigation", event.target);
|
||||
});
|
||||
window.addEventListener("card-container-view-all", function (event) {
|
||||
recordTelemetry("view-all", event.originalTarget);
|
||||
recordNavigationTelemetry("view-all", event.originalTarget);
|
||||
});
|
||||
if (document.location.hash) {
|
||||
changePage(document.location.hash.substring(1));
|
||||
|
|
@ -75,6 +76,24 @@ document
|
|||
}
|
||||
});
|
||||
|
||||
document.addEventListener("visibilitychange", () => {
|
||||
if (document.visibilityState === "visible") {
|
||||
recordEnteredTelemetry();
|
||||
}
|
||||
});
|
||||
|
||||
function recordEnteredTelemetry() {
|
||||
Services.telemetry.recordEvent(
|
||||
"firefoxview_next",
|
||||
"entered",
|
||||
"firefoxview",
|
||||
null,
|
||||
{
|
||||
page: document.location?.hash?.substring(1) || "recentbrowsing",
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
window.addEventListener(
|
||||
"unload",
|
||||
() => {
|
||||
|
|
|
|||
|
|
@ -3,22 +3,25 @@
|
|||
|
||||
/* import-globals-from ../head.js */
|
||||
|
||||
const FXVIEW_NEXT_ENABLED_PREF = "browser.tabs.firefox-view-next";
|
||||
const FXVIEW_ENABLED_PREF = "browser.tabs.firefox-view";
|
||||
|
||||
add_task(async function about_firefoxview_next_pref() {
|
||||
// Verify pref enables new Firefox view
|
||||
Services.prefs.setBoolPref("browser.tabs.firefox-view-next", true);
|
||||
await SpecialPowers.pushPrefEnv({ set: [[FXVIEW_NEXT_ENABLED_PREF, true]] });
|
||||
await withFirefoxView({}, async browser => {
|
||||
const { document } = browser.contentWindow;
|
||||
is(document.location.href, "about:firefoxview-next");
|
||||
});
|
||||
// Verify pref enables new Firefox view even when old is disabled
|
||||
Services.prefs.setBoolPref("browser.tabs.firefox-view", false);
|
||||
await SpecialPowers.pushPrefEnv({ set: [[FXVIEW_ENABLED_PREF, false]] });
|
||||
await withFirefoxView({}, async browser => {
|
||||
const { document } = browser.contentWindow;
|
||||
is(document.location.href, "about:firefoxview-next");
|
||||
});
|
||||
Services.prefs.setBoolPref("browser.tabs.firefox-view", true);
|
||||
await SpecialPowers.pushPrefEnv({ set: [[FXVIEW_ENABLED_PREF, true]] });
|
||||
// Verify pref disables new Firefox view
|
||||
Services.prefs.setBoolPref("browser.tabs.firefox-view-next", false);
|
||||
await SpecialPowers.pushPrefEnv({ set: [[FXVIEW_NEXT_ENABLED_PREF, false]] });
|
||||
await withFirefoxView({}, async browser => {
|
||||
const { document } = browser.contentWindow;
|
||||
is(document.location.href, "about:firefoxview");
|
||||
|
|
@ -26,7 +29,7 @@ add_task(async function about_firefoxview_next_pref() {
|
|||
});
|
||||
|
||||
add_task(async function test_aria_roles() {
|
||||
Services.prefs.setBoolPref("browser.tabs.firefox-view-next", true);
|
||||
await SpecialPowers.pushPrefEnv({ set: [[FXVIEW_NEXT_ENABLED_PREF, true]] });
|
||||
await withFirefoxView({}, async browser => {
|
||||
const { document } = browser.contentWindow;
|
||||
is(document.location.href, "about:firefoxview-next");
|
||||
|
|
@ -94,7 +97,7 @@ add_task(async function test_aria_roles() {
|
|||
);
|
||||
});
|
||||
// Verify pref disables new Firefox view
|
||||
Services.prefs.setBoolPref("browser.tabs.firefox-view-next", false);
|
||||
await SpecialPowers.pushPrefEnv({ set: [[FXVIEW_NEXT_ENABLED_PREF, false]] });
|
||||
await withFirefoxView({}, async browser => {
|
||||
const { document } = browser.contentWindow;
|
||||
is(document.location.href, "about:firefoxview");
|
||||
|
|
|
|||
|
|
@ -95,6 +95,27 @@ async function contextMenuTelemetry(contextMenuEvent) {
|
|||
);
|
||||
}
|
||||
|
||||
async function enteredTelemetry(enteredEvent) {
|
||||
await TestUtils.waitForCondition(
|
||||
() => {
|
||||
let events = Services.telemetry.snapshotEvents(
|
||||
Ci.nsITelemetry.DATASET_PRERELEASE_CHANNELS,
|
||||
false
|
||||
).parent;
|
||||
return events && events.length >= 1;
|
||||
},
|
||||
"Waiting for entered firefoxview_next telemetry event.",
|
||||
200,
|
||||
100
|
||||
);
|
||||
|
||||
TelemetryTestUtils.assertEvents(
|
||||
enteredEvent,
|
||||
{ category: "firefoxview_next" },
|
||||
{ clear: true, process: "parent" }
|
||||
);
|
||||
}
|
||||
|
||||
add_setup(async () => {
|
||||
await SpecialPowers.pushPrefEnv({ set: [[FXVIEW_NEXT_ENABLED_PREF, true]] });
|
||||
registerCleanupFunction(async () => {
|
||||
|
|
@ -332,3 +353,48 @@ add_task(async function test_context_menu_telemetry() {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function firefox_view_entered_telemetry() {
|
||||
await SpecialPowers.pushPrefEnv({ set: [[FXVIEW_NEXT_ENABLED_PREF, true]] });
|
||||
await clearAllParentTelemetryEvents();
|
||||
await withFirefoxView({}, async browser => {
|
||||
const { document } = browser.contentWindow;
|
||||
is(document.location.href, "about:firefoxview-next");
|
||||
let enteredEvent = [
|
||||
[
|
||||
"firefoxview_next",
|
||||
"entered",
|
||||
"firefoxview",
|
||||
null,
|
||||
{ page: "recentbrowsing" },
|
||||
],
|
||||
];
|
||||
await enteredTelemetry(enteredEvent);
|
||||
|
||||
enteredEvent = [
|
||||
[
|
||||
"firefoxview_next",
|
||||
"entered",
|
||||
"firefoxview",
|
||||
null,
|
||||
{ page: "recentlyclosed" },
|
||||
],
|
||||
];
|
||||
|
||||
navigateToCategory(document, "recentlyclosed");
|
||||
await clearAllParentTelemetryEvents();
|
||||
await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:robots");
|
||||
is(
|
||||
gBrowser.selectedBrowser.currentURI.spec,
|
||||
"about:robots",
|
||||
"The selected tab is about:robots"
|
||||
);
|
||||
await switchToFxViewTab(browser.ownerGlobal);
|
||||
await enteredTelemetry(enteredEvent);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
// clean up extra tabs
|
||||
while (gBrowser.tabs.length > 1) {
|
||||
BrowserTestUtils.removeTab(gBrowser.tabs.at(-1));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4057,6 +4057,22 @@ firefoxview_next:
|
|||
- 1842616
|
||||
expiry_version: "never"
|
||||
release_channel_collection: opt-out
|
||||
entered:
|
||||
objects: ["firefoxview"]
|
||||
description: >
|
||||
Recorded when the Firefox View tab is selected
|
||||
extra_keys:
|
||||
page: The short page name used as the location hash when selecting the Firefox View tab
|
||||
notification_emails:
|
||||
- firefoxview@mozilla.com
|
||||
products:
|
||||
- "firefox"
|
||||
record_in_processes:
|
||||
- main
|
||||
bug_numbers:
|
||||
- 1852036
|
||||
expiry_version: "never"
|
||||
release_channel_collection: opt-out
|
||||
|
||||
search:
|
||||
engine:
|
||||
|
|
|
|||
Loading…
Reference in a new issue