Skip to content

Commit

Permalink
Backed out changeset 32aba4f911e2 (bug 1740232) for causing build bus…
Browse files Browse the repository at this point in the history
…tages on TelemetryScalarData.h CLOSED TREE
  • Loading branch information
Norisz Fay committed Nov 18, 2021
1 parent cee8088 commit e3cab91
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 88 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */

const { TelemetryTestUtils } = ChromeUtils.import(
"resource://testing-common/TelemetryTestUtils.jsm"
);

const PREF_DFPI_ENABLED_BY_DEFAULT =
"privacy.restrict3rdpartystorage.rollout.enabledByDefault";
const COOKIE_BEHAVIOR_PREF = "network.cookie.cookieBehavior";
Expand Down Expand Up @@ -37,74 +33,48 @@ function testSearchPrefState(optIn) {
let expectedPrefs = optIn ? SEARCH_PREFS_OPT_IN : SEARCH_PREFS_OPT_OUT;

expectedPrefs.forEach(([key, value]) => {
ok(
Services.prefs.prefHasUserValue(key),
`Pref '${key}' should have user value.'`
);
ok(Services.prefs.prefHasUserValue(key));
is(
Services.prefs.getStringPref(key),
value,
`Pref '${key}' should have correct value.`
`Pref '${key}' is set by the action`
);
});
}

function testTelemetryState(optIn) {
let expectedValue;
if (optIn == null) {
expectedValue = 2;
} else {
expectedValue = optIn ? 1 : 0;
}

TelemetryTestUtils.assertScalar(
TelemetryTestUtils.getProcessScalars("parent"),
"privacy.dfpi_rollout_enabledByDefault",
expectedValue,
"Scalar should have correct value"
);
}

// Tests that the dFPI rollout pref updates the default cookieBehavior to 5,
// sets the correct search prefs and records telemetry.
// Tests that the dFPI rollout pref updates the default cookieBehavior to 5 and
// sets the correct search prefs.
add_task(async function testdFPIRolloutPref() {
defaultPrefs.setIntPref(
COOKIE_BEHAVIOR_PREF,
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER
);

// Test the unset state of the pref.
testTelemetryState(null);

Services.prefs.setBoolPref(PREF_DFPI_ENABLED_BY_DEFAULT, false);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER
);
testSearchPrefState(false);
testTelemetryState(false);

Services.prefs.setBoolPref(PREF_DFPI_ENABLED_BY_DEFAULT, true);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN
);
testSearchPrefState(true);
testTelemetryState(true);

Services.prefs.setBoolPref(PREF_DFPI_ENABLED_BY_DEFAULT, false);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER
);
testSearchPrefState(false);
testTelemetryState(false);

Services.prefs.setBoolPref(PREF_DFPI_ENABLED_BY_DEFAULT, true);
is(
defaultPrefs.getIntPref(COOKIE_BEHAVIOR_PREF),
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN
);
testSearchPrefState(true);
testTelemetryState(true);
});
6 changes: 0 additions & 6 deletions browser/components/BrowserGlue.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,6 @@ BrowserGlue.prototype = {
// set during onboarding when the user chooses to enable protections or not.
_setDefaultCookieBehavior() {
if (!Services.prefs.prefHasUserValue(PREF_DFPI_ENABLED_BY_DEFAULT)) {
Services.telemetry.scalarSet("privacy.dfpi_rollout_enabledByDefault", 2);
return;
}
let dFPIEnabled = Services.prefs.getBoolPref(PREF_DFPI_ENABLED_BY_DEFAULT);
Expand All @@ -1735,11 +1734,6 @@ BrowserGlue.prototype = {
: Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER
);

Services.telemetry.scalarSet(
"privacy.dfpi_rollout_enabledByDefault",
dFPIEnabled ? 1 : 0
);

if (dFPIEnabled) {
Services.prefs.setStringPref(
"browser.search.param.google_channel_us",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ ChromeUtils.defineModuleGetter(
const { ExperimentFakes } = ChromeUtils.import(
"resource://testing-common/NimbusTestUtils.jsm"
);
const { TelemetryTestUtils } = ChromeUtils.import(
"resource://testing-common/TelemetryTestUtils.jsm"
);

const PREF_DFPI_ENABLED_BY_DEFAULT =
"privacy.restrict3rdpartystorage.rollout.enabledByDefault";
Expand All @@ -32,22 +29,6 @@ const {
BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN,
} = Ci.nsICookieService;

function testTelemetryState(optIn) {
let expectedValue;
if (optIn == null) {
expectedValue = 2;
} else {
expectedValue = optIn ? 1 : 0;
}

TelemetryTestUtils.assertScalar(
TelemetryTestUtils.getProcessScalars("parent"),
"privacy.dfpi_rollout_enabledByDefault",
expectedValue,
"Scalar should have correct value"
);
}

/**
* Waits for preference to be set and asserts the value.
* @param {string} pref - Preference key.
Expand Down Expand Up @@ -87,10 +68,6 @@ async function testRolloutUI({
JSON.stringify({ dFPIEnabledByDefault, rolloutUIEnabled })
);

// Initially the rollout pref is not set. Telemetry should record this unset
// state.
testTelemetryState(null);

// Setting to standard category explicitly, since changing the default cookie
// behavior still switches us to custom initially.
let set = [[CAT_PREF, "standard"]];
Expand All @@ -102,9 +79,6 @@ async function testRolloutUI({
}
await SpecialPowers.pushPrefEnv({ set });

// At this point the pref can only be enabled or unset.
testTelemetryState(dFPIEnabledByDefault || null);

const uiEnabled =
rolloutUIEnabled ||
rolloutUIEnabledByExperiment ||
Expand Down Expand Up @@ -208,11 +182,11 @@ async function testRolloutUI({
"standard",
"Should still be in standard category"
);

ok(
BrowserTestUtils.is_visible(reloadWarning),
"Reload warning should be visible."
);
testTelemetryState(true);
}

// Un-check checkbox and assert pref state.
Expand All @@ -234,11 +208,11 @@ async function testRolloutUI({
"standard",
"Should still be in standard category"
);

ok(
BrowserTestUtils.is_visible(reloadWarning),
"Reload warning should be visible."
);
testTelemetryState(false);
}

let categoryPrefChange = waitForAndAssertPrefState(CAT_PREF, "strict");
Expand Down Expand Up @@ -272,8 +246,6 @@ async function testRolloutUI({
Services.prefs.setStringPref(CAT_PREF, "standard");
Services.prefs.clearUserPref(PREF_DFPI_ENABLED_BY_DEFAULT);
Services.prefs.clearUserPref(PREF_DFPI_ROLLOUT_UI_ENABLED);

testTelemetryState(null);
}

// Clients which are not part of the rollout. They should not see the
Expand Down
18 changes: 0 additions & 18 deletions toolkit/components/telemetry/Scalars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1372,24 +1372,6 @@ contentblocking:
record_in_processes:
- main

privacy:
dfpi_rollout_enabledByDefault:
bug_numbers:
- 1740232
description: >
Records if a client is opted into dFPI in standard ETP mode as part of the
rollout experiment. 0: opted out, 1: opted in, 2: not part of the
experiment
expires: 101
kind: uint
notification_emails:
- [email protected]
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main

datasanitization:
network_cookie_lifetimePolicy:
bug_numbers:
Expand Down

0 comments on commit e3cab91

Please sign in to comment.