From 5e07a531159c940dbcd9ca221776607d48f396b9 Mon Sep 17 00:00:00 2001 From: Bogdan Tara Date: Wed, 24 Jul 2019 11:51:56 +0300 Subject: [PATCH] Backed out 2 changesets (bug 1563552) for failures on browser_privacypane_2.js and browser_sanitizeDialog.js CLOSED TREE Backed out changeset c7df8a9a00a4 (bug 1563552) Backed out changeset ce3ae99da523 (bug 1563552) --- .../preferences/in-content/sync.inc.xul | 16 ++--- .../components/preferences/in-content/sync.js | 50 +++++++++------- toolkit/content/preferencesBindings.js | 59 +++++++++++++------ 3 files changed, 76 insertions(+), 49 deletions(-) diff --git a/browser/components/preferences/in-content/sync.inc.xul b/browser/components/preferences/in-content/sync.inc.xul index aaa3a48ff22e..5d3ce6e6a8fc 100755 --- a/browser/components/preferences/in-content/sync.inc.xul +++ b/browser/components/preferences/in-content/sync.inc.xul @@ -156,23 +156,23 @@ + preference="engine.bookmarks"/> + preference="engine.history"/> + preference="engine.tabs"/> + preference="engine.passwords"/> + preference="engine.addresses"/> + preference="engine.creditcards"/> + preference="engine.addons"/> + preference="engine.prefs"/> diff --git a/browser/components/preferences/in-content/sync.js b/browser/components/preferences/in-content/sync.js index 515025471e39..08e65e789f7a 100644 --- a/browser/components/preferences/in-content/sync.js +++ b/browser/components/preferences/in-content/sync.js @@ -31,14 +31,30 @@ const FXA_LOGIN_UNVERIFIED = 1; const FXA_LOGIN_FAILED = 2; Preferences.addAll([ - { id: "services.sync.engine.addons", type: "bool" }, - { id: "services.sync.engine.bookmarks", type: "bool" }, - { id: "services.sync.engine.history", type: "bool" }, - { id: "services.sync.engine.tabs", type: "bool" }, - { id: "services.sync.engine.prefs", type: "bool" }, - { id: "services.sync.engine.passwords", type: "bool" }, - { id: "services.sync.engine.addresses", type: "bool" }, - { id: "services.sync.engine.creditcards", type: "bool" }, + { id: "engine.addons", name: "services.sync.engine.addons", type: "bool" }, + { + id: "engine.bookmarks", + name: "services.sync.engine.bookmarks", + type: "bool", + }, + { id: "engine.history", name: "services.sync.engine.history", type: "bool" }, + { id: "engine.tabs", name: "services.sync.engine.tabs", type: "bool" }, + { id: "engine.prefs", name: "services.sync.engine.prefs", type: "bool" }, + { + id: "engine.passwords", + name: "services.sync.engine.passwords", + type: "bool", + }, + { + id: "engine.addresses", + name: "services.sync.engine.addresses", + type: "bool", + }, + { + id: "engine.creditcards", + name: "services.sync.engine.creditcards", + type: "bool", + }, ]); var gSyncPane = { @@ -95,14 +111,8 @@ var gSyncPane = { // These 2 engines are unique in that there are prefs that make the // entire engine unavailable (which is distinct from "disabled"). let enginePrefs = [ - [ - "services.sync.engine.addresses.available", - "services.sync.engine.addresses", - ], - [ - "services.sync.engine.creditcards.available", - "services.sync.engine.creditcards", - ], + ["services.sync.engine.addresses.available", "engine.addresses"], + ["services.sync.engine.creditcards.available", "engine.creditcards"], ]; let numHidden = 0; for (let [availablePref, prefName] of enginePrefs) { @@ -118,12 +128,8 @@ var gSyncPane = { // the second column. (If we only moved one, it's still unbalanced, but // there's an odd number of engines so that can't be avoided) if (numHidden == 2) { - let history = document.querySelector( - '[preference="services.sync.engine.history"]' - ); - let addons = document.querySelector( - '[preference="services.sync.engine.addons"]' - ); + let history = document.querySelector('[preference="engine.history"]'); + let addons = document.querySelector('[preference="engine.addons"]'); addons.parentNode.insertBefore(history, addons); } }, diff --git a/toolkit/content/preferencesBindings.js b/toolkit/content/preferencesBindings.js index 7360bbf9ef3c..87a6229b0c0b 100644 --- a/toolkit/content/preferencesBindings.js +++ b/toolkit/content/preferencesBindings.js @@ -344,7 +344,7 @@ const Preferences = (window.Preferences = (function() { window.addEventListener("unload", Preferences, { once: true }); class Preference extends EventEmitter { - constructor({ id, type, inverted, disabled }) { + constructor({ id, name, type, inverted, disabled }) { super(); this.on("change", this.onChange.bind(this)); @@ -354,10 +354,17 @@ const Preferences = (window.Preferences = (function() { this.batching = false; this.id = id; + this._name = name || this.id; this.type = type; this.inverted = !!inverted; this._disabled = !!disabled; + // if the element has been inserted without the name attribute set, + // we have nothing to do here + if (!this.name) { + throw new Error(`preference with id '${id}' doesn't have name`); + } + // In non-instant apply mode, we must try and use the last saved state // from any previous opens of a child dialog instead of the value from // preferences, to pick up any edits a user may have made. @@ -369,7 +376,7 @@ const Preferences = (window.Preferences = (function() { window.opener.document.nodePrincipal.isSystemPrincipal ) { // Try to find the preference in the parent window. - const preference = window.opener.Preferences.get(this.id); + const preference = window.opener.Preferences.get(this.name); // Don't use the value setter here, we don't want updateElements to be // prematurely fired. @@ -385,9 +392,9 @@ const Preferences = (window.Preferences = (function() { } _reportUnknownType() { - const msg = `Preference with id=${this.id} has unknown type ${ - this.type - }.`; + const msg = `Preference with id=${this.id} and name=${ + this.name + } has unknown type ${this.type}.`; Services.console.logStringMessage(msg); } @@ -523,6 +530,20 @@ const Preferences = (window.Preferences = (function() { this.updateElements(); } + get name() { + return this._name; + } + + set name(val) { + if (val == this.name) { + return val; + } + + this._name = val; + + return val; + } + get value() { return this._value; } @@ -539,7 +560,7 @@ const Preferences = (window.Preferences = (function() { } get locked() { - return Services.prefs.prefIsLocked(this.id); + return Services.prefs.prefIsLocked(this.name); } get disabled() { @@ -568,7 +589,7 @@ const Preferences = (window.Preferences = (function() { get hasUserValue() { return ( - Services.prefs.prefHasUserValue(this.id) && this.value !== undefined + Services.prefs.prefHasUserValue(this.name) && this.value !== undefined ); } @@ -588,28 +609,28 @@ const Preferences = (window.Preferences = (function() { // Force a resync of value with preferences. switch (this.type) { case "int": - return this._branch.getIntPref(this.id); + return this._branch.getIntPref(this.name); case "bool": { - const val = this._branch.getBoolPref(this.id); + const val = this._branch.getBoolPref(this.name); return this.inverted ? !val : val; } case "wstring": return this._branch.getComplexValue( - this.id, + this.name, Ci.nsIPrefLocalizedString ).data; case "string": case "unichar": - return this._branch.getStringPref(this.id); + return this._branch.getStringPref(this.name); case "fontname": { - const family = this._branch.getStringPref(this.id); + const family = this._branch.getStringPref(this.name); const fontEnumerator = Cc[ "@mozilla.org/gfx/fontenumerator;1" ].createInstance(Ci.nsIFontEnumerator); return fontEnumerator.getStandardFamilyName(family); } case "file": { - const f = this._branch.getComplexValue(this.id, Ci.nsIFile); + const f = this._branch.getComplexValue(this.name, Ci.nsIFile); return f; } default: @@ -627,17 +648,17 @@ const Preferences = (window.Preferences = (function() { // The special value undefined means 'reset preference to default'. if (val === undefined) { - Services.prefs.clearUserPref(this.id); + Services.prefs.clearUserPref(this.name); return val; } // Force a resync of preferences with value. switch (this.type) { case "int": - Services.prefs.setIntPref(this.id, val); + Services.prefs.setIntPref(this.name, val); break; case "bool": - Services.prefs.setBoolPref(this.id, this.inverted ? !val : val); + Services.prefs.setBoolPref(this.name, this.inverted ? !val : val); break; case "wstring": { const pls = Cc["@mozilla.org/pref-localizedstring;1"].createInstance( @@ -645,7 +666,7 @@ const Preferences = (window.Preferences = (function() { ); pls.data = val; Services.prefs.setComplexValue( - this.id, + this.name, Ci.nsIPrefLocalizedString, pls ); @@ -654,7 +675,7 @@ const Preferences = (window.Preferences = (function() { case "string": case "unichar": case "fontname": - Services.prefs.setStringPref(this.id, val); + Services.prefs.setStringPref(this.name, val); break; case "file": { let lf; @@ -667,7 +688,7 @@ const Preferences = (window.Preferences = (function() { } else { lf = val.QueryInterface(Ci.nsIFile); } - Services.prefs.setComplexValue(this.id, Ci.nsIFile, lf); + Services.prefs.setComplexValue(this.name, Ci.nsIFile, lf); break; } default: