diff --git a/toolkit/components/normandy/content/AboutPages.jsm b/toolkit/components/normandy/content/AboutPages.jsm index 406a6cc34d6d..ac9236181e64 100644 --- a/toolkit/components/normandy/content/AboutPages.jsm +++ b/toolkit/components/normandy/content/AboutPages.jsm @@ -15,7 +15,6 @@ ChromeUtils.defineModuleGetter(this, "RecipeRunner", "resource://normandy/lib/Re var EXPORTED_SYMBOLS = ["AboutPages"]; const SHIELD_LEARN_MORE_URL_PREF = "app.normandy.shieldLearnMoreUrl"; -XPCOMUtils.defineLazyPreferenceGetter(this, "gOptOutStudiesEnabled", "app.shield.optoutstudies.enabled"); /** @@ -193,9 +192,10 @@ XPCOMUtils.defineLazyGetter(this.AboutPages, "aboutStudies", () => { */ sendStudiesEnabled(target) { RecipeRunner.checkPrefs(); - const studiesEnabled = RecipeRunner.enabled && gOptOutStudiesEnabled; try { - target.messageManager.sendAsyncMessage("Shield:ReceiveStudiesEnabled", { studiesEnabled }); + target.messageManager.sendAsyncMessage("Shield:ReceiveStudiesEnabled", { + studiesEnabled: RecipeRunner.enabled, + }); } catch (err) { // The child process might be gone, so no need to throw here. Cu.reportError(err); @@ -237,6 +237,11 @@ XPCOMUtils.defineLazyGetter(this.AboutPages, "aboutStudies", () => { getShieldLearnMoreHref() { return Services.urlFormatter.formatURLPref(SHIELD_LEARN_MORE_URL_PREF); }, + + getStudiesEnabled() { + RecipeRunner.checkPrefs(); + return RecipeRunner.enabled; + }, }); return aboutStudies; diff --git a/toolkit/components/normandy/content/about-studies/about-studies.js b/toolkit/components/normandy/content/about-studies/about-studies.js index a23c02949171..8ff2d0247b9f 100644 --- a/toolkit/components/normandy/content/about-studies/about-studies.js +++ b/toolkit/components/normandy/content/about-studies/about-studies.js @@ -150,7 +150,7 @@ class StudyList extends React.Component { return ( r("div", {}, r("h2", {}, translations.activeStudiesList), - r("ul", { className: "study-list active-study-list" }, + r("ul", { className: "study-list" }, activeStudies.map(study => ( study.type === "addon" ? r(AddonStudyListItem, { key: study.name, study, translations }) @@ -158,7 +158,7 @@ class StudyList extends React.Component { )), ), r("h2", {}, translations.completedStudiesList), - r("ul", { className: "study-list inactive-study-list" }, + r("ul", { className: "study-list" }, inactiveStudies.map(study => ( study.type === "addon" ? r(AddonStudyListItem, { key: study.name, study, translations }) diff --git a/toolkit/components/normandy/lib/RecipeRunner.jsm b/toolkit/components/normandy/lib/RecipeRunner.jsm index 7fda26999c48..72adf4d0e2c9 100644 --- a/toolkit/components/normandy/lib/RecipeRunner.jsm +++ b/toolkit/components/normandy/lib/RecipeRunner.jsm @@ -158,12 +158,7 @@ var RecipeRunner = { } const apiUrl = Services.prefs.getCharPref(API_URL_PREF); - if (!apiUrl) { - log.warn(`Disabling Shield because ${API_URL_PREF} is not set.`); - this.disable(); - return; - } - if (!apiUrl.startsWith("https://")) { + if (!apiUrl || !apiUrl.startsWith("https://")) { log.warn(`Disabling Shield because ${API_URL_PREF} is not an HTTPS url: ${apiUrl}.`); this.disable(); return; diff --git a/toolkit/components/normandy/test/browser/browser_about_studies.js b/toolkit/components/normandy/test/browser/browser_about_studies.js index 39463dd6d12a..8cc86a908e26 100644 --- a/toolkit/components/normandy/test/browser/browser_about_studies.js +++ b/toolkit/components/normandy/test/browser/browser_about_studies.js @@ -71,7 +71,6 @@ decorate_task( } ); -// Test that the study listing shows studies in the proper order and grouping decorate_task( AddonStudies.withStudies([ addonStudyFactory({ @@ -200,19 +199,19 @@ decorate_task( activeAddonStudy.querySelector(".remove-button").click(); await ContentTaskUtils.waitForCondition(() => ( - getStudyRow(doc, addonStudies[0].name).matches(".study.disabled") + getStudyRow(doc, addonStudies[0].name).matches(".study--disabled") )); ok( - getStudyRow(doc, addonStudies[0].name).matches(".study.disabled"), + getStudyRow(doc, addonStudies[0].name).matches(".study--disabled"), "Clicking the remove button updates the UI to show that the study has been disabled." ); activePrefStudy.querySelector(".remove-button").click(); await ContentTaskUtils.waitForCondition(() => ( - getStudyRow(doc, prefStudies[0].name).matches(".study.disabled") + getStudyRow(doc, prefStudies[0].name).matches(".study--disabled") )); ok( - getStudyRow(doc, prefStudies[0].name).matches(".study.disabled"), + getStudyRow(doc, prefStudies[0].name).matches(".study--disabled"), "Clicking the remove button updates the UI to show that the study has been disabled." ); }); @@ -231,11 +230,10 @@ decorate_task( } ); -// Test that a message is shown when no studies have been run decorate_task( AddonStudies.withStudies([]), withAboutStudies, - async function testStudyListingNoStudies(studies, browser) { + async function testStudyListing(studies, browser) { await ContentTask.spawn(browser, null, async () => { const doc = content.document; await ContentTaskUtils.waitForCondition(() => doc.querySelectorAll(".study-list-info").length); @@ -250,25 +248,9 @@ decorate_task( } ); -// Test that the message shown when studies are disabled and studies exist decorate_task( withAboutStudies, - AddonStudies.withStudies([ - addonStudyFactory({ - name: "A Fake Add-on Study", - active: false, - description: "A fake description", - studyStartDate: new Date(2018, 0, 4), - }), - ]), - PreferenceExperiments.withMockExperiments([ - preferenceStudyFactory({ - name: "B Fake Preference Study", - lastSeen: new Date(2018, 0, 5), - expired: true, - }), - ]), - async function testStudyListingDisabled(browser, addonStudies, preferenceStudies) { + async function testStudyListing(browser) { try { RecipeRunner.disable(); @@ -287,36 +269,4 @@ decorate_task( RecipeRunner.checkPrefs(); } } -); - -// Test for bug 1498940 - detects studies disabled when only study opt-out is set -decorate_task( - withPrefEnv({ - set: [ - ["datareporting.healthreport.uploadEnabled", true], - ["app.normandy.api_url", "https://example.com"], - ["app.shield.optoutstudies.enabled", false], - ], - }), - withAboutStudies, - AddonStudies.withStudies([]), - PreferenceExperiments.withMockExperiments([]), - async function testStudyListingStudiesOptOut(browser) { - RecipeRunner.checkPrefs(); - ok( - RecipeRunner.enabled, - "RecipeRunner should be enabled as a Precondition", - ); - - await ContentTask.spawn(browser, null, async () => { - const doc = content.document; - await ContentTaskUtils.waitForCondition(() => doc.querySelector(".info-box-content > span").textContent); - - is( - doc.querySelector(".info-box-content > span").textContent, - "This is a list of studies that you have participated in. No new studies will run.", - "A message is shown when studies are disabled", - ); - }); - } -); +).only();