Skip to content

Commit 8f71edf

Browse files
Bug 1972647 - Hide Firefox Labs opt-ins from about:studies r=nimbus-reviewers,relud
We do not want users to confuse these opt-ins with regular studies, especially when studies are disabled, as that may lead them to believe that we are running studies without their consent. Differential Revision: https://phabricator.services.mozilla.com/D269918
1 parent a3c91c5 commit 8f71edf

2 files changed

Lines changed: 57 additions & 5 deletions

File tree

‎toolkit/components/normandy/content/AboutPages.sys.mjs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ ChromeUtils.defineLazyGetter(AboutPages, "aboutStudies", () => {
101101
},
102102

103103
getMessagingSystemList() {
104-
return lazy.ExperimentAPI.manager.store.getAll();
104+
// Do not include Firefox Labs. Those are shown on
105+
// about:preferences#experimental.
106+
return lazy.ExperimentAPI.manager.store
107+
.getAll()
108+
.filter(e => !e.isFirefoxLabsOptIn);
105109
},
106110

107111
async optInToExperiment(data) {
@@ -220,7 +224,7 @@ ChromeUtils.defineLazyGetter(AboutPages, "aboutStudies", () => {
220224
);
221225
this._sendToAll(
222226
"Shield:UpdateMessagingSystemExperimentList",
223-
lazy.ExperimentAPI.manager.store.getAll()
227+
this.getMessagingSystemList()
224228
);
225229
},
226230

‎toolkit/components/normandy/test/browser/browser_about_studies.js‎

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ const { NimbusTestUtils } = ChromeUtils.importESModule(
1212
const { ExperimentAPI } = ChromeUtils.importESModule(
1313
"resource://nimbus/ExperimentAPI.sys.mjs"
1414
);
15-
const { RemoteSettingsExperimentLoader } = ChromeUtils.importESModule(
16-
"resource://nimbus/lib/RemoteSettingsExperimentLoader.sys.mjs"
15+
const { FirefoxLabs } = ChromeUtils.importESModule(
16+
"resource://nimbus/FirefoxLabs.sys.mjs"
1717
);
1818

1919
const { NormandyTestUtils } = ChromeUtils.importESModule(
@@ -866,7 +866,7 @@ add_task(async function test_forceEnroll() {
866866
}
867867
);
868868

869-
NimbusTestUtils.assert.storeIsEmpty(ExperimentAPI.manager.store);
869+
await NimbusTestUtils.assert.storeIsEmpty(ExperimentAPI.manager.store);
870870
sandbox.restore();
871871
});
872872

@@ -956,3 +956,51 @@ add_task(async function test_inactive_rollouts_under_completed_studies() {
956956
// Cleanup for multiple test runs
957957
await NimbusTestUtils.assert.storeIsEmpty(ExperimentAPI.manager.store);
958958
});
959+
960+
add_task(async function testFirefoxLabs() {
961+
const study = NimbusTestUtils.factories.recipe("study");
962+
await ExperimentAPI.manager.enroll(study, "rs-loader");
963+
964+
const optin = NimbusTestUtils.factories.recipe("optin", {
965+
isRollout: true,
966+
isFirefoxLabsOptIn: true,
967+
firefoxLabsTitle: "title",
968+
firefoxLabsDescription: "description",
969+
firefoxLabsGroup: "group",
970+
requiresRestart: false,
971+
});
972+
973+
ExperimentAPI.manager.optInRecipes.push(optin);
974+
975+
const labs = await FirefoxLabs.create();
976+
await labs.enroll("optin", "control");
977+
978+
await BrowserTestUtils.withNewTab(
979+
{ gBrowser, url: "about:studies" },
980+
async browser => {
981+
const nimbusItems = await SpecialPowers.spawn(browser, [], async () => {
982+
await ContentTaskUtils.waitForCondition(
983+
() => content.document.querySelector(".nimbus .remove-button"),
984+
"waiting for page to load"
985+
);
986+
987+
return Array.from(
988+
content.document.querySelectorAll(".nimbus"),
989+
el => el.dataset.studySlug
990+
);
991+
});
992+
993+
Assert.deepEqual(
994+
nimbusItems,
995+
["study"],
996+
"Firefox Labs opt-in not present"
997+
);
998+
}
999+
);
1000+
1001+
await labs.unenroll("optin", "control");
1002+
await ExperimentAPI.manager.unenroll("study");
1003+
ExperimentAPI.manager.optInRecipes.pop();
1004+
1005+
await NimbusTestUtils.assert.storeIsEmpty(ExperimentAPI.manager.store);
1006+
});

0 commit comments

Comments
 (0)