зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1551965 - Add telemetry for page reload key combinations r=bdekoz,Gijs,chutten
Differential Revision: https://phabricator.services.mozilla.com/D35035 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a456952e71
Коммит
49f3772d40
|
@ -211,7 +211,7 @@
|
|||
<key id="key_toggleReaderMode" keycode="&toggleReaderMode.win.keycode;" command="View:ReaderView" disabled="true"/>
|
||||
#endif
|
||||
<key key="&reloadCmd.commandkey;" command="Browser:Reload" modifiers="accel" id="key_reload"/>
|
||||
<key key="&reloadCmd.commandkey;" command="Browser:ReloadSkipCache" modifiers="accel,shift"/>
|
||||
<key key="&reloadCmd.commandkey;" command="Browser:ReloadSkipCache" modifiers="accel,shift" id="key_reload_skip_cache"/>
|
||||
<key id="key_viewSource" key="&pageSourceCmd.commandkey;" command="View:PageSource" modifiers="accel"/>
|
||||
#ifdef XP_MACOSX
|
||||
<key id="key_viewSourceSafari" key="&pageSourceCmd.SafariCommandKey;" command="View:PageSource" modifiers="accel,alt"/>
|
||||
|
|
|
@ -1852,6 +1852,55 @@ var gBrowserInit = {
|
|||
}
|
||||
|
||||
this._loadHandled = true;
|
||||
let reloadHistogram = Services.telemetry.getHistogramById(
|
||||
"FX_PAGE_RELOAD_KEY_COMBO"
|
||||
);
|
||||
let reloadCommand = document.getElementById("Browser:Reload");
|
||||
reloadCommand.addEventListener("command", function(event) {
|
||||
let { target } = event.sourceEvent || {};
|
||||
if (target.getAttribute("keycode") == "VK_F5") {
|
||||
reloadHistogram.add("only_f5", 1);
|
||||
} else if (target.id == "key_reload") {
|
||||
reloadHistogram.add("accel_reloadKey", 1);
|
||||
}
|
||||
});
|
||||
|
||||
let reloadSkipCacheCommand = document.getElementById(
|
||||
"Browser:ReloadSkipCache"
|
||||
);
|
||||
reloadSkipCacheCommand.addEventListener("command", function(event) {
|
||||
let { target } = event.sourceEvent || {};
|
||||
if (target.getAttribute("keycode") == "VK_F5") {
|
||||
reloadHistogram.add("ctrl_f5", 1);
|
||||
} else if (target.id == "key_reload_skip_cache") {
|
||||
reloadHistogram.add("accel_shift_reload", 1);
|
||||
}
|
||||
});
|
||||
|
||||
let reloadOrDuplicateCommand = document.getElementById(
|
||||
"Browser:ReloadOrDuplicate"
|
||||
);
|
||||
reloadOrDuplicateCommand.addEventListener("command", function(event) {
|
||||
let { target } = event.sourceEvent || {};
|
||||
if (target.id == "reload-button") {
|
||||
let accelKeyPressed =
|
||||
AppConstants.platform == "macosx" ? event.metaKey : event.ctrlKey;
|
||||
let auxiliaryPressed = false;
|
||||
let { sourceEvent } = event.sourceEvent || {};
|
||||
if (sourceEvent) {
|
||||
auxiliaryPressed = sourceEvent.button == 1;
|
||||
}
|
||||
if (auxiliaryPressed) {
|
||||
reloadHistogram.add("auxiliary_toolbar", 1);
|
||||
} else if (accelKeyPressed) {
|
||||
reloadHistogram.add("accel_toolbar", 1);
|
||||
} else if (event.shiftKey) {
|
||||
reloadHistogram.add("shift_toolbar", 1);
|
||||
} else {
|
||||
reloadHistogram.add("toolbar", 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_cancelDelayedStartup() {
|
||||
|
@ -2617,9 +2666,9 @@ function BrowserStop() {
|
|||
|
||||
function BrowserReloadOrDuplicate(aEvent) {
|
||||
aEvent = getRootEvent(aEvent);
|
||||
let metaKeyPressed =
|
||||
let accelKeyPressed =
|
||||
AppConstants.platform == "macosx" ? aEvent.metaKey : aEvent.ctrlKey;
|
||||
var backgroundTabModifier = aEvent.button == 1 || metaKeyPressed;
|
||||
var backgroundTabModifier = aEvent.button == 1 || accelKeyPressed;
|
||||
|
||||
if (aEvent.shiftKey && !backgroundTabModifier) {
|
||||
BrowserReloadSkipCache();
|
||||
|
|
|
@ -55,3 +55,4 @@ support-files =
|
|||
[browser_UsageTelemetry_content.js]
|
||||
[browser_UsageTelemetry_content_aboutHome.js]
|
||||
[browser_UsageTelemetry_content_aboutRestartRequired.js]
|
||||
[browser_UsageTelemetry_reload_key_combination.js]
|
||||
|
|
|
@ -0,0 +1,160 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file tests page reload key combination telemetry
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const TAB_URL = "https://example.com";
|
||||
|
||||
var accelKey = "ctrlKey";
|
||||
if (AppConstants.platform == "macosx") {
|
||||
accelKey = "metaKey";
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["toolkit.cosmeticAnimations.enabled", false]],
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_pageReloadOnlyF5() {
|
||||
let histogram = TelemetryTestUtils.getAndClearHistogram(
|
||||
"FX_PAGE_RELOAD_KEY_COMBO"
|
||||
);
|
||||
|
||||
await BrowserTestUtils.withNewTab(TAB_URL, async browser => {
|
||||
let p = BrowserTestUtils.browserLoaded(browser);
|
||||
EventUtils.synthesizeKey("VK_F5");
|
||||
await p;
|
||||
|
||||
TelemetryTestUtils.assertHistogram(histogram, 0, 1);
|
||||
});
|
||||
});
|
||||
|
||||
if (AppConstants.platform != "macosx") {
|
||||
add_task(async function test_pageReloadAccelF5() {
|
||||
let histogram = TelemetryTestUtils.getAndClearHistogram(
|
||||
"FX_PAGE_RELOAD_KEY_COMBO"
|
||||
);
|
||||
|
||||
await BrowserTestUtils.withNewTab(TAB_URL, async browser => {
|
||||
let p = BrowserTestUtils.browserLoaded(browser);
|
||||
EventUtils.synthesizeKey("VK_F5", { accelKey: true });
|
||||
await p;
|
||||
|
||||
TelemetryTestUtils.assertHistogram(histogram, 1, 1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function test_pageReloadAccelR() {
|
||||
let histogram = TelemetryTestUtils.getAndClearHistogram(
|
||||
"FX_PAGE_RELOAD_KEY_COMBO"
|
||||
);
|
||||
|
||||
await BrowserTestUtils.withNewTab(TAB_URL, async browser => {
|
||||
let p = BrowserTestUtils.browserLoaded(browser);
|
||||
EventUtils.synthesizeKey("r", { accelKey: true });
|
||||
await p;
|
||||
|
||||
TelemetryTestUtils.assertHistogram(histogram, 2, 1);
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_pageReloadAccelShiftR() {
|
||||
let histogram = TelemetryTestUtils.getAndClearHistogram(
|
||||
"FX_PAGE_RELOAD_KEY_COMBO"
|
||||
);
|
||||
|
||||
await BrowserTestUtils.withNewTab(TAB_URL, async browser => {
|
||||
let p = BrowserTestUtils.browserLoaded(browser);
|
||||
EventUtils.synthesizeKey("r", { accelKey: true, shiftKey: true });
|
||||
await p;
|
||||
|
||||
TelemetryTestUtils.assertHistogram(histogram, 3, 1);
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_pageReloadToolbar() {
|
||||
let histogram = TelemetryTestUtils.getAndClearHistogram(
|
||||
"FX_PAGE_RELOAD_KEY_COMBO"
|
||||
);
|
||||
|
||||
await BrowserTestUtils.withNewTab(TAB_URL, async browser => {
|
||||
let reloadButton = document.getElementById("reload-button");
|
||||
let p = BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
await BrowserTestUtils.waitForCondition(() => {
|
||||
return !reloadButton.disabled;
|
||||
});
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(reloadButton, {});
|
||||
await p;
|
||||
|
||||
TelemetryTestUtils.assertHistogram(histogram, 4, 1);
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_pageReloadShiftToolbar() {
|
||||
let histogram = TelemetryTestUtils.getAndClearHistogram(
|
||||
"FX_PAGE_RELOAD_KEY_COMBO"
|
||||
);
|
||||
|
||||
await BrowserTestUtils.withNewTab(TAB_URL, async browser => {
|
||||
let reloadButton = document.getElementById("reload-button");
|
||||
let p = BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
await BrowserTestUtils.waitForCondition(() => {
|
||||
return !reloadButton.disabled;
|
||||
});
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(reloadButton, { shiftKey: true });
|
||||
await p;
|
||||
|
||||
TelemetryTestUtils.assertHistogram(histogram, 5, 1);
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_pageReloadAccelToolbar() {
|
||||
let histogram = TelemetryTestUtils.getAndClearHistogram(
|
||||
"FX_PAGE_RELOAD_KEY_COMBO"
|
||||
);
|
||||
|
||||
await BrowserTestUtils.withNewTab(TAB_URL, async browser => {
|
||||
let reloadButton = document.getElementById("reload-button");
|
||||
|
||||
await BrowserTestUtils.waitForCondition(() => {
|
||||
return !reloadButton.disabled;
|
||||
});
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(reloadButton, { accelKey: true });
|
||||
|
||||
TelemetryTestUtils.assertHistogram(histogram, 6, 1);
|
||||
// Accel + Toolbar would open an extra tab, so we need to call removeTab twice
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_pageReloadAuxiliaryToobar() {
|
||||
let histogram = TelemetryTestUtils.getAndClearHistogram(
|
||||
"FX_PAGE_RELOAD_KEY_COMBO"
|
||||
);
|
||||
|
||||
await BrowserTestUtils.withNewTab(TAB_URL, async browser => {
|
||||
let reloadButton = document.getElementById("reload-button");
|
||||
|
||||
await BrowserTestUtils.waitForCondition(() => {
|
||||
return !reloadButton.disabled;
|
||||
});
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(reloadButton, { button: 1 });
|
||||
|
||||
TelemetryTestUtils.assertHistogram(histogram, 7, 1);
|
||||
// Auxiliary + Toolbar would open an extra tab, so we need to call removeTab twice
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
});
|
|
@ -7104,6 +7104,17 @@
|
|||
"alert_emails": ["sefeng@mozilla.com", "perfteam@mozilla.com", "product-metrics-telemetry-alerts@mozilla.com"],
|
||||
"releaseChannelCollection": "opt-out"
|
||||
},
|
||||
"FX_PAGE_RELOAD_KEY_COMBO": {
|
||||
"record_in_processes": ["main"],
|
||||
"products": ["firefox"],
|
||||
"expires_in_version": "72",
|
||||
"kind": "categorical",
|
||||
"description": "Record the frequency for common key combinations that users can use to trigger a page reload",
|
||||
"labels": ["only_f5", "ctrl_f5", "accel_reloadKey", "accel_shift_reload", "toolbar", "shift_toolbar", "accel_toolbar", "auxiliary_toolbar"],
|
||||
"bug_numbers": [1551965],
|
||||
"alert_emails": ["sefeng@mozilla.com", "perfteam@mozilla.com", "product-metrics-telemetry-alerts@mozilla.com"],
|
||||
"releaseChannelCollection": "opt-out"
|
||||
},
|
||||
"FX_SCHEDULE_PRESSURE_IDLE_SAMPLE_MS": {
|
||||
"record_in_processes": ["main"],
|
||||
"products": ["firefox", "fennec", "geckoview"],
|
||||
|
|
Загрузка…
Ссылка в новой задаче