зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1498940 - Reflect study opt-out in about:studies when Normandy is generally enabled. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D9738 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
968a7a4996
Коммит
e74056eacb
|
@ -15,6 +15,7 @@ ChromeUtils.defineModuleGetter(this, "RecipeRunner", "resource://normandy/lib/Re
|
||||||
var EXPORTED_SYMBOLS = ["AboutPages"];
|
var EXPORTED_SYMBOLS = ["AboutPages"];
|
||||||
|
|
||||||
const SHIELD_LEARN_MORE_URL_PREF = "app.normandy.shieldLearnMoreUrl";
|
const SHIELD_LEARN_MORE_URL_PREF = "app.normandy.shieldLearnMoreUrl";
|
||||||
|
XPCOMUtils.defineLazyPreferenceGetter(this, "gOptOutStudiesEnabled", "app.shield.optoutstudies.enabled");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,10 +193,9 @@ XPCOMUtils.defineLazyGetter(this.AboutPages, "aboutStudies", () => {
|
||||||
*/
|
*/
|
||||||
sendStudiesEnabled(target) {
|
sendStudiesEnabled(target) {
|
||||||
RecipeRunner.checkPrefs();
|
RecipeRunner.checkPrefs();
|
||||||
|
const studiesEnabled = RecipeRunner.enabled && gOptOutStudiesEnabled;
|
||||||
try {
|
try {
|
||||||
target.messageManager.sendAsyncMessage("Shield:ReceiveStudiesEnabled", {
|
target.messageManager.sendAsyncMessage("Shield:ReceiveStudiesEnabled", { studiesEnabled });
|
||||||
studiesEnabled: RecipeRunner.enabled,
|
|
||||||
});
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// The child process might be gone, so no need to throw here.
|
// The child process might be gone, so no need to throw here.
|
||||||
Cu.reportError(err);
|
Cu.reportError(err);
|
||||||
|
@ -237,11 +237,6 @@ XPCOMUtils.defineLazyGetter(this.AboutPages, "aboutStudies", () => {
|
||||||
getShieldLearnMoreHref() {
|
getShieldLearnMoreHref() {
|
||||||
return Services.urlFormatter.formatURLPref(SHIELD_LEARN_MORE_URL_PREF);
|
return Services.urlFormatter.formatURLPref(SHIELD_LEARN_MORE_URL_PREF);
|
||||||
},
|
},
|
||||||
|
|
||||||
getStudiesEnabled() {
|
|
||||||
RecipeRunner.checkPrefs();
|
|
||||||
return RecipeRunner.enabled;
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return aboutStudies;
|
return aboutStudies;
|
||||||
|
|
|
@ -158,7 +158,12 @@ var RecipeRunner = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiUrl = Services.prefs.getCharPref(API_URL_PREF);
|
const apiUrl = Services.prefs.getCharPref(API_URL_PREF);
|
||||||
if (!apiUrl || !apiUrl.startsWith("https://")) {
|
if (!apiUrl) {
|
||||||
|
log.warn(`Disabling Shield because ${API_URL_PREF} is not set.`);
|
||||||
|
this.disable();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!apiUrl.startsWith("https://")) {
|
||||||
log.warn(`Disabling Shield because ${API_URL_PREF} is not an HTTPS url: ${apiUrl}.`);
|
log.warn(`Disabling Shield because ${API_URL_PREF} is not an HTTPS url: ${apiUrl}.`);
|
||||||
this.disable();
|
this.disable();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -237,7 +237,7 @@ decorate_task(
|
||||||
decorate_task(
|
decorate_task(
|
||||||
AddonStudies.withStudies([]),
|
AddonStudies.withStudies([]),
|
||||||
withAboutStudies,
|
withAboutStudies,
|
||||||
async function testStudyListing(studies, browser) {
|
async function testStudyListingNoStudies(studies, browser) {
|
||||||
await ContentTask.spawn(browser, null, async () => {
|
await ContentTask.spawn(browser, null, async () => {
|
||||||
const doc = content.document;
|
const doc = content.document;
|
||||||
await ContentTaskUtils.waitForCondition(() => doc.querySelectorAll(".study-list-info").length);
|
await ContentTaskUtils.waitForCondition(() => doc.querySelectorAll(".study-list-info").length);
|
||||||
|
@ -255,7 +255,22 @@ decorate_task(
|
||||||
// Test that the message shown when studies are disabled and studies exist
|
// Test that the message shown when studies are disabled and studies exist
|
||||||
decorate_task(
|
decorate_task(
|
||||||
withAboutStudies,
|
withAboutStudies,
|
||||||
async function testStudyListing(browser) {
|
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) {
|
||||||
try {
|
try {
|
||||||
RecipeRunner.disable();
|
RecipeRunner.disable();
|
||||||
|
|
||||||
|
@ -276,3 +291,34 @@ decorate_task(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 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",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче