зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1630391: Add telemetry test for backplate and a11y theme scalars. r=chutten,yzen
Differential Revision: https://phabricator.services.mozilla.com/D72184
This commit is contained in:
Родитель
dfcc816bd3
Коммит
564e7c4295
|
@ -42,6 +42,7 @@ BROWSER_CHROME_MANIFESTS += [
|
|||
'tests/browser/mac/browser.ini',
|
||||
'tests/browser/scroll/browser.ini',
|
||||
'tests/browser/states/browser.ini',
|
||||
'tests/browser/telemetry/browser.ini',
|
||||
'tests/browser/tree/browser.ini'
|
||||
]
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[browser_HCM_telemetry.js]
|
||||
support-files =
|
||||
!/browser/components/preferences/tests/head.js
|
|
@ -0,0 +1,135 @@
|
|||
/* 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/. */
|
||||
|
||||
/* import-globals-from ../../../../browser/components/preferences/tests/head.js */
|
||||
|
||||
"use strict";
|
||||
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochitests/content/browser/browser/components/preferences/tests/head.js",
|
||||
this
|
||||
);
|
||||
|
||||
ChromeUtils.import("resource://testing-common/TelemetryTestUtils.jsm", this);
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
Services.prefs.clearUserPref("browser.display.document_color_use");
|
||||
Services.prefs.clearUserPref("browser.display.permit_backplate");
|
||||
Services.telemetry.clearEvents();
|
||||
});
|
||||
|
||||
async function openColorsDialog() {
|
||||
await openPreferencesViaOpenPreferencesAPI("general", { leaveOpen: true });
|
||||
const colorsButton = gBrowser.selectedBrowser.contentDocument.getElementById(
|
||||
"colors"
|
||||
);
|
||||
|
||||
const dialogOpened = promiseLoadSubDialog(
|
||||
"chrome://browser/content/preferences/dialogs/colors.xhtml"
|
||||
);
|
||||
colorsButton.doCommand();
|
||||
|
||||
return dialogOpened;
|
||||
}
|
||||
|
||||
async function closeColorsDialog(dialogWin) {
|
||||
const dialogClosed = BrowserTestUtils.waitForEvent(dialogWin, "unload");
|
||||
dialogWin.document
|
||||
.getElementById("ColorsDialog")
|
||||
.getButton("accept")
|
||||
.doCommand();
|
||||
return dialogClosed;
|
||||
}
|
||||
|
||||
function verifyBackplate(expectedValue) {
|
||||
const snapshot = TelemetryTestUtils.getProcessScalars("parent", false, true);
|
||||
ok("a11y.backplate" in snapshot, "Backplate scalar must be present.");
|
||||
is(
|
||||
snapshot["a11y.backplate"],
|
||||
expectedValue,
|
||||
"Backplate scalar is logged as " + expectedValue
|
||||
);
|
||||
}
|
||||
|
||||
add_task(async function testIsNever() {
|
||||
const dialogWin = await openColorsDialog();
|
||||
const menulistHCM = dialogWin.document.getElementById("useDocumentColors");
|
||||
|
||||
is(menulistHCM.value, 1, "HCM menulist should be set to never on startup");
|
||||
|
||||
// Verify correct default value
|
||||
TelemetryTestUtils.assertKeyedScalar(
|
||||
TelemetryTestUtils.getProcessScalars("parent", true, true),
|
||||
"a11y.theme",
|
||||
"always",
|
||||
false
|
||||
);
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(async function testSetDefault() {
|
||||
const dialogWin = await openColorsDialog();
|
||||
const menulistHCM = dialogWin.document.getElementById("useDocumentColors");
|
||||
|
||||
menulistHCM.doCommand();
|
||||
const newOption = dialogWin.document.getElementById("documentColorAutomatic");
|
||||
newOption.click();
|
||||
|
||||
is(menulistHCM.value, 0, "HCM menulist should be set to default");
|
||||
|
||||
await closeColorsDialog(dialogWin);
|
||||
|
||||
// Verify correct initial value
|
||||
TelemetryTestUtils.assertKeyedScalar(
|
||||
TelemetryTestUtils.getProcessScalars("parent", true, true),
|
||||
"a11y.theme",
|
||||
"default",
|
||||
false
|
||||
);
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(async function testSetAlways() {
|
||||
const dialogWin = await openColorsDialog();
|
||||
const menulistHCM = dialogWin.document.getElementById("useDocumentColors");
|
||||
|
||||
menulistHCM.doCommand();
|
||||
const newOption = dialogWin.document.getElementById("documentColorAlways");
|
||||
newOption.click();
|
||||
|
||||
is(menulistHCM.value, 2, "HCM menulist should be set to always");
|
||||
|
||||
await closeColorsDialog(dialogWin);
|
||||
|
||||
// Verify correct initial value
|
||||
TelemetryTestUtils.assertKeyedScalar(
|
||||
TelemetryTestUtils.getProcessScalars("parent", true, true),
|
||||
"a11y.theme",
|
||||
"never",
|
||||
false
|
||||
);
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
// XXX We're uable to assert scalars that are false using assertScalar util,
|
||||
// so we directly query the scalar in the scalar list below. (bug 1633883)
|
||||
|
||||
add_task(async function testBackplate() {
|
||||
is(
|
||||
Services.prefs.getBoolPref("browser.display.permit_backplate"),
|
||||
true,
|
||||
"Backplate is init'd to true"
|
||||
);
|
||||
|
||||
Services.prefs.setBoolPref("browser.display.permit_backplate", false);
|
||||
// Verify correct recorded value
|
||||
verifyBackplate(0);
|
||||
|
||||
Services.prefs.setBoolPref("browser.display.permit_backplate", true);
|
||||
// Verify correct recorded value
|
||||
verifyBackplate(1);
|
||||
});
|
|
@ -12,7 +12,7 @@ a11y:
|
|||
- 1539212
|
||||
description: >
|
||||
Boolean tracking if the user has the backplate preference enabled or disabled.
|
||||
expires: "80"
|
||||
expires: never
|
||||
kind: boolean
|
||||
notification_emails:
|
||||
- accessibility@mozilla.com
|
||||
|
@ -73,7 +73,7 @@ a11y:
|
|||
The result is split into keys which represent the values of
|
||||
browser.display.document_color_use: "default", "always", or "never".
|
||||
keyed: true
|
||||
expires: "80"
|
||||
expires: never
|
||||
kind: boolean
|
||||
notification_emails:
|
||||
- accessibility@mozilla.com
|
||||
|
|
Загрузка…
Ссылка в новой задаче