From 3ac9bd063d7b169834ba3edf2723992cfa557d2e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 18 Sep 2014 01:14:00 +0200 Subject: [PATCH 1/4] Fix setPreferences regression from the e10s patch (PR 5115) --- extensions/firefox/content/PdfjsChromeUtils.jsm | 8 ++++++-- make.js | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/extensions/firefox/content/PdfjsChromeUtils.jsm b/extensions/firefox/content/PdfjsChromeUtils.jsm index 89e995b3a..8b3efe11f 100644 --- a/extensions/firefox/content/PdfjsChromeUtils.jsm +++ b/extensions/firefox/content/PdfjsChromeUtils.jsm @@ -1,3 +1,5 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +25,7 @@ const Ci = Components.interfaces; const Cr = Components.results; const Cu = Components.utils; -const PREF_PREFIX = 'pdfjs'; +const PREF_PREFIX = 'PDFJSSCRIPT_PREF_PREFIX'; const PDF_CONTENT_TYPE = 'application/pdf'; Cu.import('resource://gre/modules/XPCOMUtils.jsm'); @@ -176,7 +178,9 @@ let PdfjsChromeUtils = { }, _isPrefAllowed: function (aPrefName) { - if (this._allowedPrefNames.indexOf(aPrefName) == -1) { + let unPrefixedName = aPrefName.split(PREF_PREFIX + '.'); + if (unPrefixedName[0] !== '' || + this._allowedPrefNames.indexOf(unPrefixedName[1]) === -1) { let msg = "'" + aPrefName + "' "; msg += "can't be accessed from content. See PdfjsChromeUtils." throw new Error(msg); diff --git a/make.js b/make.js index 7ab11f765..f7789da8a 100644 --- a/make.js +++ b/make.js @@ -680,6 +680,8 @@ target.firefox = function() { FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm'); sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'false', FIREFOX_BUILD_CONTENT_DIR + 'PdfStreamConverter.jsm'); + sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, FIREFOX_PREF_PREFIX, + FIREFOX_BUILD_CONTENT_DIR + 'PdfjsChromeUtils.jsm'); // Update localized metadata var localizedMetadata = cat(EXTENSION_SRC_DIR + '/firefox/metadata.inc'); @@ -808,6 +810,8 @@ target.mozcentral = function() { MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm'); sed('-i', /PDFJSSCRIPT_MOZ_CENTRAL/, 'true', MOZCENTRAL_CONTENT_DIR + 'PdfStreamConverter.jsm'); + sed('-i', /PDFJSSCRIPT_PREF_PREFIX/, MOZCENTRAL_PREF_PREFIX, + MOZCENTRAL_CONTENT_DIR + 'PdfjsChromeUtils.jsm'); // Copy test files mkdir('-p', MOZCENTRAL_TEST_DIR); From c00951e3e47ec5be2b5943e18eaccb46ab592b73 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 18 Sep 2014 01:16:09 +0200 Subject: [PATCH 2/4] Add back pdfBugEnabled pref check in the |log| function in extensions/firefox/content/PdfStreamConverter.jsm --- extensions/firefox/content/PdfStreamConverter.jsm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extensions/firefox/content/PdfStreamConverter.jsm b/extensions/firefox/content/PdfStreamConverter.jsm index 1c2bb5257..e714c841e 100644 --- a/extensions/firefox/content/PdfStreamConverter.jsm +++ b/extensions/firefox/content/PdfStreamConverter.jsm @@ -114,6 +114,9 @@ function getStringPref(pref, def) { } function log(aMsg) { + if (!getBoolPref(PREF_PREFIX + '.pdfBugEnabled', false)) { + return; + } var msg = 'PdfStreamConverter.js: ' + (aMsg.join ? aMsg.join('') : aMsg); Services.console.logStringMessage(msg); dump(msg + '\n'); From dbe756c406a15dd05c1b451ecced762d703ba02c Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 18 Sep 2014 01:19:32 +0200 Subject: [PATCH 3/4] Update the license header in extensions/firefox/content/pdfjschildbootstrap.js; see https://bugzilla.mozilla.org/show_bug.cgi?id=942707#c99 --- .../firefox/content/pdfjschildbootstrap.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/extensions/firefox/content/pdfjschildbootstrap.js b/extensions/firefox/content/pdfjschildbootstrap.js index 8e5a48aa4..c9758b3e5 100644 --- a/extensions/firefox/content/pdfjschildbootstrap.js +++ b/extensions/firefox/content/pdfjschildbootstrap.js @@ -1,6 +1,19 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +/* Copyright 2014 Mozilla Foundation +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ /* jshint esnext:true */ /* globals Components, PdfjsContentUtils, PdfJs */ From 8d27f38c64cd4fe2d0e36970426152b82eca5f10 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 18 Sep 2014 15:06:34 +0200 Subject: [PATCH 4/4] Rename |_isPrefAllowed| to |_ensurePreferenceAllowed| in extensions/firefox/content/PdfjsChromeUtils.jsm --- extensions/firefox/content/PdfjsChromeUtils.jsm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/extensions/firefox/content/PdfjsChromeUtils.jsm b/extensions/firefox/content/PdfjsChromeUtils.jsm index 8b3efe11f..8b28ce45d 100644 --- a/extensions/firefox/content/PdfjsChromeUtils.jsm +++ b/extensions/firefox/content/PdfjsChromeUtils.jsm @@ -177,7 +177,7 @@ let PdfjsChromeUtils = { return true; }, - _isPrefAllowed: function (aPrefName) { + _ensurePreferenceAllowed: function (aPrefName) { let unPrefixedName = aPrefName.split(PREF_PREFIX + '.'); if (unPrefixedName[0] !== '' || this._allowedPrefNames.indexOf(unPrefixedName[1]) === -1) { @@ -188,27 +188,27 @@ let PdfjsChromeUtils = { }, _clearUserPref: function (aPrefName) { - this._isPrefAllowed(aPrefName); + this._ensurePreferenceAllowed(aPrefName); Services.prefs.clearUserPref(aPrefName); }, _setIntPref: function (aPrefName, aPrefValue) { - this._isPrefAllowed(aPrefName); + this._ensurePreferenceAllowed(aPrefName); Services.prefs.setIntPref(aPrefName, aPrefValue); }, _setBoolPref: function (aPrefName, aPrefValue) { - this._isPrefAllowed(aPrefName); + this._ensurePreferenceAllowed(aPrefName); Services.prefs.setBoolPref(aPrefName, aPrefValue); }, _setCharPref: function (aPrefName, aPrefValue) { - this._isPrefAllowed(aPrefName); + this._ensurePreferenceAllowed(aPrefName); Services.prefs.setCharPref(aPrefName, aPrefValue); }, _setStringPref: function (aPrefName, aPrefValue) { - this._isPrefAllowed(aPrefName); + this._ensurePreferenceAllowed(aPrefName); let str = Cc['@mozilla.org/supports-string;1'] .createInstance(Ci.nsISupportsString); str.data = aPrefValue;