Bug 1429160 - Create enterprise policy to disable PDFjs r=dthayer,Felipe

MozReview-Commit-ID: 4Ir407Qjdoq

--HG--
extra : rebase_source : 3108b7b0a9b4121bbc39ee561542584894143b6f
This commit is contained in:
Kirk Steuber 2018-03-07 13:17:07 -08:00
Родитель 7b82a59655
Коммит c690d6f97d
5 изменённых файлов: 37 добавлений и 0 удалений

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

@ -181,6 +181,14 @@ var Policies = {
}
},
"DisableBuiltinPDFViewer": {
onBeforeUIStartup(manager, param) {
if (param) {
manager.disallowFeature("PDFjs");
}
}
},
"DisablePocket": {
onBeforeAddons(manager, param) {
if (param) {

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

@ -142,6 +142,13 @@
"type": "boolean"
},
"DisableBuiltinPDFViewer": {
"description": "Disables PDF.js, which displays PDFs within Firefox.",
"first_available": "60.0",
"type": "boolean"
},
"DisablePocket": {
"description": "Prevents ability to save webpages to Pocket.",
"first_available": "60.0",

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

@ -28,6 +28,7 @@ support-files =
[browser_policy_disable_fxaccounts.js]
[browser_policy_disable_fxscreenshots.js]
[browser_policy_disable_masterpassword.js]
[browser_policy_disable_pdfjs.js]
[browser_policy_disable_pocket.js]
[browser_policy_disable_privatebrowsing.js]
[browser_policy_disable_shield.js]

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

@ -0,0 +1,17 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const {PdfJs} = ChromeUtils.import("resource://pdf.js/PdfJs.jsm", {});
add_task(async function test_disable_pdfjs() {
is(PdfJs.enabled, true, "PDFjs should be enabled before policy runs");
await setupPolicyEngineWithJson({
"policies": {
"DisableBuiltinPDFViewer": true
}
});
is(PdfJs.enabled, false, "PDFjs should be disabled after policy runs");
});

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

@ -337,6 +337,10 @@ var PdfJs = {
* @return {boolean} Whether or not it's enabled.
*/
get enabled() {
if (Services.policies && !Services.policies.isAllowed("PDFjs")) {
return false;
}
if (!Services.prefs.getBoolPref(PREF_ENABLED_CACHE_INITIALIZED, false)) {
// If we just updated, and the cache hasn't been initialized, then we
// can't assume a default state, and need to synchronously initialize