Commit 17bcd7d1 authored by Morgan Rae Reschenberg's avatar Morgan Rae Reschenberg
Browse files

Bug 1835194: Add Use System Colors telemetry probe r=eeejay

parent 543f3e05
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ function reset() {
  // state changes.
  Services.prefs.clearUserPref("browser.display.document_color_use");
  Services.prefs.clearUserPref("browser.display.permit_backplate");
  Services.prefs.clearUserPref("browser.display.use_system_colors");
  Services.telemetry.clearEvents();
  TelemetryTestUtils.assertNumberOfEvents(0);
  Services.prefs.clearUserPref("browser.display.foreground_color");
@@ -63,6 +64,18 @@ function verifyBackplate(expectedValue) {
    "Backplate scalar is logged as " + expectedValue
  );
}

function verifyUseSystemColors(expectedValue) {
  const snapshot = TelemetryTestUtils.getProcessScalars("parent", false, false);
  ok("a11y.use_system_colors" in snapshot, "System color usage was logged.");
  TelemetryTestUtils.assertScalar(
    snapshot,
    "a11y.use_system_colors",
    expectedValue,
    "System colors scalar is logged as " + expectedValue
  );
}

// The magic numbers below are the uint32_t values representing RGB white
// and RGB black respectively. They're directly captured as nsColors and
// follow the same bit-shift pattern.
@@ -321,3 +334,34 @@ add_task(async function testBackplate() {
  // Verify correct recorded value
  verifyBackplate(true);
});

add_task(async function testSystemColors() {
  let expectedInitVal = false;
  if (AppConstants.platform == "win") {
    expectedInitVal = true;
  }

  is(
    Services.prefs.getBoolPref("browser.display.use_system_colors"),
    expectedInitVal,
    "Use system colours pref is init'd correctly"
  );
  verifyUseSystemColors(expectedInitVal);

  const dialogWin = await openColorsDialog();
  const checkbox = dialogWin.document.getElementById("browserUseSystemColors");
  checkbox.click();

  is(
    checkbox.checked,
    !expectedInitVal,
    "System colors checkbox should be modified"
  );

  await closeColorsDialog(dialogWin);

  verifyUseSystemColors(!expectedInitVal);

  reset();
  gBrowser.removeCurrentTab();
});
+2 −0
Original line number Diff line number Diff line
@@ -285,6 +285,8 @@ void PreferenceSheet::Initialize() {

  Telemetry::ScalarSet(Telemetry::ScalarID::A11Y_BACKPLATE,
                       StaticPrefs::browser_display_permit_backplate());
  Telemetry::ScalarSet(Telemetry::ScalarID::A11Y_USE_SYSTEM_COLORS,
                       StaticPrefs::browser_display_use_system_colors());
}

bool PreferenceSheet::AffectedByPref(const nsACString& aPref) {
+17 −0
Original line number Diff line number Diff line
@@ -7,6 +7,23 @@

# The following section contains the accessibility scalars.
a11y:
  use_system_colors:
    bug_numbers:
      - 1835194
    description: >
      Bool tracking if the user has system colors enabled in firefox.
    expires: never
    kind: boolean
    notification_emails:
      - accessibility@mozilla.com
      - mreschenberg@mozilla.com
    products:
      - 'firefox'
    record_in_processes:
      - 'main'
    release_channel_collection: opt-out
    keyed: false

  HCM_background:
    bug_numbers:
      - 1694717