From ff881bdb6795e0f307b93919f98f454bedde4bb6 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 1 Nov 2019 21:55:13 +0100 Subject: #1261 - Update status bar component for the removal of Object.(un)watch This fixes the regression from #1257 by adding in an Object.prototype.watch() shim, based on Eli Grey's polyfill. This resolves #1261. --- .../palemoon/components/statusbar/Status.jsm | 66 +++++++++++++++++----- 1 file changed, 51 insertions(+), 15 deletions(-) (limited to 'application/palemoon/components') diff --git a/application/palemoon/components/statusbar/Status.jsm b/application/palemoon/components/statusbar/Status.jsm index 19e12ddfd..dbdd1fc49 100644 --- a/application/palemoon/components/statusbar/Status.jsm +++ b/application/palemoon/components/statusbar/Status.jsm @@ -120,6 +120,57 @@ S4EStatusService.prototype = }, buildBinding: function() { + + // Object.prototype.watch() shim, based on Eli Grey's polyfill + // object.watch + if (!this._window.XULBrowserWindow.watch) { + Object.defineProperty(this._window.XULBrowserWindow, "watch", { + enumerable: false, + configurable: true, + writable: false, + value: function (prop, handler) { + var oldval = this[prop], + newval = oldval, + getter = function () { + return newval; + }, + setter = function (val) { + oldval = newval; + return newval = handler.call(this, prop, oldval, val); + } + ; + + try { + if (delete this[prop]) { // can't watch constants + Object.defineProperty(this, prop, { + get: getter, + set: setter, + enumerable: true, + configurable: true + }); + } + } catch(e) { + // This fails fatally on non-configurable props, so just + // ignore errors if it does. + } + } + }); + } + + // object.unwatch + if (!this._window.XULBrowserWindow.unwatch) { + Object.defineProperty(this._window.XULBrowserWindow, "unwatch", { + enumerable: false, + configurable: true, + writable: false, + value: function (prop) { + var val = this[prop]; + delete this[prop]; // remove accessors + this[prop] = val; + } + }); + } + let XULBWPropHandler = function(prop, oldval, newval) { CU.reportError("Attempt to modify XULBrowserWindow." + prop); return oldval; @@ -139,21 +190,6 @@ S4EStatusService.prototype = this._window.XULBrowserWindow[prop] = this[prop].bind(this); this._window.XULBrowserWindow.watch(prop, XULBWPropHandler); }, this); - - let XULBWHandler = function(prop, oldval, newval) { - if(!newval) - { - return newval; - } - CU.reportError("XULBrowserWindow changed. Updating S4E bindings."); - this._window.setTimeout(function(self) - { - self.buildBinding(); - }, 0, this); - return newval; - }; - - this._window.watch("XULBrowserWindow", XULBWHandler); }, destroy: function() -- cgit v1.2.3 From effff24825e50bd525892375e18cdaeb627f5855 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 14 Nov 2019 12:26:32 +0100 Subject: Issue #1289 - Part 4: Update Pale Moon UI. This swaps the UI choice to using the new boolean pref instead of enforcement level. --- application/palemoon/components/nsBrowserGlue.js | 7 +++++- .../palemoon/components/preferences/security.js | 27 ---------------------- .../palemoon/components/preferences/security.xul | 8 +++---- 3 files changed, 10 insertions(+), 32 deletions(-) (limited to 'application/palemoon/components') diff --git a/application/palemoon/components/nsBrowserGlue.js b/application/palemoon/components/nsBrowserGlue.js index 01a133833..31a8bf40c 100644 --- a/application/palemoon/components/nsBrowserGlue.js +++ b/application/palemoon/components/nsBrowserGlue.js @@ -1198,7 +1198,7 @@ BrowserGlue.prototype = { }, _migrateUI: function BG__migrateUI() { - const UI_VERSION = 19; + const UI_VERSION = 20; const BROWSER_DOCURL = "chrome://browser/content/browser.xul#"; let currentUIVersion = 0; try { @@ -1433,6 +1433,11 @@ BrowserGlue.prototype = { } #endif + if (currentUIVersion < 20) { + // HPKP change of UI preference; reset enforcement level + Services.prefs.clearUserPref("security.cert_pinning.enforcement_level"); + } + // Update the migration version. Services.prefs.setIntPref("browser.migration.version", UI_VERSION); }, diff --git a/application/palemoon/components/preferences/security.js b/application/palemoon/components/preferences/security.js index 9d5f302a2..54fab68ac 100644 --- a/application/palemoon/components/preferences/security.js +++ b/application/palemoon/components/preferences/security.js @@ -18,7 +18,6 @@ var gSecurityPane = { { this._pane = document.getElementById("paneSecurity"); this._initMasterPasswordUI(); - this._initHPKPUI(); }, // ADD-ONS @@ -233,31 +232,5 @@ var gSecurityPane = { document.documentElement.openWindow("Toolkit:PasswordManager", "chrome://passwordmgr/content/passwordManager.xul", "", null); - }, - - _initHPKPUI: function() { - let checkbox = document.getElementById("enableHPKP"); - let HPKPpref = document.getElementById("security.cert_pinning.enforcement_level"); - - if (HPKPpref.value == 0) { - checkbox.checked = false; - } else { - checkbox.checked = true; - } - }, - - /** - * Updates the HPKP enforcement level to the proper value depending on checkbox - * state. - */ - updateHPKPPref: function() { - let checkbox = document.getElementById("enableHPKP"); - let HPKPpref = document.getElementById("security.cert_pinning.enforcement_level"); - - if (checkbox.checked) { - HPKPpref.value = 2; - } else { - HPKPpref.value = 0; - } } }; diff --git a/application/palemoon/components/preferences/security.xul b/application/palemoon/components/preferences/security.xul index bc1625275..9aa3f7a8a 100644 --- a/application/palemoon/components/preferences/security.xul +++ b/application/palemoon/components/preferences/security.xul @@ -46,9 +46,9 @@ - + @@ -150,7 +150,7 @@ + preference="security.cert_pinning.hpkp.enabled"/> -- cgit v1.2.3