Bug 1548080 - Add a policy to control Firefox Home r=Mardak,flod

Differential Revision: https://phabricator.services.mozilla.com/D29396

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Michael Kaply 2019-05-02 15:40:41 +00:00
Родитель fd94f413de
Коммит 4b61694b5e
6 изменённых файлов: 111 добавлений и 0 удалений

Просмотреть файл

@ -609,6 +609,27 @@ var Policies = {
},
},
"FirefoxHome": {
onBeforeAddons(manager, param) {
let locked = param.Locked || false;
if ("Search" in param) {
setDefaultPref("browser.newtabpage.activity-stream.showSearch", param.Search, locked);
}
if ("TopSites" in param) {
setDefaultPref("browser.newtabpage.activity-stream.feeds.topsites", param.TopSites, locked);
}
if ("Highlights" in param) {
setDefaultPref("browser.newtabpage.activity-stream.feeds.section.highlights", param.Highlights, locked);
}
if ("Pocket" in param) {
setDefaultPref("browser.newtabpage.activity-stream.feeds.section.topstories", param.Pocket, locked);
}
if ("Snippets" in param) {
setDefaultPref("browser.newtabpage.activity-stream.feeds.snippets", param.Snippets, locked);
}
},
},
"FlashPlugin": {
onBeforeUIStartup(manager, param) {
addAllowDenyPermissions("plugin:flash", param.Allow, param.Block);

Просмотреть файл

@ -331,6 +331,30 @@
"type": "boolean"
},
"FirefoxHome": {
"type": "object",
"properties": {
"Search": {
"type": "boolean"
},
"TopSites": {
"type": "boolean"
},
"Highlights": {
"type": "boolean"
},
"Pocket": {
"type": "boolean"
},
"Snippets": {
"type": "boolean"
},
"Locked": {
"type": "boolean"
}
}
},
"FlashPlugin": {
"type": "object",
"properties": {

Просмотреть файл

@ -51,6 +51,7 @@ skip-if = (verify && debug && (os == 'mac'))
[browser_policy_extensions.js]
[browser_policy_extensionsettings.js]
[browser_policy_locale.js]
[browser_policy_firefoxhome.js]
[browser_policy_override_postupdatepage.js]
[browser_policy_permissions.js]
[browser_policy_proxy.js]

Просмотреть файл

@ -427,6 +427,21 @@ const POLICIES_TESTS = [
"browser.urlbar.suggest.searches": false,
},
},
// POLICY: FirefoxHome
{
policies: {
"FirefoxHome": {
"Pocket": false,
"Snippets": false,
"Locked": true,
},
},
lockedPrefs: {
"browser.newtabpage.activity-stream.feeds.snippets": false,
"browser.newtabpage.activity-stream.feeds.section.topstories": false,
},
},
];
add_task(async function test_policy_simple_prefs() {

Просмотреть файл

@ -0,0 +1,48 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function test_firefox_home_without_policy_without_pocket() {
let tab = await BrowserTestUtils.openNewForegroundTab({gBrowser,
opening: "about:home",
waitForStateStop: true});
await ContentTask.spawn(tab.linkedBrowser, {}, function() {
let search = content.document.querySelector(".search-wrapper");
isnot(search, null, "Search section should be there.");
let topsites = content.document.querySelector("section[data-section-id='topsites']");
isnot(topsites, null, "Top Sites section should be there.");
let highlights = content.document.querySelector("section[data-section-id='highlights']");
isnot(highlights, null, "Highlights section should be there.");
});
BrowserTestUtils.removeTab(tab);
await SpecialPowers.popPrefEnv();
});
add_task(async function test_firefox_home_with_policy() {
await setupPolicyEngineWithJson({
"policies": {
"FirefoxHome": {
"Search": false,
"TopSites": false,
"Highlights": false,
"Snippets": false,
},
},
});
let tab = await BrowserTestUtils.openNewForegroundTab({gBrowser,
opening: "about:home",
waitForStateStop: true});
await ContentTask.spawn(tab.linkedBrowser, {}, function() {
let search = content.document.querySelector(".search-wrapper");
is(search, null, "Search section should not be there.");
let topsites = content.document.querySelector("section[data-section-id='topsites']");
is(topsites, null, "Top Sites section should not be there.");
let highlights = content.document.querySelector("section[data-section-id='highlights']");
is(highlights, null, "Highlights section should not be there.");
});
BrowserTestUtils.removeTab(tab);
});

Просмотреть файл

@ -88,6 +88,8 @@ policy-Extensions = Install, uninstall or lock extensions. The Install option ta
policy-ExtensionUpdate = Enable or disable automatic extension updates.
policy-FirefoxHome = Configure Firefox Home.
policy-FlashPlugin = Allow or deny usage of the Flash plugin.
policy-HardwareAcceleration = If false, turn off hardware acceleration.