Bug 1496855 - Switch PDF policy to use pdfjs.disabled. r=Felipe
authorMichael Kaply <mozilla@kaply.com>
Wed, 10 Oct 2018 21:57:34 +0000
changeset 496367 461d609b9d2dc3c889ce68e2c7011c009c4d1fb5
parent 496366 4e4d1fe0d17ed328d5ace7f27686f2e4af480ecf
child 496368 f04a49448cf522e4157ef2468923224b79fcdb87
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFelipe
bugs1496855
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1496855 - Switch PDF policy to use pdfjs.disabled. r=Felipe pdfjs.disabled now works from policy, so use it Differential Revision: https://phabricator.services.mozilla.com/D8237
browser/components/enterprisepolicies/Policies.jsm
browser/components/enterprisepolicies/tests/browser/browser.ini
browser/components/enterprisepolicies/tests/browser/browser_policies_simple_pref_policies.js
browser/components/enterprisepolicies/tests/browser/browser_policy_disable_pdfjs.js
browser/components/preferences/in-content/main.js
browser/extensions/pdfjs/content/PdfJs.jsm
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -222,19 +222,19 @@ var Policies = {
     onBeforeAddons(manager, param) {
       if (param) {
         manager.disallowFeature("appUpdate");
       }
     },
   },
 
   "DisableBuiltinPDFViewer": {
-    onBeforeUIStartup(manager, param) {
+    onBeforeAddons(manager, param) {
       if (param) {
-        manager.disallowFeature("PDF.js");
+        setAndLockPref("pdfjs.disabled", true);
       }
     },
   },
 
   "DisableDeveloperTools": {
     onBeforeAddons(manager, param) {
       if (param) {
         setAndLockPref("devtools.policy.disabled", true);
--- a/browser/components/enterprisepolicies/tests/browser/browser.ini
+++ b/browser/components/enterprisepolicies/tests/browser/browser.ini
@@ -32,17 +32,16 @@ support-files =
 [browser_policy_clear_blocked_cookies.js]
 [browser_policy_cookie_settings.js]
 [browser_policy_default_browser_check.js]
 [browser_policy_disable_feedback_commands.js]
 [browser_policy_disable_flash_plugin.js]
 [browser_policy_disable_fxaccounts.js]
 skip-if = (verify && debug && (os == 'mac'))
 [browser_policy_disable_masterpassword.js]
-[browser_policy_disable_pdfjs.js]
 [browser_policy_disable_pocket.js]
 [browser_policy_disable_popup_blocker.js]
 [browser_policy_disable_privatebrowsing.js]
 [browser_policy_disable_profile_reset.js]
 [browser_policy_disable_profile_import.js]
 [browser_policy_disable_safemode.js]
 [browser_policy_disable_shield.js]
 [browser_policy_disable_telemetry.js]
--- a/browser/components/enterprisepolicies/tests/browser/browser_policies_simple_pref_policies.js
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policies_simple_pref_policies.js
@@ -48,16 +48,21 @@ const POLICIES_TESTS = [
       },
     },
     lockedPrefs: {
       "security.certerror.hideAddException": true,
       "browser.safebrowsing.allowOverride": false,
     },
   },
 
+  // POLICY: DisableBuiltinPDFViewer
+  {
+    policies: { "DisableBuiltinPDFViewer": true },
+    lockedPrefs: { "pdfjs.disabled": true },
+  },
 
   // POLICY: DisableFormHistory
   {
     policies: { "DisableFormHistory": true },
     lockedPrefs: { "browser.formfill.enable": false },
   },
 
   // POLICY: EnableTrackingProtection
deleted file mode 100644
--- a/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_pdfjs.js
+++ /dev/null
@@ -1,17 +0,0 @@
-/* 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");
-});
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -3243,12 +3243,11 @@ class PDFHandlerInfoWrapper extends Inte
     return TOPIC_PDFJS_HANDLER_CHANGED;
   }
 
   get _appPrefLabel() {
     return "portableDocumentFormat";
   }
 
   get enabled() {
-    return !Services.prefs.getBoolPref(PREF_PDFJS_DISABLED) &&
-           Services.policies.isAllowed("PDF.js");
+    return !Services.prefs.getBoolPref(PREF_PDFJS_DISABLED);
   }
 }
--- a/browser/extensions/pdfjs/content/PdfJs.jsm
+++ b/browser/extensions/pdfjs/content/PdfJs.jsm
@@ -263,20 +263,16 @@ var PdfJs = {
   },
 
   /**
    * pdf.js is only enabled if it is both selected as the pdf viewer and if the
    * global switch enabling it is true.
    * @return {boolean} Whether or not it's enabled.
    */
   get enabled() {
-    if (!Services.policies.isAllowed("PDF.js")) {
-      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
       // PdfJs
       if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_POSTUPDATE)) {
         this.checkEnabled();
       }