Bug 1401528 - replace __defineGetter__ on top-level objects in chat. r=florian
--- a/chat/components/src/imContacts.js
+++ b/chat/components/src/imContacts.js
@@ -91,37 +91,42 @@ function getDBConnection()
return conn;
}
// Wrap all the usage of DBConn inside a transaction that will be
// commited automatically at the end of the event loop spin so that
// we flush buddy list data to disk only once per event loop spin.
var gDBConnWithPendingTransaction = null;
-this.__defineGetter__("DBConn", function() {
- if (gDBConnWithPendingTransaction)
- return gDBConnWithPendingTransaction;
+Object.defineProperty(this, "DBConn", {
+ configurable: true,
+ enumerable: true,
+
+ get() {
+ if (gDBConnWithPendingTransaction)
+ return gDBConnWithPendingTransaction;
- if (!gDBConnection) {
- gDBConnection = getDBConnection();
- Services.obs.addObserver(function dbClose(aSubject, aTopic, aData) {
- Services.obs.removeObserver(dbClose, aTopic);
- if (gDBConnection) {
- gDBConnection.asyncClose();
- gDBConnection = null;
- }
- }, "profile-before-change");
+ if (!gDBConnection) {
+ gDBConnection = getDBConnection();
+ Services.obs.addObserver(function dbClose(aSubject, aTopic, aData) {
+ Services.obs.removeObserver(dbClose, aTopic);
+ if (gDBConnection) {
+ gDBConnection.asyncClose();
+ gDBConnection = null;
+ }
+ }, "profile-before-change");
+ }
+ gDBConnWithPendingTransaction = gDBConnection;
+ gDBConnection.beginTransaction();
+ executeSoon(function() {
+ gDBConnWithPendingTransaction.commitTransaction();
+ gDBConnWithPendingTransaction = null;
+ });
+ return gDBConnection;
}
- gDBConnWithPendingTransaction = gDBConnection;
- gDBConnection.beginTransaction();
- executeSoon(function() {
- gDBConnWithPendingTransaction.commitTransaction();
- gDBConnWithPendingTransaction = null;
- });
- return gDBConnection;
});
function TagsService() { }
TagsService.prototype = {
get wrappedJSObject() { return this; },
get defaultTag() { return this.createTag(_("defaultGroup")); },
createTag: function(aName) {
// If the tag already exists, we don't want to create a duplicate.
--- a/chat/modules/imSmileys.jsm
+++ b/chat/modules/imSmileys.jsm
@@ -18,20 +18,25 @@ this.EXPORTED_SYMBOLS = [
"smileString", // used to add smile:// img tags into a string without parsing it as HTML. Be sure the string doesn't contain HTML tags.
"getSmileRealURI", // used to retrive the chrome URI for a smile:// URI
"getSmileyList" // used to display a list of smileys in the UI
];
var kEmoticonsThemePref = "messenger.options.emoticonsTheme";
var kThemeFile = "theme.js";
-this.__defineGetter__("gTheme", function() {
- delete this.gTheme;
- gPrefObserver.init();
- return this.gTheme = getTheme();
+Object.defineProperty(this, "gTheme", {
+ configurable: true,
+ enumerable: true,
+
+ get() {
+ delete this.gTheme;
+ gPrefObserver.init();
+ return this.gTheme = getTheme();
+ }
});
var gPrefObserver = {
init: function po_init() {
Services.prefs.addObserver(kEmoticonsThemePref, gPrefObserver);
},
observe: function so_observe(aObject, aTopic, aMsg) {
--- a/chat/protocols/xmpp/xmpp-session.jsm
+++ b/chat/protocols/xmpp/xmpp-session.jsm
@@ -16,17 +16,23 @@ Cu.import("resource:///modules/xmpp-auth
XPCOMUtils.defineLazyGetter(this, "_", () =>
l10nHelper("chrome://chat/locale/xmpp.properties")
);
// Workaround because a lazy getter can't be exported.
XPCOMUtils.defineLazyGetter(this, "_defaultResource", () =>
l10nHelper("chrome://branding/locale/brand.properties")("brandShortName")
);
-this.__defineGetter__("XMPPDefaultResource", () => _defaultResource);
+Object.defineProperty(this, "XMPPDefaultResource", {
+ configurable: true,
+ enumerable: true,
+ get() {
+ return _defaultResource;
+ }
+});
function XMPPSession(aHost, aPort, aSecurity, aJID, aPassword, aAccount) {
this._host = aHost;
this._port = aPort;
this._connectionSecurity = aSecurity;
if (this._connectionSecurity == "old_ssl")
this._security = ["ssl"];