Bug 1740063 - Collect telemetry for hidden browser.link.open_newwindow.restriction preference usage. r=chutten

Differential Revision: https://phabricator.services.mozilla.com/D130887
This commit is contained in:
Tooru Fujisawa 2021-11-17 23:29:56 +00:00
Родитель 4b5bda15cb
Коммит 0958039f60
5 изменённых файлов: 91 добавлений и 0 удалений

Просмотреть файл

@ -17,6 +17,8 @@ const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
Cu.importGlobalProperties(["Glean"]);
XPCOMUtils.defineLazyModuleGetters(this, {
AboutNewTab: "resource:///modules/AboutNewTab.jsm",
ActorManagerParent: "resource://gre/modules/ActorManagerParent.jsm",
@ -1088,6 +1090,8 @@ BrowserGlue.prototype = {
}
} else if (data == "add-breaches-sync-handler") {
this._addBreachesSyncHandler();
} else if (data == "new-window-restriction-telemetry") {
this._collectNewWindowRestrictionTelemetry();
}
break;
case "initial-migration-will-import-default-bookmarks":
@ -2713,6 +2717,12 @@ BrowserGlue.prototype = {
},
},
{
task: () => {
this._collectNewWindowRestrictionTelemetry();
},
},
// WebDriver components (Remote Agent and Marionette) need to be
// initialized as very last step.
{
@ -4537,6 +4547,14 @@ BrowserGlue.prototype = {
}
},
_collectNewWindowRestrictionTelemetry() {
let restrictionPref = Services.prefs.getIntPref(
"browser.link.open_newwindow.restriction",
2
);
Glean.browserLink.openNewwindowRestriction.set(restrictionPref);
},
QueryInterface: ChromeUtils.generateQI([
"nsIObserver",
"nsISupportsWeakReference",

Просмотреть файл

@ -0,0 +1,21 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
---
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0
browser.link:
open_newwindow_restriction:
type: quantity
description: >
browser.link.open_newwindow.restriction preference value, that is one of
0, 1, or 2, where 2 is desktop default
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1740063
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1740063#c6
notification_emails:
- tfujisawa.birchill@mozilla.com
expires: "97"
unit: "-"

Просмотреть файл

@ -0,0 +1,50 @@
/* 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
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const gBrowserGlue = Cc["@mozilla.org/browser/browserglue;1"].getService(
Ci.nsIObserver
);
Cu.importGlobalProperties(["Glean"]);
const RESTRICTION_PREF = "browser.link.open_newwindow.restriction";
function collectTelemetry() {
gBrowserGlue.observe(
null,
"browser-glue-test",
"new-window-restriction-telemetry"
);
}
add_task(async function() {
const FOG = Cc["@mozilla.org/toolkit/glean;1"].createInstance(Ci.nsIFOG);
FOG.initializeFOG();
Services.prefs.setIntPref(RESTRICTION_PREF, 0);
collectTelemetry();
Assert.equal(Glean.browserLink.openNewwindowRestriction.testGetValue(), 0);
Services.prefs.setIntPref(RESTRICTION_PREF, 1);
collectTelemetry();
Assert.equal(Glean.browserLink.openNewwindowRestriction.testGetValue(), 1);
Services.prefs.setIntPref(RESTRICTION_PREF, 2);
collectTelemetry();
Assert.equal(Glean.browserLink.openNewwindowRestriction.testGetValue(), 2);
// Test 0 again to verify that 0 above wasn't garbage data, and also as a
// preparetion for the next default pref test.
Services.prefs.setIntPref(RESTRICTION_PREF, 0);
collectTelemetry();
Assert.equal(Glean.browserLink.openNewwindowRestriction.testGetValue(), 0);
Services.prefs.clearUserPref(RESTRICTION_PREF);
collectTelemetry();
Assert.equal(Glean.browserLink.openNewwindowRestriction.testGetValue(), 2);
});
registerCleanupFunction(function() {
Services.prefs.clearUserPref(RESTRICTION_PREF);
});

Просмотреть файл

@ -11,3 +11,4 @@ support-files =
[test_distribution_cachedexistence.js]
[test_browserGlue_migration_no_errors.js]
[test_browserGlue_migration_social_cleanup.js]
[test_browserGlue_newwindow_restriction_telemetry.js]

Просмотреть файл

@ -13,6 +13,7 @@ metrics_yamls = [
"browser/base/content/metrics.yaml",
"gfx/metrics.yaml",
"toolkit/components/processtools/metrics.yaml",
"browser/components/metrics.yaml",
]
# The list of all Glean pings.yaml files, relative to the top src dir.