зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1440574 - Policy: Disable commands to send feedback. r=felipe
This commit is contained in:
Родитель
335cdd19e4
Коммит
ac057aaa2d
|
@ -23,21 +23,16 @@ var gSafeBrowsing = {
|
|||
document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu")
|
||||
.hidden = !isPhishingPage;
|
||||
|
||||
var broadcasterId = isPhishingPage
|
||||
? "reportPhishingErrorBroadcaster"
|
||||
: "reportPhishingBroadcaster";
|
||||
|
||||
var broadcaster = document.getElementById(broadcasterId);
|
||||
if (!broadcaster)
|
||||
return;
|
||||
|
||||
// Now look at the currentURI to learn which page we were trying
|
||||
// to browse to.
|
||||
let uri = gBrowser.currentURI;
|
||||
if (uri && (uri.schemeIs("http") || uri.schemeIs("https")))
|
||||
broadcaster.removeAttribute("disabled");
|
||||
else
|
||||
broadcaster.setAttribute("disabled", true);
|
||||
const uri = gBrowser.currentURI;
|
||||
const isReportablePage = uri && (uri.schemeIs("http") || uri.schemeIs("https"));
|
||||
|
||||
const disabledByPolicy = !Services.policies.isAllowed("feedbackCommands");
|
||||
document.getElementById("reportPhishingBroadcaster")
|
||||
.disabled = disabledByPolicy || isPhishingPage || !isReportablePage;
|
||||
document.getElementById("reportPhishingErrorBroadcaster")
|
||||
.disabled = disabledByPolicy || !isPhishingPage || !isReportablePage;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -829,6 +829,9 @@ function openTourPage() {
|
|||
}
|
||||
|
||||
function buildHelpMenu() {
|
||||
document.getElementById("feedbackPage")
|
||||
.disabled = !Services.policies.isAllowed("feedbackCommands");
|
||||
|
||||
// Enable/disable the "Report Web Forgery" menu item.
|
||||
if (typeof gSafeBrowsing != "undefined") {
|
||||
gSafeBrowsing.setReportPhishingMenu();
|
||||
|
|
|
@ -149,6 +149,14 @@ var Policies = {
|
|||
}
|
||||
},
|
||||
|
||||
"DisableFeedbackCommands": {
|
||||
onBeforeUIStartup(manager, param) {
|
||||
if (param) {
|
||||
manager.disallowFeature("feedbackCommands");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"DisableFirefoxAccounts": {
|
||||
onBeforeAddons(manager, param) {
|
||||
if (param) {
|
||||
|
|
|
@ -114,6 +114,13 @@
|
|||
"type": "boolean"
|
||||
},
|
||||
|
||||
"DisableFeedbackCommands": {
|
||||
"description": "Prevents ability to send feedback from the help menu (\"Submit Feedback\" and \"Report Deceptive Site\").",
|
||||
"first_available": "60.0",
|
||||
|
||||
"type": "boolean"
|
||||
},
|
||||
|
||||
"DisableFirefoxAccounts": {
|
||||
"description": "Disables Firefox Account based services, including Sync.",
|
||||
"first_available": "60.0",
|
||||
|
|
|
@ -24,6 +24,7 @@ support-files =
|
|||
[browser_policy_bookmarks.js]
|
||||
[browser_policy_clear_blocked_cookies.js]
|
||||
[browser_policy_default_browser_check.js]
|
||||
[browser_policy_disable_feedback_commands.js]
|
||||
[browser_policy_disable_formhistory.js]
|
||||
[browser_policy_disable_fxaccounts.js]
|
||||
[browser_policy_disable_fxscreenshots.js]
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* the buidHelpMenu() function comes from browser/base/content/utilityOverlay.js */
|
||||
|
||||
const NORMAL_PAGE = "http://example.com";
|
||||
const PHISH_PAGE = "http://www.itisatrap.org/firefox/its-a-trap.html";
|
||||
|
||||
async function checkItemsAreDisabled(url) {
|
||||
await BrowserTestUtils.withNewTab({
|
||||
gBrowser,
|
||||
url,
|
||||
// The phishing page doesn't send a load notification
|
||||
waitForLoad: false,
|
||||
waitForStateStop: true,
|
||||
}, async function checkItems() {
|
||||
buildHelpMenu();
|
||||
|
||||
let reportMenu = document.getElementById("menu_HelpPopup_reportPhishingtoolmenu");
|
||||
is(reportMenu.getAttribute("disabled"), "true",
|
||||
"The `Report Deceptive Site` item should be disabled");
|
||||
|
||||
let errorMenu = document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu");
|
||||
is(errorMenu.getAttribute("disabled"), "true",
|
||||
"The `This isn’t a deceptive site` item should be disabled");
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function test_policy_feedback_commands() {
|
||||
await setupPolicyEngineWithJson({
|
||||
"policies": {
|
||||
"DisableFeedbackCommands": true
|
||||
}
|
||||
});
|
||||
|
||||
/* from browser/base/content/utilityOverlay.js */
|
||||
buildHelpMenu();
|
||||
|
||||
let feedbackPageMenu = document.getElementById("feedbackPage");
|
||||
is(feedbackPageMenu.getAttribute("disabled"), "true",
|
||||
"The `Submit Feedback...` item should be disabled");
|
||||
|
||||
await checkItemsAreDisabled(NORMAL_PAGE);
|
||||
await checkItemsAreDisabled(PHISH_PAGE);
|
||||
|
||||
});
|
||||
|
Загрузка…
Ссылка в новой задаче