Commit fac06519 authored by Kirk Steuber's avatar Kirk Steuber
Browse files

Bug 1429129 - Add enterprise policy to remove "Set As Desktop Background"...

Bug 1429129 - Add enterprise policy to remove "Set As Desktop Background" context menu option r=Felipe,Gijs

MozReview-Commit-ID: EdVKcujYUh4

--HG--
extra : rebase_source : 747a24e0181b6c9cfbfeda1ad247d118439ef766
parent 9d063bfa
......@@ -451,7 +451,8 @@ nsContextMenu.prototype = {
// and only works if we have a shell service.
var haveSetDesktopBackground = false;
if (AppConstants.HAVE_SHELL_SERVICE) {
if (AppConstants.HAVE_SHELL_SERVICE &&
Services.policies.isAllowed("set_desktop_background")) {
// Only enable Set as Desktop Background if we can get the shell service.
var shell = getShellService();
if (shell)
......@@ -1017,8 +1018,10 @@ nsContextMenu.prototype = {
mm.removeMessageListener("ContextMenu:SetAsDesktopBackground:Result",
onMessage);
if (message.data.disable)
if (message.data.disable ||
!Services.policies.isAllowed("set_desktop_background")) {
return;
}
let image = document.createElementNS("http://www.w3.org/1999/xhtml", "img");
image.src = message.data.dataUrl;
......
......@@ -76,6 +76,14 @@ this.Policies = {
}
},
"block_set_desktop_background": {
onBeforeUIStartup(manager, param) {
if (param == true) {
manager.disallowFeature("set_desktop_background", true);
}
}
},
"dont_check_default_browser": {
onBeforeUIStartup(manager, param) {
setAndLockPref("browser.shell.checkDefaultBrowser", false);
......
......@@ -26,6 +26,14 @@
"enum": [true]
},
"block_set_desktop_background": {
"description": "Prevents usage of the \"Set Image as Desktop Background\" feature.",
"first_available": "60.0",
"type": "boolean",
"enum": [true]
},
"dont_check_default_browser": {
"description": "Don't check for the default browser on startup.",
"first_available": "60.0",
......
......@@ -10,6 +10,7 @@ support-files =
config_broken_json.json
config_display_menu.json
config_display_bookmarks.json
config_block_set_desktop_background.json
[browser_policies_broken_json.js]
[browser_policies_popups_cookies_addons_flash.js]
......@@ -19,3 +20,4 @@ support-files =
[browser_policy_default_browser_check.js]
[browser_policy_display_menu.js]
[browser_policy_display_bookmarks.js]
[browser_policy_block_set_desktop_background.js]
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function setup() {
await setupPolicyEngineWithJson("config_block_set_desktop_background.json");
});
add_task(async function test_check_set_desktop_background() {
const imageUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gwMDAsTBZbkNwAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAABNElEQVQ4y8WSsU0DURBE3yyWIaAJaqAAN4DPSL6AlIACKIEOyJEgRsIgOOkiInJqgAKowNg7BHdn7MOksNl+zZ//dvbDf5cAiklp22BdVtXdeTEpDYDB9m1VzU6OJuVp2NdEQCaI96fH2YHG4+mDduKYNMYINTcjcGbXzQVDEAphG0k48zUsajIbnAiMIXThpW8EICE0RAK4dvoKg9NIcTiQ589otyHOZLnwqK5nLwBFUZ4igc3iM0d1ff8CMC6mZ6Ihiaqq3gi1aUAnArD00SW1fq5OLBg0ymYmSZsR2/t4e/rGyCLW0sbp3oq+yTYqVgytQWui2FS7XYF7GFprY921T4CNQt8zr47dNzCkIX7y/jBtH+v+RGMQrc828W8pApnZbmEVQp/Ae7BlOy2ttib81/UFc+WRWEbjckIAAAAASUVORK5CYII=";
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, imageUrl, true);
// Right click on the image and wait for the context menu to open
let contextMenu = document.getElementById("contentAreaContextMenu");
let promiseContextMenuOpen = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
await BrowserTestUtils.synthesizeMouse("img", 0, 0,
{
type: "contextmenu",
button: 2,
centered: true
},
gBrowser.selectedBrowser);
await promiseContextMenuOpen;
info("Context Menu Shown");
let buttonElement = document.getElementById("context-setDesktopBackground");
is(buttonElement.hidden, true,
"The \"Set Desktop Background\" context menu element should be hidden");
let promiseContextMenuHidden = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden");
contextMenu.hidePopup();
await promiseContextMenuHidden;
await BrowserTestUtils.removeTab(tab);
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment