Backed out 2 changesets (bug 1501877, bug 1498940) for failing browser_about_studies.js CLOSED TREE

Backed out changeset f0ed99b29aaf (bug 1498940)
Backed out changeset ae8cdf156f9a (bug 1501877)
This commit is contained in:
Ciure Andrei 2018-10-25 21:24:45 +03:00
parent 100c41163d
commit 2c53ceb546
4 changed files with 18 additions and 68 deletions

View File

@ -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;

View File

@ -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 })

View File

@ -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;

View File

@ -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();