зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1736688 - Remove telemetry probe: EXTERNAL_PROTOCOL_HANDLER_DIALOG_CONTEXT_SCHEME. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D156213
This commit is contained in:
Родитель
61775d53f8
Коммит
cc5eea6b97
|
@ -16770,116 +16770,6 @@
|
|||
"bug_numbers": [1671886],
|
||||
"description": "When echConfig is enabled, number of times a transaction is retried because of other error"
|
||||
},
|
||||
"EXTERNAL_PROTOCOL_HANDLER_DIALOG_CONTEXT_SCHEME": {
|
||||
"record_in_processes": ["main"],
|
||||
"products": ["firefox"],
|
||||
"alert_emails": ["pbz@mozilla.com", "seceng-telemetry@mozilla.com"],
|
||||
"bug_numbers": [1672344, 1683103, 1700832, 1720612],
|
||||
"expires_in_version": "96",
|
||||
"kind": "categorical",
|
||||
"releaseChannelCollection": "opt-out",
|
||||
"description": "Counts how often the external protocol handler dialog is shown. Labelled by protocol scheme. Keyed by the kind of browsing context the navigation was triggered from: TOPLEVEL: Top browser, SUB_SAMEORIGIN: Same origin iframe, SUB_CROSSORIGIN: Cross origin iframe, SUB_SANDBOX_ALLOW: Sandboxed iframe with relevant allow flags, SUB_SANDBOX_NOALLOW: Sandboxed iframe without relevant allow flags",
|
||||
"keyed": true,
|
||||
"keys": ["TOPLEVEL", "SUB_SAMEORIGIN", "SUB_CROSSORIGIN", "SUB_SANDBOX_ALLOW", "SUB_SANDBOX_NOALLOW", "UNKNOWN"],
|
||||
"labels": [
|
||||
"APPLE",
|
||||
"APPLE_FINDMY",
|
||||
"APPLE_LIVESTREAM",
|
||||
"APPLE_MUSIC",
|
||||
"BING",
|
||||
"FACEBOOK",
|
||||
"FACETIME",
|
||||
"GIT",
|
||||
"ICLOUD",
|
||||
"IMESSAGE",
|
||||
"INSTANT_MESSAGE",
|
||||
"IPP",
|
||||
"IRC",
|
||||
"MACAPPSTORE",
|
||||
"MAP",
|
||||
"MESSAGE",
|
||||
"MICROSOFT_APP",
|
||||
"MUSIC",
|
||||
"ONENOTE",
|
||||
"OTHER",
|
||||
"OUTLOOK",
|
||||
"PHOTOS",
|
||||
"PODCAST",
|
||||
"SEARCH",
|
||||
"SIP",
|
||||
"SKYPE",
|
||||
"TELEGRAM",
|
||||
"TELEVISION",
|
||||
"WEBHANDLER",
|
||||
"WINDOWS_PREFIX",
|
||||
"XBOX",
|
||||
"ZOOM",
|
||||
"addressbook",
|
||||
"afp",
|
||||
"aim",
|
||||
"apconfig",
|
||||
"apt",
|
||||
"apupdate",
|
||||
"bitcoin",
|
||||
"calculator",
|
||||
"calendar",
|
||||
"callto",
|
||||
"cap",
|
||||
"cifs",
|
||||
"cloudphoto",
|
||||
"daap",
|
||||
"dav",
|
||||
"dict",
|
||||
"doi",
|
||||
"feed",
|
||||
"ftp",
|
||||
"geo",
|
||||
"grvopen",
|
||||
"gtalk",
|
||||
"help",
|
||||
"ibooks",
|
||||
"ical",
|
||||
"info",
|
||||
"lastfm",
|
||||
"ldap",
|
||||
"magnet",
|
||||
"mailto",
|
||||
"mapi",
|
||||
"messenger",
|
||||
"msnweather",
|
||||
"mumble",
|
||||
"mvn",
|
||||
"nfs",
|
||||
"odopen",
|
||||
"rss",
|
||||
"slack",
|
||||
"smb",
|
||||
"sms",
|
||||
"snap",
|
||||
"spotify",
|
||||
"ssh",
|
||||
"steam",
|
||||
"stocks",
|
||||
"svn",
|
||||
"tbauth",
|
||||
"teamspeak",
|
||||
"tel",
|
||||
"telnet",
|
||||
"twitter",
|
||||
"ventrilo",
|
||||
"videos",
|
||||
"vnc",
|
||||
"vscode",
|
||||
"webcal",
|
||||
"weixin",
|
||||
"whatsapp",
|
||||
"xbls",
|
||||
"xmpp",
|
||||
"gotoopener",
|
||||
"msteams",
|
||||
"ROBLOX"
|
||||
]
|
||||
},
|
||||
"ECHCONFIG_SUCCESS_RATE": {
|
||||
"record_in_processes": ["main", "socket"],
|
||||
"products": ["firefox"],
|
||||
|
|
|
@ -16,10 +16,7 @@ const DIALOG_URL_APP_CHOOSER =
|
|||
const DIALOG_URL_PERMISSION =
|
||||
"chrome://mozapps/content/handling/permissionDialog.xhtml";
|
||||
|
||||
var EXPORTED_SYMBOLS = [
|
||||
"nsContentDispatchChooser",
|
||||
"ContentDispatchChooserTelemetry",
|
||||
];
|
||||
var EXPORTED_SYMBOLS = ["nsContentDispatchChooser"];
|
||||
|
||||
const gPrefs = {};
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
|
@ -32,212 +29,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||
const PROTOCOL_HANDLER_OPEN_PERM_KEY = "open-protocol-handler";
|
||||
const PERMISSION_KEY_DELIMITER = "^";
|
||||
|
||||
let ContentDispatchChooserTelemetry = {
|
||||
/**
|
||||
* Maps protocol scheme to telemetry label.
|
||||
*/
|
||||
SCHEME_TO_LABEL: {
|
||||
bingmaps: "BING",
|
||||
bingweather: "BING",
|
||||
fb: "FACEBOOK",
|
||||
fbmessenger: "FACEBOOK",
|
||||
findmy: "APPLE_FINDMY",
|
||||
findmyfriends: "APPLE_FINDMY",
|
||||
fmf1: "APPLE_FINDMY",
|
||||
fmip1: "APPLE_FINDMY",
|
||||
git: "GIT",
|
||||
"git-client": "GIT",
|
||||
grenada: "APPLE_FINDMY",
|
||||
ichat: "IMESSAGE",
|
||||
im: "INSTANT_MESSAGE",
|
||||
imessage: "IMESSAGE",
|
||||
ipp: "IPP",
|
||||
ipps: "IPP",
|
||||
irc: "IRC",
|
||||
irc6: "IRC",
|
||||
ircs: "IRC",
|
||||
itals: "APPLE_LIVESTREAM",
|
||||
italss: "APPLE_LIVESTREAM",
|
||||
itls: "APPLE_LIVESTREAM",
|
||||
itlss: "APPLE_LIVESTREAM",
|
||||
itms: "APPLE_MUSIC",
|
||||
itmss: "APPLE_MUSIC",
|
||||
itsradio: "APPLE_MUSIC",
|
||||
itunes: "APPLE_MUSIC",
|
||||
itunesradio: "APPLE_MUSIC",
|
||||
itvls: "APPLE_LIVESTREAM",
|
||||
itvlss: "APPLE_LIVESTREAM",
|
||||
macappstore: "MACAPPSTORE",
|
||||
macappstores: "MACAPPSTORE",
|
||||
map: "MAP",
|
||||
mapitem: "MAP",
|
||||
maps: "MAP",
|
||||
message: "MESSAGE",
|
||||
messages: "MESSAGE",
|
||||
microsoftmusic: "MICROSOFT_APP",
|
||||
microsoftvideo: "MICROSOFT_APP",
|
||||
mswindowsmusic: "MICROSOFT_APP",
|
||||
music: "MUSIC",
|
||||
musics: "MUSIC",
|
||||
onenote: "ONENOTE",
|
||||
"onenote-cmd": "ONENOTE",
|
||||
pcast: "PODCAST",
|
||||
podcast: "PODCAST",
|
||||
podcasts: "PODCAST",
|
||||
"roblox-player": "ROBLOX",
|
||||
search: "SEARCH",
|
||||
"search-ms": "SEARCH",
|
||||
sip: "SIP",
|
||||
sips: "SIP",
|
||||
skype: "SKYPE",
|
||||
"skype-meetnow": "SKYPE",
|
||||
skypewin: "SKYPE",
|
||||
tg: "TELEGRAM",
|
||||
tv: "TELEVISION",
|
||||
zoommtg: "ZOOM",
|
||||
zoompbx: "ZOOM",
|
||||
zoomus: "ZOOM",
|
||||
zune: "MICROSOFT_APP",
|
||||
},
|
||||
|
||||
/**
|
||||
* Maps protocol scheme prefix to telemetry label.
|
||||
*/
|
||||
SCHEME_PREFIX_TO_LABEL: {
|
||||
apple: "APPLE",
|
||||
"com.microsoft": "MICROSOFT_APP",
|
||||
facetime: "FACETIME",
|
||||
"fb-messenger": "FACEBOOK",
|
||||
icloud: "ICLOUD",
|
||||
"itms-": "APPLE_MUSIC",
|
||||
microsoft: "MICROSOFT_APP",
|
||||
"ms-": "MICROSOFT_APP",
|
||||
outlook: "OUTLOOK",
|
||||
photos: "PHOTOS",
|
||||
"web+": "WEBHANDLER",
|
||||
windows: "WINDOWS_PREFIX",
|
||||
"x-apple": "APPLE",
|
||||
xbox: "XBOX",
|
||||
},
|
||||
|
||||
/**
|
||||
* Sandbox flags for telemetry
|
||||
* Copied from nsSandboxFlags.h
|
||||
*/
|
||||
SANDBOXED_AUXILIARY_NAVIGATION: 0x2,
|
||||
SANDBOXED_TOPLEVEL_NAVIGATION: 0x4,
|
||||
SANDBOXED_TOPLEVEL_NAVIGATION_USER_ACTIVATION: 0x20000,
|
||||
|
||||
/**
|
||||
* Lazy getter for labels of the external protocol navigation telemetry probe.
|
||||
* @returns {string[]} - An array of histogram labels.
|
||||
*/
|
||||
get _telemetryLabels() {
|
||||
if (!this._telemetryLabelArray) {
|
||||
this._telemetryLabelArray = Services.telemetry.getCategoricalLabels().EXTERNAL_PROTOCOL_HANDLER_DIALOG_CONTEXT_SCHEME;
|
||||
}
|
||||
return this._telemetryLabelArray;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get histogram label by protocol scheme.
|
||||
* @param {string} aScheme - Protocol scheme to map to histogram label.
|
||||
* @returns {string} - Label.
|
||||
*/
|
||||
_getTelemetryLabel(aScheme) {
|
||||
if (!aScheme) {
|
||||
throw new Error("Invalid scheme");
|
||||
}
|
||||
let labels = this._telemetryLabels;
|
||||
|
||||
// Custom scheme-to-label mappings
|
||||
let mappedLabel = this.SCHEME_TO_LABEL[aScheme];
|
||||
if (mappedLabel) {
|
||||
return mappedLabel;
|
||||
}
|
||||
|
||||
// Prefix mappings
|
||||
for (let prefix of Object.keys(this.SCHEME_PREFIX_TO_LABEL)) {
|
||||
if (aScheme.startsWith(prefix)) {
|
||||
return this.SCHEME_PREFIX_TO_LABEL[prefix];
|
||||
}
|
||||
}
|
||||
|
||||
// Test if we have a label for the protocol scheme.
|
||||
// If not, we use the "OTHER" label.
|
||||
if (labels.includes(aScheme)) {
|
||||
return aScheme;
|
||||
}
|
||||
|
||||
return "OTHER";
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine if a load was triggered from toplevel or an iframe
|
||||
* (cross origin, same origin, sandboxed).
|
||||
*
|
||||
* @param {BrowsingContext} [aBrowsingContext] - Context of the load.
|
||||
* @param {nsIPrincipal} [aTriggeringPrincipal] - Principal which triggered
|
||||
* the load.
|
||||
* @returns {string} - Histogram key. May return "UNKNOWN".
|
||||
*/
|
||||
_getTelemetryKey(aBrowsingContext, aTriggeringPrincipal) {
|
||||
if (!aBrowsingContext) {
|
||||
return "UNKNOWN";
|
||||
}
|
||||
if (aBrowsingContext.top == aBrowsingContext) {
|
||||
return "TOPLEVEL";
|
||||
}
|
||||
|
||||
let { sandboxFlags } = aBrowsingContext;
|
||||
if (sandboxFlags) {
|
||||
// Iframe is sandboxed. Determine whether it sets allow flags relevant
|
||||
// for the external protocol navigation.
|
||||
if (
|
||||
!(sandboxFlags & this.SANDBOXED_TOPLEVEL_NAVIGATION) ||
|
||||
!(sandboxFlags & this.SANDBOXED_TOPLEVEL_NAVIGATION_USER_ACTIVATION) ||
|
||||
!(sandboxFlags & this.SANDBOXED_AUXILIARY_NAVIGATION)
|
||||
) {
|
||||
return "SUB_SANDBOX_ALLOW";
|
||||
}
|
||||
return "SUB_SANDBOX_NOALLOW";
|
||||
}
|
||||
|
||||
// We're in a frame, check if the frame is cross origin with the top context.
|
||||
if (!aTriggeringPrincipal) {
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
let topLevelPrincipal =
|
||||
aBrowsingContext.top.embedderElement?.contentPrincipal;
|
||||
if (!topLevelPrincipal) {
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
if (topLevelPrincipal.isThirdPartyPrincipal(aTriggeringPrincipal)) {
|
||||
return "SUB_CROSSORIGIN";
|
||||
}
|
||||
|
||||
return "SUB_SAMEORIGIN";
|
||||
},
|
||||
|
||||
/**
|
||||
* Record telemetry for the external protocol handler dialog.
|
||||
* @param {string} aScheme - Scheme of the protocol being loaded.
|
||||
* @param {BrowsingContext} [aBrowsingContext] - Context of the load.
|
||||
* @param {nsIPrincipal} [aTriggeringPrincipal] - Principal which triggered
|
||||
* the load.
|
||||
*/
|
||||
recordTelemetry(aScheme, aBrowsingContext, aTriggeringPrincipal) {
|
||||
let type = this._getTelemetryKey(aBrowsingContext, aTriggeringPrincipal);
|
||||
let label = this._getTelemetryLabel(aScheme);
|
||||
|
||||
Services.telemetry
|
||||
.getKeyedHistogramById("EXTERNAL_PROTOCOL_HANDLER_DIALOG_CONTEXT_SCHEME")
|
||||
.add(type, label);
|
||||
},
|
||||
};
|
||||
|
||||
class nsContentDispatchChooser {
|
||||
/**
|
||||
* Prompt the user to open an external application.
|
||||
|
@ -300,17 +91,6 @@ class nsContentDispatchChooser {
|
|||
}
|
||||
}
|
||||
|
||||
// We will show a prompt, record telemetry.
|
||||
try {
|
||||
ContentDispatchChooserTelemetry.recordTelemetry(
|
||||
aHandler.type,
|
||||
aBrowsingContext,
|
||||
aPrincipal
|
||||
);
|
||||
} catch (error) {
|
||||
Cu.reportError(error);
|
||||
}
|
||||
|
||||
let shouldOpenHandler = false;
|
||||
|
||||
try {
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { ContentDispatchChooserTelemetry } = ChromeUtils.import(
|
||||
"resource://gre/modules/ContentDispatchChooser.jsm"
|
||||
);
|
||||
|
||||
let telemetryLabels = Services.telemetry.getCategoricalLabels()
|
||||
.EXTERNAL_PROTOCOL_HANDLER_DIALOG_CONTEXT_SCHEME;
|
||||
|
||||
let schemeToLabel = ContentDispatchChooserTelemetry.SCHEME_TO_LABEL;
|
||||
let schemePrefixToLabel =
|
||||
ContentDispatchChooserTelemetry.SCHEME_PREFIX_TO_LABEL;
|
||||
|
||||
/**
|
||||
* Test for scheme-label mappings of protocol ask dialog telemetry.
|
||||
*/
|
||||
add_task(async function test_telemetry_label_maps() {
|
||||
let mapValues = Object.values(schemeToLabel).concat(
|
||||
Object.values(schemePrefixToLabel)
|
||||
);
|
||||
|
||||
// Scheme - label maps must have valid label values.
|
||||
mapValues.forEach(label => {
|
||||
// Mapped labels must be valid.
|
||||
Assert.ok(telemetryLabels.includes(label), `Exists label: ${label}`);
|
||||
});
|
||||
|
||||
// Uppercase labels must have a mapping.
|
||||
telemetryLabels.forEach(label => {
|
||||
Assert.equal(
|
||||
label == "OTHER" || mapValues.includes(label),
|
||||
label == label.toUpperCase(),
|
||||
`Exists label: ${label}`
|
||||
);
|
||||
});
|
||||
|
||||
Object.keys(schemeToLabel).forEach(key => {
|
||||
// Schemes which have a mapping must not exist as as label.
|
||||
Assert.ok(!telemetryLabels.includes(key), `Not exists label: ${key}`);
|
||||
|
||||
// There must be no key duplicates across the two maps.
|
||||
Assert.ok(!schemePrefixToLabel[key], `No duplicate key: ${key}`);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Tests the getTelemetryLabel method.
|
||||
*/
|
||||
add_task(async function test_telemetry_getTelemetryLabel() {
|
||||
// Method should return the correct mapping.
|
||||
Object.keys(schemeToLabel).forEach(scheme => {
|
||||
Assert.equal(
|
||||
schemeToLabel[scheme],
|
||||
ContentDispatchChooserTelemetry._getTelemetryLabel(scheme)
|
||||
);
|
||||
});
|
||||
|
||||
// Passing null to _getTelemetryLabel should throw.
|
||||
Assert.throws(() => {
|
||||
ContentDispatchChooserTelemetry._getTelemetryLabel(null);
|
||||
}, /Invalid scheme/);
|
||||
|
||||
// Replace maps with test data
|
||||
ContentDispatchChooserTelemetry.SCHEME_TO_LABEL = {
|
||||
foo: "FOOLABEL",
|
||||
bar: "BARLABEL",
|
||||
};
|
||||
|
||||
ContentDispatchChooserTelemetry.SCHEME_PREFIX_TO_LABEL = {
|
||||
fooPrefix: "FOOPREFIXLABEL",
|
||||
barPrefix: "BARPREFIXLABEL",
|
||||
fo: "PREFIXLABEL",
|
||||
};
|
||||
|
||||
Assert.equal(
|
||||
ContentDispatchChooserTelemetry._getTelemetryLabel("foo"),
|
||||
"FOOLABEL",
|
||||
"Non prefix mapping should have priority"
|
||||
);
|
||||
|
||||
Assert.equal(
|
||||
ContentDispatchChooserTelemetry._getTelemetryLabel("bar"),
|
||||
"BARLABEL",
|
||||
"Should return the correct label"
|
||||
);
|
||||
|
||||
Assert.equal(
|
||||
ContentDispatchChooserTelemetry._getTelemetryLabel("fooPrefix"),
|
||||
"FOOPREFIXLABEL",
|
||||
"Should return the correct label"
|
||||
);
|
||||
|
||||
Assert.equal(
|
||||
ContentDispatchChooserTelemetry._getTelemetryLabel("fooPrefix1"),
|
||||
"FOOPREFIXLABEL",
|
||||
"Should return the correct label"
|
||||
);
|
||||
|
||||
Assert.equal(
|
||||
ContentDispatchChooserTelemetry._getTelemetryLabel("fooPrefix2"),
|
||||
"FOOPREFIXLABEL",
|
||||
"Should return the correct label"
|
||||
);
|
||||
|
||||
Assert.equal(
|
||||
ContentDispatchChooserTelemetry._getTelemetryLabel("doesnotexist"),
|
||||
"OTHER",
|
||||
"Should return the correct label for unknown scheme"
|
||||
);
|
||||
|
||||
// Restore maps
|
||||
ContentDispatchChooserTelemetry.SCHEME_TO_LABEL = schemeToLabel;
|
||||
ContentDispatchChooserTelemetry.SCHEME_PREFIX_TO_LABEL = schemePrefixToLabel;
|
||||
});
|
|
@ -34,5 +34,3 @@ fail-if = os == "android"
|
|||
fail-if = os == "android"
|
||||
support-files = handlers.json
|
||||
[test_punycodeURIs.js]
|
||||
[test_protocol_ask_dialog_telemetry.js]
|
||||
skip-if = os == "android" # Desktop telemetry
|
||||
|
|
Загрузка…
Ссылка в новой задаче