Backed out changeset af2c13b9fdb7 (bug 1801244) per developer request.

This commit is contained in:
Ryan VanderMeulen 2022-12-05 16:38:55 -05:00
Родитель b1b63ca8f0
Коммит d0bb184374
8 изменённых файлов: 78 добавлений и 501 удалений

Просмотреть файл

@ -10,8 +10,6 @@
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
@ -939,33 +937,19 @@ class Preferences {
//
// Prefs not listed here for any scenario keep their values set in
// firefox.js.
let isBeta;
if (typeof this._test_isBeta == "boolean") {
isBeta = this._test_isBeta;
} else {
isBeta =
AppConstants.MOZ_UPDATE_CHANNEL == "beta" ||
AppConstants.isReleaseCandidateOnBeta;
}
return {
history: {
"quicksuggest.enabled": false,
},
offline: {
"quicksuggest.enabled": true,
// Merino (`quicksuggest.dataCollection.enabled`) is opt out on Beta in
// the offline scenario.
"quicksuggest.dataCollection.enabled": isBeta,
"quicksuggest.dataCollection.enabled": false,
"quicksuggest.shouldShowOnboardingDialog": false,
"suggest.quicksuggest.nonsponsored": true,
"suggest.quicksuggest.sponsored": true,
},
online: {
"quicksuggest.enabled": true,
// The whole point of the online scenario is to prompt users to opt in
// to Merino, so it's disabled by default for online.
"quicksuggest.dataCollection.enabled": false,
"quicksuggest.shouldShowOnboardingDialog": true,
"suggest.quicksuggest.nonsponsored": true,

Просмотреть файл

@ -8,8 +8,6 @@ const {
PartnerLinkAttribution,
} = ChromeUtils.import("resource:///modules/PartnerLinkAttribution.jsm");
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
@ -43,12 +41,6 @@ XPCOMUtils.defineLazyGetter(lazy, "UrlbarTestUtils", () => {
return module;
});
// The default value of `quicksuggest.dataCollection.enabled` in the offline
// scenario.
const DATA_COLLECTION_OFFLINE =
AppConstants.MOZ_UPDATE_CHANNEL == "beta" ||
AppConstants.isReleaseCandidateOnBeta;
const DEFAULT_CONFIG = {
best_match: {
blocked_suggestion_ids: [],
@ -62,7 +54,7 @@ const DEFAULT_PING_PAYLOADS = {
block_id: 1,
context_id: () => actual => !!actual,
iab_category: "22 - Shopping",
improve_suggest_experience_checked: DATA_COLLECTION_OFFLINE,
improve_suggest_experience_checked: false,
match_type: "firefox-suggest",
request_id: null,
},
@ -70,7 +62,7 @@ const DEFAULT_PING_PAYLOADS = {
advertiser: "testadvertiser",
block_id: 1,
context_id: () => actual => !!actual,
improve_suggest_experience_checked: DATA_COLLECTION_OFFLINE,
improve_suggest_experience_checked: false,
match_type: "firefox-suggest",
reporting_url: "http://example.com/click",
request_id: null,
@ -79,7 +71,7 @@ const DEFAULT_PING_PAYLOADS = {
advertiser: "testadvertiser",
block_id: 1,
context_id: () => actual => !!actual,
improve_suggest_experience_checked: DATA_COLLECTION_OFFLINE,
improve_suggest_experience_checked: false,
is_clicked: false,
match_type: "firefox-suggest",
reporting_url: "http://example.com/impression",
@ -136,21 +128,6 @@ export class QuickSuggestTestUtils {
Services.telemetry.clearScalars();
}
/**
* @returns {boolean}
* The default value of the `quicksuggest.dataCollection.enabled` pref in
* the offline scenario. This is the pref whose value is sent in the
* contextual services pings as `improve_suggest_experience_checked`.
*/
get DATA_COLLECTION_OFFLINE() {
return DATA_COLLECTION_OFFLINE;
}
/**
* @returns {object}
* The default quick suggest configuration object as stored in remote
* settings.
*/
get DEFAULT_CONFIG() {
// Return a clone so callers can modify it.
return Cu.cloneInto(DEFAULT_CONFIG, this);

Просмотреть файл

@ -16,8 +16,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
sinon: "resource://testing-common/Sinon.jsm",
});
const { DATA_COLLECTION_OFFLINE } = QuickSuggestTestUtils;
// We use this pref in enterprise preference policy tests. We specifically use a
// pref that's sticky and exposed in the UI to make sure it can be set properly.
const POLICY_PREF = "suggest.quicksuggest.nonsponsored";
@ -181,7 +179,7 @@ add_task(async function test_scenario_offline() {
// prefs
"quicksuggest.scenario": "offline",
"quicksuggest.enabled": true,
"quicksuggest.dataCollection.enabled": DATA_COLLECTION_OFFLINE,
"quicksuggest.dataCollection.enabled": false,
"quicksuggest.shouldShowOnboardingDialog": false,
"suggest.quicksuggest.nonsponsored": true,
"suggest.quicksuggest.sponsored": true,
@ -198,7 +196,7 @@ add_task(async function test_scenario_offline() {
},
{
name: "browser.urlbar.quicksuggest.dataCollection.enabled",
value: DATA_COLLECTION_OFFLINE,
value: false,
},
{
name: "browser.urlbar.quicksuggest.shouldShowOnboardingDialog",
@ -216,58 +214,6 @@ add_task(async function test_scenario_offline() {
});
});
add_task(async function test_scenario_offline_forceBeta() {
for (let isBeta of [false, true]) {
info("Forcing beta: " + isBeta);
UrlbarPrefs._test_isBeta = isBeta;
await doBasicScenarioTest(
"offline",
{
urlbarPrefs: {
// prefs
"quicksuggest.scenario": "offline",
"quicksuggest.enabled": true,
"quicksuggest.dataCollection.enabled": isBeta,
"quicksuggest.shouldShowOnboardingDialog": false,
"suggest.quicksuggest.nonsponsored": true,
"suggest.quicksuggest.sponsored": true,
// Nimbus variables
quickSuggestScenario: "offline",
quickSuggestEnabled: true,
quickSuggestShouldShowOnboardingDialog: false,
},
defaults: [
{
name: "browser.urlbar.quicksuggest.enabled",
value: true,
},
{
name: "browser.urlbar.quicksuggest.dataCollection.enabled",
value: isBeta,
},
{
name: "browser.urlbar.quicksuggest.shouldShowOnboardingDialog",
value: false,
},
{
name: "browser.urlbar.suggest.quicksuggest.nonsponsored",
value: true,
},
{
name: "browser.urlbar.suggest.quicksuggest.sponsored",
value: true,
},
],
},
isBeta
);
}
delete UrlbarPrefs._test_isBeta;
});
add_task(async function test_scenario_history() {
await doBasicScenarioTest("history", {
urlbarPrefs: {
@ -288,11 +234,7 @@ add_task(async function test_scenario_history() {
});
});
async function doBasicScenarioTest(
scenario,
expectedPrefs,
dataCollectionOffline = DATA_COLLECTION_OFFLINE
) {
async function doBasicScenarioTest(scenario, expectedPrefs) {
await QuickSuggestTestUtils.withExperiment({
valueOverrides: {
quickSuggestScenario: scenario,
@ -315,7 +257,7 @@ async function doBasicScenarioTest(
"updatingFirefoxSuggestPrefs is false"
);
assertDefaultScenarioPrefs(dataCollectionOffline);
assertDefaultScenarioPrefs();
}
function assertScenarioPrefs({ urlbarPrefs, defaults }) {
@ -333,12 +275,12 @@ function assertScenarioPrefs({ urlbarPrefs, defaults }) {
}
}
function assertDefaultScenarioPrefs(dataCollectionOffline) {
function assertDefaultScenarioPrefs() {
assertScenarioPrefs({
urlbarPrefs: {
"quicksuggest.scenario": "offline",
"quicksuggest.enabled": true,
"quicksuggest.dataCollection.enabled": dataCollectionOffline,
"quicksuggest.dataCollection.enabled": false,
"quicksuggest.shouldShowOnboardingDialog": false,
"suggest.quicksuggest.nonsponsored": true,
"suggest.quicksuggest.sponsored": true,
@ -353,7 +295,7 @@ function assertDefaultScenarioPrefs(dataCollectionOffline) {
},
{
name: "browser.urlbar.quicksuggest.dataCollection.enabled",
value: dataCollectionOffline,
value: false,
},
{
name: "browser.urlbar.quicksuggest.shouldShowOnboardingDialog",
@ -451,7 +393,7 @@ add_task(async function() {
// The following tasks test OFFLINE TO OFFLINE
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * User did not override any defaults
//
// Enrollment:
@ -474,10 +416,10 @@ add_task(async function() {
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * Non-sponsored suggestions: user left on
// * Sponsored suggestions: user turned off
// * Data collection: user didn't modify
// * Data collection: user left off
//
// Enrollment:
// * Offline
@ -485,7 +427,7 @@ add_task(async function() {
// Expected:
// * Non-sponsored suggestions: remain on
// * Sponsored suggestions: remain off
// * Data collection: remains DATA_COLLECTION_OFFLINE
// * Data collection: remains off
add_task(async function() {
await checkEnrollments({
initialPrefsToSet: {
@ -507,10 +449,10 @@ add_task(async function() {
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * Non-sponsored suggestions: user turned off
// * Sponsored suggestions: user left on
// * Data collection: user didn't modify
// * Data collection: user left off
//
// Enrollment:
// * Offline
@ -518,7 +460,7 @@ add_task(async function() {
// Expected:
// * Non-sponsored suggestions: remain off
// * Sponsored suggestions: remain on
// * Data collection: remains DATA_COLLECTION_OFFLINE
// * Data collection: remains off
add_task(async function() {
await checkEnrollments({
initialPrefsToSet: {
@ -540,10 +482,10 @@ add_task(async function() {
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * Non-sponsored suggestions: user turned off
// * Sponsored suggestions: user turned off
// * Data collection: user didn't modify
// * Data collection: user left off
//
// Enrollment:
// * Offline
@ -551,7 +493,7 @@ add_task(async function() {
// Expected:
// * Non-sponsored suggestions: remain off
// * Sponsored suggestions: remain off
// * Data collection: remains DATA_COLLECTION_OFFLINE
// * Data collection: remains off
add_task(async function() {
await checkEnrollments({
initialPrefsToSet: {
@ -575,7 +517,7 @@ add_task(async function() {
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * Non-sponsored suggestions: user left on
// * Sponsored suggestions: user left on
// * Data collection: user turned on
@ -608,40 +550,7 @@ add_task(async function() {
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Non-sponsored suggestions: user left on
// * Sponsored suggestions: user left on
// * Data collection: user turned off
//
// Enrollment:
// * Offline
//
// Expected:
// * Non-sponsored suggestions: remain on
// * Sponsored suggestions: remain on
// * Data collection: remains off
add_task(async function() {
await checkEnrollments({
initialPrefsToSet: {
defaultBranch: UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.offline,
userBranch: {
"quicksuggest.dataCollection.enabled": false,
},
},
valueOverrides: {
quickSuggestScenario: "offline",
},
expectedPrefs: {
defaultBranch: UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.offline,
userBranch: {
"quicksuggest.dataCollection.enabled": false,
},
},
});
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * Non-sponsored suggestions: user turned off
// * Sponsored suggestions: user turned off
// * Data collection: user turned on
@ -677,47 +586,10 @@ add_task(async function() {
});
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Non-sponsored suggestions: user turned off
// * Sponsored suggestions: user turned off
// * Data collection: user turned off
//
// Enrollment:
// * Offline
//
// Expected:
// * Non-sponsored suggestions: remain off
// * Sponsored suggestions: remain off
// * Data collection: remains off
add_task(async function() {
await checkEnrollments({
initialPrefsToSet: {
defaultBranch: UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.offline,
userBranch: {
"suggest.quicksuggest.nonsponsored": false,
"suggest.quicksuggest.sponsored": false,
"quicksuggest.dataCollection.enabled": false,
},
},
valueOverrides: {
quickSuggestScenario: "offline",
},
expectedPrefs: {
defaultBranch: UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.offline,
userBranch: {
"suggest.quicksuggest.nonsponsored": false,
"suggest.quicksuggest.sponsored": false,
"quicksuggest.dataCollection.enabled": false,
},
},
});
});
// The following tasks test OFFLINE TO ONLINE
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * User did not override any defaults
//
// Enrollment:
@ -740,10 +612,10 @@ add_task(async function() {
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * Non-sponsored suggestions: user left on
// * Sponsored suggestions: user turned off
// * Data collection: user didn't modify
// * Data collection: user left off
//
// Enrollment:
// * Online
@ -751,7 +623,7 @@ add_task(async function() {
// Expected:
// * Non-sponsored suggestions: remain on
// * Sponsored suggestions: remain off
// * Data collection: off
// * Data collection: remains off
add_task(async function() {
await checkEnrollments({
initialPrefsToSet: {
@ -773,10 +645,10 @@ add_task(async function() {
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * Non-sponsored suggestions: user turned off
// * Sponsored suggestions: user left on
// * Data collection: user didn't modify
// * Data collection: user left off
//
// Enrollment:
// * Online
@ -784,7 +656,7 @@ add_task(async function() {
// Expected:
// * Non-sponsored suggestions: remain off
// * Sponsored suggestions: remain on
// * Data collection: off
// * Data collection: remains off
add_task(async function() {
await checkEnrollments({
initialPrefsToSet: {
@ -806,10 +678,10 @@ add_task(async function() {
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * Non-sponsored suggestions: user turned off
// * Sponsored suggestions: user turned off
// * Data collection: user didn't modify
// * Data collection: user left off
//
// Enrollment:
// * Online
@ -817,7 +689,7 @@ add_task(async function() {
// Expected:
// * Non-sponsored suggestions: remain off
// * Sponsored suggestions: remain off
// * Data collection: off
// * Data collection: remains off
add_task(async function() {
await checkEnrollments({
initialPrefsToSet: {
@ -841,7 +713,7 @@ add_task(async function() {
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * Non-sponsored suggestions: user left on
// * Sponsored suggestions: user left on
// * Data collection: user turned on
@ -874,40 +746,7 @@ add_task(async function() {
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Non-sponsored suggestions: user left on
// * Sponsored suggestions: user left on
// * Data collection: user turned off
//
// Enrollment:
// * Online
//
// Expected:
// * Non-sponsored suggestions: remain on
// * Sponsored suggestions: remain on
// * Data collection: remains off
add_task(async function() {
await checkEnrollments({
initialPrefsToSet: {
defaultBranch: UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.offline,
userBranch: {
"quicksuggest.dataCollection.enabled": false,
},
},
valueOverrides: {
quickSuggestScenario: "online",
},
expectedPrefs: {
defaultBranch: UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.online,
userBranch: {
"quicksuggest.dataCollection.enabled": false,
},
},
});
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * Non-sponsored suggestions: user left on
// * Sponsored suggestions: user turned off
// * Data collection: user turned on
@ -942,42 +781,7 @@ add_task(async function() {
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Non-sponsored suggestions: user left on
// * Sponsored suggestions: user turned off
// * Data collection: user turned off
//
// Enrollment:
// * Online
//
// Expected:
// * Non-sponsored suggestions: remain on
// * Sponsored suggestions: remain off
// * Data collection: remains off
add_task(async function() {
await checkEnrollments({
initialPrefsToSet: {
defaultBranch: UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.offline,
userBranch: {
"suggest.quicksuggest.sponsored": false,
"quicksuggest.dataCollection.enabled": false,
},
},
valueOverrides: {
quickSuggestScenario: "online",
},
expectedPrefs: {
defaultBranch: UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.online,
userBranch: {
"suggest.quicksuggest.sponsored": false,
"quicksuggest.dataCollection.enabled": false,
},
},
});
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * Non-sponsored suggestions: user turned off
// * Sponsored suggestions: user left on
// * Data collection: user turned on
@ -1012,25 +816,26 @@ add_task(async function() {
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * Non-sponsored suggestions: user turned off
// * Sponsored suggestions: user left on
// * Data collection: user turned off
// * Sponsored suggestions: user turned off
// * Data collection: user turned on
//
// Enrollment:
// * Online
//
// Expected:
// * Non-sponsored suggestions: remain off
// * Sponsored suggestions: remain on
// * Data collection: remains off
// * Sponsored suggestions: remain off
// * Data collection: remains on
add_task(async function() {
await checkEnrollments({
initialPrefsToSet: {
defaultBranch: UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.offline,
userBranch: {
"suggest.quicksuggest.nonsponsored": false,
"quicksuggest.dataCollection.enabled": false,
"suggest.quicksuggest.sponsored": false,
"quicksuggest.dataCollection.enabled": true,
},
},
valueOverrides: {
@ -1040,7 +845,8 @@ add_task(async function() {
defaultBranch: UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.online,
userBranch: {
"suggest.quicksuggest.nonsponsored": false,
"quicksuggest.dataCollection.enabled": false,
"suggest.quicksuggest.sponsored": false,
"quicksuggest.dataCollection.enabled": true,
},
},
});
@ -1316,7 +1122,7 @@ add_task(async function() {
// variables
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * User did not override any defaults
//
// Enrollment:
@ -1344,7 +1150,7 @@ add_task(async function() {
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * Sponsored suggestions: user turned off
//
// Enrollment:
@ -1378,7 +1184,7 @@ add_task(async function() {
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Offline (suggestions on and data collection off by default)
// * User did not override any defaults
//
// Enrollment:
@ -1406,36 +1212,9 @@ add_task(async function() {
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * User did not override any defaults
//
// Enrollment:
// * Offline
// * Data collection individually forced off
//
// Expected:
// * Data collection: off
add_task(async function() {
await checkEnrollments({
initialPrefsToSet: {
defaultBranch: UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.offline,
},
valueOverrides: {
quickSuggestScenario: "offline",
quickSuggestDataCollectionEnabled: false,
},
expectedPrefs: {
defaultBranch: {
...UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.offline,
"quicksuggest.dataCollection.enabled": false,
},
},
});
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Data collection: user turned off
// * Offline (suggestions on and data collection off by default)
// * Data collection: user turned off (it's off by default, so this simulates
// when the user toggled it on and then back off)
//
// Enrollment:
// * Offline
@ -1467,108 +1246,6 @@ add_task(async function() {
});
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Data collection: user turned off
//
// Enrollment:
// * Offline
// * Data collection individually forced off
//
// Expected:
// * Data collection: remains off
add_task(async function() {
await checkEnrollments({
initialPrefsToSet: {
defaultBranch: UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.offline,
userBranch: {
"quicksuggest.dataCollection.enabled": false,
},
},
valueOverrides: {
quickSuggestScenario: "offline",
quickSuggestDataCollectionEnabled: false,
},
expectedPrefs: {
defaultBranch: {
...UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.offline,
"quicksuggest.dataCollection.enabled": false,
},
userBranch: {
"quicksuggest.dataCollection.enabled": false,
},
},
});
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Data collection: user turned on
//
// Enrollment:
// * Offline
// * Data collection individually forced on
//
// Expected:
// * Data collection: remains on
add_task(async function() {
await checkEnrollments({
initialPrefsToSet: {
defaultBranch: UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.offline,
userBranch: {
"quicksuggest.dataCollection.enabled": true,
},
},
valueOverrides: {
quickSuggestScenario: "offline",
quickSuggestDataCollectionEnabled: true,
},
expectedPrefs: {
defaultBranch: {
...UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.offline,
"quicksuggest.dataCollection.enabled": true,
},
userBranch: {
"quicksuggest.dataCollection.enabled": true,
},
},
});
});
// Initial state:
// * Offline (suggestions on, data collection per DATA_COLLECTION_OFFLINE)
// * Data collection: user turned on
//
// Enrollment:
// * Offline
// * Data collection individually forced off
//
// Expected:
// * Data collection: remains on
add_task(async function() {
await checkEnrollments({
initialPrefsToSet: {
defaultBranch: UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.offline,
userBranch: {
"quicksuggest.dataCollection.enabled": true,
},
},
valueOverrides: {
quickSuggestScenario: "offline",
quickSuggestDataCollectionEnabled: false,
},
expectedPrefs: {
defaultBranch: {
...UrlbarPrefs.FIREFOX_SUGGEST_DEFAULT_PREFS.offline,
"quicksuggest.dataCollection.enabled": false,
},
userBranch: {
"quicksuggest.dataCollection.enabled": true,
},
},
});
});
// Initial state:
// * Online (suggestions on and data collection off by default)
// * User did not override any defaults

Просмотреть файл

@ -90,7 +90,7 @@ function add_suggestions_task(fn) {
// Tests the following:
// * impression telemetry
// * offline scenario
// * data collection disabled by user
// * data collection disabled
add_suggestions_task(async function impression_offline_dataCollectionDisabled(
suggestion
) {
@ -105,7 +105,7 @@ add_suggestions_task(async function impression_offline_dataCollectionDisabled(
// Tests the following:
// * impression telemetry
// * offline scenario
// * data collection enabled by user
// * data collection enabled
add_suggestions_task(async function impression_offline_dataCollectionEnabled(
suggestion
) {
@ -120,7 +120,7 @@ add_suggestions_task(async function impression_offline_dataCollectionEnabled(
// Tests the following:
// * impression telemetry
// * online scenario
// * data collection disabled by user
// * data collection disabled
add_suggestions_task(async function impression_online_dataCollectionDisabled(
suggestion
) {
@ -137,7 +137,7 @@ add_suggestions_task(async function impression_online_dataCollectionDisabled(
// Tests the following:
// * impression telemetry
// * online scenario
// * data collection enabled by user
// * data collection enabled
add_suggestions_task(async function impression_online_dataCollectionEnabled(
suggestion
) {
@ -158,8 +158,7 @@ add_suggestions_task(async function impression_bestMatch(suggestion) {
UrlbarPrefs.set("bestMatch.enabled", true);
await doImpressionTest({
suggestion,
improve_suggest_experience_checked:
QuickSuggestTestUtils.DATA_COLLECTION_OFFLINE,
improve_suggest_experience_checked: false,
isBestMatch: true,
});
UrlbarPrefs.clear("bestMatch.enabled");
@ -293,7 +292,7 @@ add_task(async function noImpression_noQuickSuggestResult() {
// Tests the following:
// * click telemetry using keyboard
// * offline scenario
// * data collection disabled by user
// * data collection disabled
add_suggestions_task(
async function click_keyboard_offline_dataCollectionDisabled(suggestion) {
await QuickSuggestTestUtils.setScenario("offline");
@ -309,7 +308,7 @@ add_suggestions_task(
// Tests the following:
// * click telemetry using keyboard
// * offline scenario
// * data collection enabled by user
// * data collection enabled
add_suggestions_task(
async function click_keyboard_offline_dataCollectionEnabled(suggestion) {
await QuickSuggestTestUtils.setScenario("offline");
@ -325,7 +324,7 @@ add_suggestions_task(
// Tests the following:
// * click telemetry using keyboard
// * online scenario
// * data collection disabled by user
// * data collection disabled
add_suggestions_task(
async function click_keyboard_online_dataCollectionDisabled(suggestion) {
await QuickSuggestTestUtils.setScenario("online");
@ -343,7 +342,7 @@ add_suggestions_task(
// Tests the following:
// * click telemetry using keyboard
// * online scenario
// * data collection enabled by user
// * data collection enabled
add_suggestions_task(async function click_keyboard_online_dataCollectionEnabled(
suggestion
) {
@ -361,7 +360,7 @@ add_suggestions_task(async function click_keyboard_online_dataCollectionEnabled(
// Tests the following:
// * click telemetry using mouse
// * offline scenario
// * data collection disabled by user
// * data collection disabled
add_suggestions_task(async function click_mouse_offline_dataCollectionDisabled(
suggestion
) {
@ -377,7 +376,7 @@ add_suggestions_task(async function click_mouse_offline_dataCollectionDisabled(
// Tests the following:
// * click telemetry using mouse
// * offline scenario
// * data collection enabled by user
// * data collection enabled
add_suggestions_task(async function click_mouse_offline_dataCollectionEnabled(
suggestion
) {
@ -393,7 +392,7 @@ add_suggestions_task(async function click_mouse_offline_dataCollectionEnabled(
// Tests the following:
// * click telemetry using mouse
// * online scenario
// * data collection disabled by user
// * data collection disabled
add_suggestions_task(async function click_mouse_online_dataCollectionDisabled(
suggestion
) {
@ -411,7 +410,7 @@ add_suggestions_task(async function click_mouse_online_dataCollectionDisabled(
// Tests the following:
// * click telemetry using mouse
// * online scenario
// * data collection enabled by user
// * data collection enabled
add_suggestions_task(async function click_mouse_online_dataCollectionEnabled(
suggestion
) {
@ -433,8 +432,7 @@ add_suggestions_task(async function click_keyboard_bestMatch(suggestion) {
UrlbarPrefs.set("bestMatch.enabled", true);
await doClickTest({
suggestion,
improve_suggest_experience_checked:
QuickSuggestTestUtils.DATA_COLLECTION_OFFLINE,
improve_suggest_experience_checked: false,
useKeyboard: true,
isBestMatch: true,
});
@ -448,8 +446,7 @@ add_suggestions_task(async function click_mouse_bestMatch(suggestion) {
UrlbarPrefs.set("bestMatch.enabled", true);
await doClickTest({
suggestion,
improve_suggest_experience_checked:
QuickSuggestTestUtils.DATA_COLLECTION_OFFLINE,
improve_suggest_experience_checked: false,
isBestMatch: true,
});
UrlbarPrefs.clear("bestMatch.enabled");
@ -1375,8 +1372,7 @@ add_task(async function impression_previousResultStillVisible() {
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
improve_suggest_experience_checked:
QuickSuggestTestUtils.DATA_COLLECTION_OFFLINE,
improve_suggest_experience_checked: false,
block_id: firstSuggestion.id,
is_clicked: false,
match_type: "firefox-suggest",

Просмотреть файл

@ -18,8 +18,7 @@ const DEFAULT_PREFS = {
},
offline: {
"quicksuggest.enabled": true,
"quicksuggest.dataCollection.enabled":
QuickSuggestTestUtils.DATA_COLLECTION_OFFLINE,
"quicksuggest.dataCollection.enabled": false,
"quicksuggest.shouldShowOnboardingDialog": false,
"suggest.quicksuggest.nonsponsored": true,
"suggest.quicksuggest.sponsored": true,

Просмотреть файл

@ -22,13 +22,6 @@ const PREFS = [
expectedOfflineValue: true,
expectedOtherValue: false,
},
{
name: "browser.urlbar.quicksuggest.dataCollection.enabled",
get: "getBoolPref",
set: "setBoolPref",
expectedOfflineValue: QuickSuggestTestUtils.DATA_COLLECTION_OFFLINE,
expectedOtherValue: false,
},
{
name: "browser.urlbar.quicksuggest.shouldShowOnboardingDialog",
get: "getBoolPref",
@ -72,27 +65,6 @@ add_task(async function test() {
}
});
add_task(async function forceBeta() {
for (let isBeta of [true, false]) {
UrlbarPrefs._test_isBeta = isBeta;
await doTest({
locale: "en-US",
home: "US",
expectedOfflineDefault: true,
prefs: [
{
name: "browser.urlbar.quicksuggest.dataCollection.enabled",
get: "getBoolPref",
set: "setBoolPref",
expectedOfflineValue: isBeta,
expectedOtherValue: false,
},
],
});
}
delete UrlbarPrefs._test_isBeta;
});
/**
* Sets the app's locale and region, calls
* `UrlbarPrefs.updateFirefoxSuggestScenario`, and asserts that the pref values
@ -107,14 +79,10 @@ add_task(async function forceBeta() {
* @param {boolean} options.expectedOfflineDefault
* The expected value of whether offline should be enabled by default given
* the locale and region.
* @param {Array} options.prefs
* All the prefs that `updateFirefoxSuggestScenario` sets along with the
* expected default-branch values when offline is enabled and when it's not
* enabled. See `PREFS` for an example.
*/
async function doTest({ locale, home, expectedOfflineDefault, prefs = PREFS }) {
async function doTest({ locale, home, expectedOfflineDefault }) {
// Setup: Clear any user values and save original default-branch values.
for (let pref of prefs) {
for (let pref of PREFS) {
Services.prefs.clearUserPref(pref.name);
pref.originalDefault = Services.prefs
.getDefaultBranch(pref.name)
@ -122,16 +90,10 @@ async function doTest({ locale, home, expectedOfflineDefault, prefs = PREFS }) {
}
// Set the region and locale, call the function, check the pref values.
info(`Checking home region ${home} and locale ${locale}`);
Region._setHomeRegion(home, false);
await QuickSuggestTestUtils.withLocales([locale], async () => {
await UrlbarPrefs.updateFirefoxSuggestScenario();
for (let { name, get, expectedOfflineValue, expectedOtherValue } of prefs) {
info(
"Checking pref: " +
JSON.stringify({ name, expectedOfflineValue, expectedOtherValue })
);
for (let { name, get, expectedOfflineValue, expectedOtherValue } of PREFS) {
let expectedValue = expectedOfflineDefault
? expectedOfflineValue
: expectedOtherValue;
@ -146,8 +108,8 @@ async function doTest({ locale, home, expectedOfflineDefault, prefs = PREFS }) {
// For good measure, also check the return value of `UrlbarPrefs.get`
// since we use it everywhere. The value should be the same as the
// default-branch value.
Assert.strictEqual(
UrlbarPrefs.get(name.replace("browser.urlbar.", "")),
UrlbarPrefs.get(
name.replace("browser.urlbar.", ""),
expectedValue,
`UrlbarPrefs.get() value for ${name}, locale ${locale}, home ${home}`
);
@ -155,7 +117,7 @@ async function doTest({ locale, home, expectedOfflineDefault, prefs = PREFS }) {
});
// Teardown: Restore original default-branch values for the next task.
for (let { name, originalDefault, set } of prefs) {
for (let { name, originalDefault, set } of PREFS) {
if (originalDefault === undefined) {
Services.prefs.deleteBranch(name);
} else {

Просмотреть файл

@ -109,10 +109,13 @@ var TelemetryControllerBase = Object.freeze({
const isPrereleaseChannel = prereleaseChannels.includes(
AppConstants.MOZ_UPDATE_CHANNEL
);
const isReleaseCandidateOnBeta =
AppConstants.MOZ_UPDATE_CHANNEL === "release" &&
Services.prefs.getCharPref("app.update.channel", null) === "beta";
Services.telemetry.canRecordBase = true;
Services.telemetry.canRecordExtended =
isPrereleaseChannel ||
AppConstants.isReleaseCandidateOnBeta ||
isReleaseCandidateOnBeta ||
Services.prefs.getBoolPref(this.Preferences.OverridePreRelease, false);
},

Просмотреть файл

@ -33,27 +33,6 @@ export var AppConstants = Object.freeze({
false,
#endif
/**
* @returns {boolean}
* Returns whether the build is a release candidate on the Beta channel.
* For non-RC builds on the Beta channel, `MOZ_UPDATE_CHANNEL` is "beta",
* but for RC build's it's "release". See bug 1435753 for more.
*
* WARNING: Do not use this value to change Firefox behavior without a
* strong reason to do so. Any divergence in behavior between Beta and
* Release, between non-RC Beta and RC Beta, or between RC and Release puts
* us in a position where we have very limited time to test Release behavior
* before shipping it. When possible, please use the usual flags for
* preventing features from riding past pre-release such as `NIGHTLY_BUILD`
* and `EARLY_BETA_OR_EARLIER`.
*/
get isReleaseCandidateOnBeta() {
return (
AppConstants.MOZ_UPDATE_CHANNEL === "release" &&
Services.prefs.getCharPref("app.update.channel", null) === "beta"
);
},
IS_ESR:
#ifdef MOZ_ESR
true,