gecko-dev/browser/components/preferences/tests/browser_privacy_firefoxSuggest.js
Drew Willcoxon 46c9fc2d6b Bug 1949297 - Update the Firefox Suggest settings UI. r=settings-reviewers,reusable-components-reviewers,urlbar-reviewers,fluent-reviewers,bolsson,daisuke,mstriemer
This makes the following primary changes to the Suggest settings in the search
pane:

* Remove the infobox
* Remove the learn-more link from the dismissed-suggestions description
* Add a learn-more link to the Address Bar section's description but show it
  only when Suggest is enabled
* Add `#w_what-setting-is-opt-in` fragment to the learn-more URL for the online
  toggle so it links directly to the appropriate section

It also makes these related changes:

Remove the unnecessary `vbox` containers for the toggle switches. I had to
modify some reusable-components CSS. Note that there are two copies of the
Suggest toggle, one in the search pane and one in the privacy pane.

Rename the sponsored and nonsponsored checkbox strings so they're consistent
with the other checkbox strings: `addressbar-locbar-foo-option`

Remove test tasks that click checkboxes and make sure the appropriate prefs are
updated and vice versa. Now that the infobox is gone, there's no need for
Suggest-specific tests to worry about that.

Similarly, remove test tasks that click the learn-more links and make sure the
right page is opened. No need for Suggest-specific tests to do that either.

Differential Revision: https://phabricator.services.mozilla.com/D238847
2025-02-26 15:49:16 +00:00

181 lines
5.5 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// This tests the Privacy pane's Firefox Suggest UI.
"use strict";
ChromeUtils.defineESModuleGetters(this, {
QuickSuggest: "resource:///modules/QuickSuggest.sys.mjs",
});
const DATA_COLLECTION_TOGGLE_ID = "firefoxSuggestDataCollectionPrivacyToggle";
// Maps `SETTINGS_UI` values to expected visibility state objects. See
// `assertSuggestVisibility()` in `head.js` for info on the state objects.
const EXPECTED = {
[QuickSuggest.SETTINGS_UI.FULL]: {
[DATA_COLLECTION_TOGGLE_ID]: { isVisible: true },
},
[QuickSuggest.SETTINGS_UI.NONE]: {
[DATA_COLLECTION_TOGGLE_ID]: { isVisible: false },
},
[QuickSuggest.SETTINGS_UI.OFFLINE_ONLY]: {
[DATA_COLLECTION_TOGGLE_ID]: { isVisible: false },
},
};
// This test can take a while due to the many permutations some of these tasks
// run through, so request a longer timeout.
requestLongerTimeout(10);
// The following tasks check the initial visibility of the Firefox Suggest UI
// and the visibility after installing a Nimbus experiment.
add_task(async function initiallyDisabled_disable() {
await doSuggestVisibilityTest({
pane: "privacy",
initialSuggestEnabled: false,
initialExpected: EXPECTED[QuickSuggest.SETTINGS_UI.NONE],
nimbusVariables: {
quickSuggestEnabled: false,
},
});
});
add_task(async function initiallyDisabled_disable_settingsUIFull() {
await doSuggestVisibilityTest({
pane: "privacy",
initialSuggestEnabled: false,
initialExpected: EXPECTED[QuickSuggest.SETTINGS_UI.NONE],
nimbusVariables: {
quickSuggestEnabled: false,
// `quickSuggestEnabled: false` should override this, so the Suggest
// settings should not be visible (`initialExpected` should persist).
quickSuggestSettingsUi: QuickSuggest.SETTINGS_UI.FULL,
},
});
});
add_task(async function initiallyDisabled_enable() {
await doSuggestVisibilityTest({
pane: "privacy",
initialSuggestEnabled: false,
initialExpected: EXPECTED[QuickSuggest.SETTINGS_UI.NONE],
nimbusVariables: {
quickSuggestEnabled: true,
},
newExpected: EXPECTED[QuickSuggest.SETTINGS_UI.FULL],
});
});
add_task(async function initiallyDisabled_enable_settingsUiFull() {
await doSuggestVisibilityTest({
pane: "privacy",
initialSuggestEnabled: false,
initialExpected: EXPECTED[QuickSuggest.SETTINGS_UI.NONE],
nimbusVariables: {
quickSuggestEnabled: true,
quickSuggestSettingsUi: QuickSuggest.SETTINGS_UI.FULL,
},
newExpected: EXPECTED[QuickSuggest.SETTINGS_UI.FULL],
});
});
add_task(async function initiallyDisabled_enable_settingsUiNone() {
await doSuggestVisibilityTest({
pane: "privacy",
initialSuggestEnabled: false,
initialExpected: EXPECTED[QuickSuggest.SETTINGS_UI.NONE],
nimbusVariables: {
quickSuggestEnabled: true,
quickSuggestSettingsUi: QuickSuggest.SETTINGS_UI.NONE,
},
});
});
add_task(async function initiallyDisabled_enable_settingsUiOfflineOnly() {
await doSuggestVisibilityTest({
pane: "privacy",
initialSuggestEnabled: false,
initialExpected: EXPECTED[QuickSuggest.SETTINGS_UI.NONE],
nimbusVariables: {
quickSuggestEnabled: true,
quickSuggestSettingsUi: QuickSuggest.SETTINGS_UI.OFFLINE_ONLY,
},
newExpected: EXPECTED[QuickSuggest.SETTINGS_UI.OFFLINE_ONLY],
});
});
add_task(async function initiallyEnabled_disable() {
await doSuggestVisibilityTest({
pane: "privacy",
initialSuggestEnabled: true,
initialExpected: EXPECTED[QuickSuggest.SETTINGS_UI.FULL],
nimbusVariables: {
quickSuggestEnabled: false,
},
newExpected: EXPECTED[QuickSuggest.SETTINGS_UI.NONE],
});
});
add_task(async function initiallyEnabled_disable_settingsUiFull() {
await doSuggestVisibilityTest({
pane: "privacy",
initialSuggestEnabled: true,
initialExpected: EXPECTED[QuickSuggest.SETTINGS_UI.FULL],
nimbusVariables: {
quickSuggestEnabled: false,
// `quickSuggestEnabled: false` should override this, so the Suggest
// settings should not be visible.
quickSuggestSettingsUi: QuickSuggest.SETTINGS_UI.FULL,
},
newExpected: EXPECTED[QuickSuggest.SETTINGS_UI.NONE],
});
});
add_task(async function initiallyEnabled_enable() {
await doSuggestVisibilityTest({
pane: "privacy",
initialSuggestEnabled: true,
initialExpected: EXPECTED[QuickSuggest.SETTINGS_UI.FULL],
nimbusVariables: {
quickSuggestEnabled: true,
},
});
});
add_task(async function initiallyEnabled_settingsUiFull() {
await doSuggestVisibilityTest({
pane: "privacy",
initialSuggestEnabled: true,
initialExpected: EXPECTED[QuickSuggest.SETTINGS_UI.FULL],
nimbusVariables: {
quickSuggestSettingsUi: QuickSuggest.SETTINGS_UI.FULL,
},
});
});
add_task(async function initiallyEnabled_settingsUiNone() {
await doSuggestVisibilityTest({
pane: "privacy",
initialSuggestEnabled: true,
initialExpected: EXPECTED[QuickSuggest.SETTINGS_UI.FULL],
nimbusVariables: {
quickSuggestSettingsUi: QuickSuggest.SETTINGS_UI.NONE,
},
newExpected: EXPECTED[QuickSuggest.SETTINGS_UI.NONE],
});
});
add_task(async function initiallyEnabled_settingsUiOfflineOnly() {
await doSuggestVisibilityTest({
pane: "privacy",
initialSuggestEnabled: true,
initialExpected: EXPECTED[QuickSuggest.SETTINGS_UI.FULL],
nimbusVariables: {
quickSuggestSettingsUi: QuickSuggest.SETTINGS_UI.OFFLINE_ONLY,
},
newExpected: EXPECTED[QuickSuggest.SETTINGS_UI.OFFLINE_ONLY],
});
});