Bug 1525190 - Run eslint --fix over chat modules code. r=florian

This commit is contained in:
Patrick Cloke 2019-02-27 08:11:42 -05:00
Родитель ae63531e6b
Коммит 10f11d2e56
14 изменённых файлов: 337 добавлений и 338 удалений

Просмотреть файл

@ -28,10 +28,10 @@ var reporterListener = {
QueryInterface: ChromeUtils.generateQI(["nsIWebProgressListener",
"nsISupportsWeakReference"]),
onStateChange: function(/*in nsIWebProgress*/ aWebProgress,
/*in nsIRequest*/ aRequest,
/*in unsigned long*/ aStateFlags,
/*in nsresult*/ aStatus) {
onStateChange(/* in nsIWebProgress */ aWebProgress,
/* in nsIRequest */ aRequest,
/* in unsigned long */ aStateFlags,
/* in nsresult */ aStatus) {
if (aStateFlags & wpl.STATE_START &&
aStateFlags & wpl.STATE_IS_NETWORK) {
this.statusMeter.value = 0;
@ -45,33 +45,33 @@ var reporterListener = {
}
},
onProgressChange: function(/*in nsIWebProgress*/ aWebProgress,
/*in nsIRequest*/ aRequest,
/*in long*/ aCurSelfProgress,
/*in long */aMaxSelfProgress,
/*in long */aCurTotalProgress,
/*in long */aMaxTotalProgress) {
onProgressChange(/* in nsIWebProgress */ aWebProgress,
/* in nsIRequest */ aRequest,
/* in long */ aCurSelfProgress,
/* in long */ aMaxSelfProgress,
/* in long */ aCurTotalProgress,
/* in long */ aMaxTotalProgress) {
if (aMaxTotalProgress > 0) {
let percentage = (aCurTotalProgress * 100) / aMaxTotalProgress;
this.statusMeter.value = percentage;
}
},
onLocationChange: function(/*in nsIWebProgress*/ aWebProgress,
/*in nsIRequest*/ aRequest,
/*in nsIURI*/ aLocation) {
this.securityDisplay.setAttribute('label', aLocation.host);
onLocationChange(/* in nsIWebProgress */ aWebProgress,
/* in nsIRequest */ aRequest,
/* in nsIURI */ aLocation) {
this.securityDisplay.setAttribute("label", aLocation.host);
},
onStatusChange: function(/*in nsIWebProgress*/ aWebProgress,
/*in nsIRequest*/ aRequest,
/*in nsresult*/ aStatus,
/*in wstring*/ aMessage) {
onStatusChange(/* in nsIWebProgress */ aWebProgress,
/* in nsIRequest */ aRequest,
/* in nsresult */ aStatus,
/* in wstring */ aMessage) {
},
onSecurityChange: function(/*in nsIWebProgress*/ aWebProgress,
/*in nsIRequest*/ aRequest,
/*in unsigned long*/ aState) {
onSecurityChange(/* in nsIWebProgress */ aWebProgress,
/* in nsIRequest */ aRequest,
/* in unsigned long */ aState) {
const wpl_security_bits = wpl.STATE_IS_SECURE |
wpl.STATE_IS_BROKEN |
wpl.STATE_IS_INSECURE;
@ -98,11 +98,11 @@ var reporterListener = {
browser.securityUI.tooltipText);
},
onContentBlockingEvent: function(/*in nsIWebProgress*/ aWebProgress,
/*in nsIRequest*/ aRequest,
/*in unsigned long*/ aEvent) {
}
}
onContentBlockingEvent(/* in nsIWebProgress */ aWebProgress,
/* in nsIRequest */ aRequest,
/* in unsigned long */ aEvent) {
},
};
function cancelRequest()
{

Просмотреть файл

@ -10,7 +10,7 @@ var { initHTMLDocument, serializeSelection, getCurrentTheme, isNextMessage, getH
var { smileTextNode } = ChromeUtils.import("resource:///modules/imSmileys.jsm");
var { cleanupImMarkup } = ChromeUtils.import("resource:///modules/imContentSink.jsm");
(function () {
(function() {
// <browser> is lazily set up through setElementCreationCallback,
// i.e. put into customElements the first time it's really seen.
// Create a fake to ensure browser exists in customElements, since otherwise
@ -120,7 +120,7 @@ class MozConversationBrowser extends customElements.get("browser") {
});
this.addEventListener("keypress", (event) => {
switch(event.keyCode) {
switch (event.keyCode) {
case KeyEvent.DOM_VK_PAGE_UP: {
if (event.shiftKey) {
this.contentWindow.scrollByPages(-1);

Просмотреть файл

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var accountOptionsHelper = {
createTextbox: function(aType, aValue, aLabel, aName, aContainerType) {
createTextbox(aType, aValue, aLabel, aName, aContainerType) {
let container = document.createElement(aContainerType);
if (aContainerType == "row")
container.setAttribute("align", "center");
@ -24,7 +24,7 @@ var accountOptionsHelper = {
return container;
},
createMenulist: function(aList, aLabel, aName) {
createMenulist(aList, aLabel, aName) {
let vbox = document.createElement("vbox");
vbox.setAttribute("flex", "1");
@ -51,7 +51,7 @@ var accountOptionsHelper = {
// Adds options with specific prefix for ids to UI according to their types
// with optional attributes for each type and returns true if at least one
// option has been added to UI, otherwise returns false.
addOptions: function(aIdPrefix, aOptions, aAttributes) {
addOptions(aIdPrefix, aOptions, aAttributes) {
let rows = document.getElementById("protoSpecific");
while (rows.hasChildNodes())
rows.lastChild.remove();
@ -98,5 +98,5 @@ var accountOptionsHelper = {
haveOptions = true;
}
return haveOptions;
}
},
};

Просмотреть файл

@ -26,7 +26,7 @@ load_libresolv.prototype = {
library: null,
// Tries to find and load library.
_open: function() {
_open() {
function findLibrary() {
let lastException = null;
let libnames =
@ -93,13 +93,13 @@ load_libresolv.prototype = {
this.NS_C_IN = 1;
},
close: function() {
close() {
this.library.close();
this.library = null;
},
// Maps record to SRVRecord or TXTRecord according to aTypeID and return it.
_mapAnswer: function(aTypeID, aAnswer, aIdx, aLength) {
_mapAnswer(aTypeID, aAnswer, aIdx, aLength) {
if (aTypeID == NS_T_SRV) {
let prio = this.ns_get16(aAnswer.addressOfElement(aIdx));
let weight = this.ns_get16(aAnswer.addressOfElement(aIdx + 2));
@ -123,7 +123,7 @@ load_libresolv.prototype = {
// Performs a DNS query for aTypeID on a certain address (aName) and returns
// array of records of aTypeID.
lookup: function(aName, aTypeID) {
lookup(aName, aTypeID) {
let qname = ctypes.char.array()(aName);
let answer = ctypes.unsigned_char.array(this.QUERYBUF_SIZE)();
let length =
@ -163,7 +163,7 @@ load_libresolv.prototype = {
idx += dataLength;
}
return results;
}
},
};
// For Windows.
@ -175,7 +175,7 @@ load_dnsapi.prototype = {
library: null,
// Tries to find and load library.
_open: function() {
_open() {
function declare(aSymbolName, ...aArgs) {
try {
return library.declare(aSymbolName, ...aArgs);
@ -192,12 +192,12 @@ load_dnsapi.prototype = {
{ wPriority: ctypes.unsigned_short },
{ wWeight: ctypes.unsigned_short },
{ wPort: ctypes.unsigned_short },
{ Pad: ctypes.unsigned_short }
{ Pad: ctypes.unsigned_short },
]);
this.DNS_TXT_DATA = ctypes.StructType("DNS_TXT_DATA", [
{ dwStringCount: ctypes.unsigned_long },
{ pStringArray: ctypes.jschar.ptr.array(1) }
{ pStringArray: ctypes.jschar.ptr.array(1) },
]);
this.DNS_RECORD = ctypes.StructType("_DnsRecord");
@ -209,7 +209,7 @@ load_dnsapi.prototype = {
{ Flags: ctypes.unsigned_long },
{ dwTtl: ctypes.unsigned_long },
{ dwReserved: ctypes.unsigned_long },
{ Data: this.DNS_SRV_DATA } // its a union, can be cast to many things
{ Data: this.DNS_SRV_DATA }, // it's a union, can be cast to many things
]);
this.PDNS_RECORD = ctypes.PointerType(this.DNS_RECORD);
@ -226,13 +226,13 @@ load_dnsapi.prototype = {
this.DnsFreeRecordList = 1;
},
close: function() {
close() {
this.library.close();
this.library = null;
},
// Maps record to SRVRecord or TXTRecord according to aTypeID and return it.
_mapAnswer: function(aTypeID, aData) {
_mapAnswer(aTypeID, aData) {
if (aTypeID == NS_T_SRV) {
let srvdata = ctypes.cast(aData, this.DNS_SRV_DATA);
return new SRVRecord(srvdata.wPriority, srvdata.wWeight,
@ -249,7 +249,7 @@ load_dnsapi.prototype = {
// Performs a DNS query for aTypeID on a certain address (aName) and returns
// array of records of aTypeID (e.g. SRVRecord or TXTRecord).
lookup: function(aName, aTypeID) {
lookup(aName, aTypeID) {
let queryResultsSet = this.PDNS_RECORD();
let qname = ctypes.jschar.array()(aName);
let dnsStatus = this.DnsQuery_W(qname, aTypeID, this.DNS_QUERY_STANDARD,
@ -274,7 +274,7 @@ load_dnsapi.prototype = {
this.DnsRecordListFree(queryResultsSet, this.DnsFreeRecordList);
return results;
}
},
};
// Used to make results of different libraries consistent for SRV queries.
@ -333,16 +333,16 @@ else {
* @param aTypeID The RR type to look up as a constant.
* @return A promise resolved when completed.
*/
lookup: function(aName, aTypeID) {
lookup(aName, aTypeID) {
let worker = new BasePromiseWorker(LOCATION);
return worker.post("execute",
[Services.appinfo.OS, "lookup", [...arguments]]);
},
/** Convenience functions */
srv: function(aName) { return this.lookup(aName, NS_T_SRV); },
txt: function(aName) { return this.lookup(aName, NS_T_TXT); },
}
srv(aName) { return this.lookup(aName, NS_T_SRV); },
txt(aName) { return this.lookup(aName, NS_T_TXT); },
};
this.DNS = dns_async_front;
this.EXPORTED_SYMBOLS = ["DNS"];
}

Просмотреть файл

@ -38,4 +38,4 @@ class NormalizedMap extends Map {
super.set(this._normalize(key), val);
return this;
}
};
}

Просмотреть файл

@ -30,7 +30,7 @@ function month(aDate, option) {
}
function hourMinSecTwoDigits(aDate) {
return aDate.toLocaleString(undefined, {
hour: "2-digit", minute: "2-digit", second: "2-digit"
hour: "2-digit", minute: "2-digit", second: "2-digit",
});
}
function dayPeriod(aDate) {
@ -83,13 +83,13 @@ function timeZone(aDate) {
}
const dateTimeFormatter = new Services.intl.DateTimeFormat(undefined, {
dateStyle: "full", timeStyle: "long"
dateStyle: "full", timeStyle: "long",
});
const dateFormatter = new Services.intl.DateTimeFormat(undefined, {
dateStyle: "full"
dateStyle: "full",
});
const timeFormatter = new Services.intl.DateTimeFormat(undefined, {
timeStyle: "long"
timeStyle: "long",
});
const formatFunctions = {

Просмотреть файл

@ -20,7 +20,7 @@ this.EXPORTED_SYMBOLS = [
"addGlobalAllowedAttribute",
"removeGlobalAllowedAttribute",
"addGlobalAllowedStyleRule",
"removeGlobalAllowedStyleRule"
"removeGlobalAllowedStyleRule",
];
/*
@ -53,7 +53,7 @@ var kAllowedAnchorClasses = aClassName => aClassName == "ib-person";
/* Tags whose content should be fully removed, and reported in the Error Console. */
var kForbiddenTags = {
script: true,
style: true
style: true,
};
// in strict mode, remove all formatings. Keep only links and line breaks.
@ -61,105 +61,105 @@ var kStrictMode = {
attrs: { },
tags: {
'a': {
'title': true,
'href': kAllowedURLs,
'class': kAllowedAnchorClasses
"a": {
"title": true,
"href": kAllowedURLs,
"class": kAllowedAnchorClasses,
},
'br': true,
'p': true
"br": true,
"p": true,
},
styles: { }
styles: { },
};
// standard mode allows basic formattings (bold, italic, underlined)
var kStandardMode = {
attrs: {
'style': true
"style": true,
},
tags: {
'div': true,
'a': {
'title': true,
'href': kAllowedURLs,
'class': kAllowedAnchorClasses
"div": true,
"a": {
"title": true,
"href": kAllowedURLs,
"class": kAllowedAnchorClasses,
},
'em': true,
'strong': true,
'b': true,
'i': true,
'u': true,
'span': {
'class': kAllowedMozClasses
"em": true,
"strong": true,
"b": true,
"i": true,
"u": true,
"span": {
"class": kAllowedMozClasses,
},
'br': true,
'code': true,
'ul': true,
'li': true,
'ol': true,
'cite': true,
'blockquote': true,
'p': true
"br": true,
"code": true,
"ul": true,
"li": true,
"ol": true,
"cite": true,
"blockquote": true,
"p": true,
},
styles: {
'font-style': true,
'font-weight': true,
'text-decoration-line': true
}
"font-style": true,
"font-weight": true,
"text-decoration-line": true,
},
};
// permissive mode allows about anything that isn't going to mess up the chat window
var kPermissiveMode = {
attrs: {
'style': true
"style": true,
},
tags : {
'div': true,
'a': {
'title': true,
'href': kAllowedURLs,
'class': kAllowedAnchorClasses
tags: {
"div": true,
"a": {
"title": true,
"href": kAllowedURLs,
"class": kAllowedAnchorClasses,
},
'font': {
'face': true,
'color': true,
'size': true
"font": {
"face": true,
"color": true,
"size": true,
},
'em': true,
'strong': true,
'b': true,
'i': true,
'u': true,
'span': {
'class': kAllowedMozClasses
"em": true,
"strong": true,
"b": true,
"i": true,
"u": true,
"span": {
"class": kAllowedMozClasses,
},
'br': true,
'hr': true,
'code': true,
'ul': true,
'li': true,
'ol': true,
'cite': true,
'blockquote': true,
'p': true
"br": true,
"hr": true,
"code": true,
"ul": true,
"li": true,
"ol": true,
"cite": true,
"blockquote": true,
"p": true,
},
// FIXME: should be possible to use functions to filter values
styles : {
'color': true,
'font': true,
'font-family': true,
'font-size': true,
'font-style': true,
'font-weight': true,
'text-decoration-color': true,
'text-decoration-style': true,
'text-decoration-line': true
}
styles: {
"color": true,
"font": true,
"font-family": true,
"font-size": true,
"font-style": true,
"font-weight": true,
"text-decoration-color": true,
"text-decoration-style": true,
"text-decoration-line": true,
},
};
var kModePref = "messenger.options.filterMode";
@ -183,7 +183,7 @@ var styleObserver = {
throw "gGlobalRuleset not initialized";
setBaseRuleset(getModePref(), gGlobalRuleset);
}
},
};
function getModePref()
@ -206,7 +206,7 @@ function newRuleset(aBase)
let result = {
tags: {},
attrs: {},
styles: {}
styles: {},
};
setBaseRuleset(aBase || getModePref(), result);
return result;
@ -290,7 +290,7 @@ function cleanupNode(aNode, aRules, aTextModifiers)
// we check both the list of accepted attributes for all tags
// and the list of accepted attributes for this specific tag.
if (!(acceptFunction(aRules.attrs, attr) ||
((typeof aRules.tags[nodeName] == "object") &&
((typeof aRules.tags[nodeName] == "object") &&
acceptFunction(aRules.tags[nodeName], attr)))) {
node.removeAttribute(attr.name);
--j;
@ -322,7 +322,7 @@ function cleanupNode(aNode, aRules, aTextModifiers)
}
attrs = attrs.split(";").map(a => a.trim());
attrs.sort();
node.setAttribute("style", attrs.join("; ") + (trailingSemi?";":""));
node.setAttribute("style", attrs.join("; ") + (trailingSemi ? ";" : ""));
}
}
else {

Просмотреть файл

@ -17,7 +17,7 @@ this.EXPORTED_SYMBOLS = [
"smileTextNode", // used to add smile:// img tags to the content of a textnode
"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 retrieve the chrome URI for a smile:// URI
"getSmileyList" // used to display a list of smileys in the UI
"getSmileyList", // used to display a list of smileys in the UI
];
var kEmoticonsThemePref = "messenger.options.emoticonsTheme";
@ -31,7 +31,7 @@ Object.defineProperty(this, "gTheme", {
delete this.gTheme;
gPrefObserver.init();
return this.gTheme = getTheme();
}
},
});
var gPrefObserver = {
@ -44,7 +44,7 @@ var gPrefObserver = {
throw "bad notification";
gTheme = getTheme();
}
},
};
function getSmileRealURI(aSmile)
@ -77,10 +77,10 @@ function getTheme(aName)
let name = aName || Services.prefs.getCharPref(kEmoticonsThemePref);
let theme = {
name: name,
name,
iconsHash: null,
json: null,
regExp: null
regExp: null,
};
if (name == "none")
@ -105,7 +105,7 @@ function getTheme(aName)
for (let textCode of smiley.textCodes)
theme.iconsHash[textCode] = smiley;
}
} catch(e) {
} catch (e) {
Cu.reportError(e);
}
return theme;
@ -145,7 +145,7 @@ function getRegexp()
return null;
}
gTheme.regExp = new RegExp(emoticonList.join('|'), 'g');
gTheme.regExp = new RegExp(emoticonList.join("|"), "g");
return gTheme.regExp;
}

Просмотреть файл

@ -37,7 +37,7 @@ var Status = {
aStatusType in statusAttributes ? statusAttributes[aStatusType] : "unknown",
_labels: {},
toLabel: function(aStatusType, aStatusText) {
toLabel(aStatusType, aStatusText) {
// aStatusType may be either one of the (integral) imIStatusInfo status
// constants, or one of the statusAttributes.
if (!(typeof aStatusType == "string"))
@ -53,10 +53,10 @@ var Status = {
return label;
},
toFlag: function(aAttribute) {
toFlag(aAttribute) {
for (let flag in statusAttributes)
if (statusAttributes[flag] == aAttribute)
return flag;
return imIStatusInfo.STATUS_UNKNOWN;
}
},
};

Просмотреть файл

@ -11,7 +11,7 @@ this.EXPORTED_SYMBOLS = [
"insertHTMLForMessage",
"initHTMLDocument",
"getMessagesForRange",
"serializeSelection"
"serializeSelection",
];
const {Services} = ChromeUtils.import("resource:///modules/imServices.jsm");
@ -44,7 +44,7 @@ XPCOMUtils.defineLazyGetter(this, "gTimeFormatter", () => {
return new Services.intl.DateTimeFormat(undefined, {
hour: "2-digit",
minute: "2-digit",
second: "2-digit"
second: "2-digit",
});
});
@ -89,7 +89,7 @@ function HTMLTheme(aBaseURI)
outgoingContent: "Outgoing/Content.html",
outgoingContext: "Outgoing/Context.html",
outgoingNextContent: "Outgoing/NextContent.html",
outgoingNextContext: "Outgoing/NextContext.html"
outgoingNextContext: "Outgoing/NextContext.html",
};
for (let id in files) {
@ -116,29 +116,29 @@ HTMLTheme.prototype = {
get incomingContext() { return this.incomingContent; },
get incomingNextContext() { return this.incomingNextContent; },
get outgoingContext() { return this.hasOwnProperty("outgoingContent") ? this.outgoingContent : this.incomingContext; },
get outgoingNextContext() { return this.hasOwnProperty("outgoingNextContent") ? this.outgoingNextContent : this.incomingNextContext; }
get outgoingNextContext() { return this.hasOwnProperty("outgoingNextContent") ? this.outgoingNextContent : this.incomingNextContext; },
};
function plistToJSON(aElt)
{
switch (aElt.localName) {
case 'true':
case "true":
return true;
case 'false':
case "false":
return false;
case 'string':
case 'data':
case "string":
case "data":
return aElt.textContent;
case 'real':
case "real":
return parseFloat(aElt.textContent);
case 'integer':
case "integer":
return parseInt(aElt.textContent, 10);
case 'dict':
case "dict":
let res = {};
let nodes = aElt.childNodes;
for (let i = 0; i < nodes.length; ++i) {
if (nodes[i].nodeName == 'key') {
if (nodes[i].nodeName == "key") {
let key = nodes[i].textContent;
++i;
while (!Element.isInstance(nodes[i]))
@ -148,7 +148,7 @@ function plistToJSON(aElt)
}
return res;
case 'array':
case "array":
let array = [];
nodes = aElt.childNodes;
for (let i = 0; i < nodes.length; ++i) {
@ -181,7 +181,7 @@ function getInfoPlistContent(aBaseURI)
if (!node || node.localName != "dict")
throw "Empty or invalid Info.plist file";
return plistToJSON(node);
} catch(e) {
} catch (e) {
Cu.reportError(e);
return null;
}
@ -204,12 +204,12 @@ function getThemeByName(aName)
return {
name: aName,
variant: "default",
baseURI: baseURI,
metadata: metadata,
baseURI,
metadata,
html: new HTMLTheme(baseURI),
showHeader: gPrefBranch.getBoolPref(kShowHeaderPref),
combineConsecutive: gPrefBranch.getBoolPref(kCombineConsecutivePref),
combineConsecutiveInterval: gPrefBranch.getIntPref(kCombineConsecutiveIntervalPref)
combineConsecutiveInterval: gPrefBranch.getIntPref(kCombineConsecutiveIntervalPref),
};
}
@ -224,7 +224,7 @@ function getCurrentTheme()
try {
gCurrentTheme = getThemeByName(name);
gCurrentTheme.variant = variant;
} catch(e) {
} catch (e) {
Cu.reportError(e);
gCurrentTheme = getThemeByName(DEFAULT_THEME);
gCurrentTheme.variant = "default";
@ -338,18 +338,18 @@ var headerFooterReplacements = {
sourceName: aConv => TXTToHTML(aConv.account.alias || aConv.account.name),
destinationName: aConv => TXTToHTML(aConv.name),
destinationDisplayName: aConv => TXTToHTML(aConv.title),
incomingIconPath: function(aConv) {
incomingIconPath(aConv) {
let buddy;
return (!aConv.isChat && (buddy = aConv.buddy) &&
buddy.buddyIconFilename) || "incoming_icon.png";
},
outgoingIconPath: aConv => "outgoing_icon.png",
timeOpened: function(aConv, aFormat) {
timeOpened(aConv, aFormat) {
let date = new Date(aConv.startDate / 1000);
if (aFormat)
return ToLocaleFormat(aFormat, date);
return gTimeFormatter.format(date);
}
},
};
function formatAutoResponce(aTxt) {
@ -362,17 +362,17 @@ var statusMessageReplacements = {
message: aMsg => "<span class=\"ib-msg-txt\">" +
(aMsg.autoResponse ? formatAutoResponce(aMsg.message) : aMsg.message) +
"</span>",
time: function(aMsg, aFormat) {
time(aMsg, aFormat) {
let date = new Date(aMsg.time * 1000);
if (aFormat)
return ToLocaleFormat(aFormat, date);
return gTimeFormatter.format(date);
},
timestamp: aMsg => aMsg.time,
shortTime: function(aMsg) {
shortTime(aMsg) {
return gTimeFormatter.format(new Date(aMsg.time * 1000));
},
messageClasses: function(aMsg) {
messageClasses(aMsg) {
let msgClass = [];
if (aMsg.system)
@ -404,14 +404,14 @@ var statusMessageReplacements = {
msgClass.push("monospaced");
return msgClass.join(" ");
}
},
};
function formatSender(aName) {
return "<span class=\"ib-sender\">" + TXTToHTML(aName) + "</span>";
}
var messageReplacements = {
userIconPath: function (aMsg) {
userIconPath(aMsg) {
// If the protocol plugin provides an icon for the message, use it.
let iconURL = aMsg.iconURL;
if (iconURL)
@ -437,19 +437,19 @@ var messageReplacements = {
senderDisplayName: aMsg => formatSender(aMsg.alias || aMsg.who),
service: aMsg => aMsg.conversation.account.protocol.name,
textbackgroundcolor: (aMsg, aFormat) => "transparent", // FIXME?
__proto__: statusMessageReplacements
__proto__: statusMessageReplacements,
};
var statusReplacements = {
status: aMsg => "", //FIXME
statusIcon: function(aMsg) {
status: aMsg => "", // FIXME
statusIcon(aMsg) {
let conv = aMsg.conversation;
let buddy = null;
if (!conv.isChat)
buddy = conv.buddy;
return getStatusIconFromBuddy(buddy);
},
__proto__: statusMessageReplacements
__proto__: statusMessageReplacements,
};
var kReplacementRegExp = /%([a-zA-Z]*)(\{([^\}]*)\})?%/g;
@ -753,8 +753,7 @@ function serializeSelection(aSelection)
if (shortVersionPossible)
return shortSelection || aSelection.toString();
else
return longSelection.join(kLineBreak);
return longSelection.join(kLineBreak);
}
function SelectedMessage(aRootNode, aRange)
@ -765,13 +764,13 @@ function SelectedMessage(aRootNode, aRange)
SelectedMessage.prototype = {
get msg() { return this._rootNodes[0]._originalMsg; },
addRoot: function(aRootNode) {
addRoot(aRootNode) {
this._rootNodes.push(aRootNode);
},
// Helper function that returns the first span node of class
// ib-msg-text under the rootNodes of the selected message.
_getSpanNode: function() {
_getSpanNode() {
// first use the cached value if any
if (this._spanNode)
return this._spanNode;
@ -805,7 +804,7 @@ SelectedMessage.prototype = {
// Initialize _textSelected and _otherSelected; if _textSelected is true,
// also initialize _selectedText and _cutBegin/End.
_initSelectedText: function() {
_initSelectedText() {
if ("_textSelected" in this)
return; // already initialized
@ -870,19 +869,19 @@ SelectedMessage.prototype = {
this._initSelectedText();
return this._textSelected && this._cutEnd;
},
isTextSelected: function() {
isTextSelected() {
this._initSelectedText();
return this._textSelected;
},
onlyTextSelected: function() {
onlyTextSelected() {
this._initSelectedText();
return !this._otherSelected;
},
getSelectedText: function() {
getSelectedText() {
this._initSelectedText();
return this._textSelected ? this._selectedText : "";
},
getFormattedMessage: function() {
getFormattedMessage() {
// First, get the selected text
this._initSelectedText();
let msg = this.msg;
@ -900,13 +899,13 @@ SelectedMessage.prototype = {
}
// then get the suitable replacements and templates for this message
let getLocalizedPrefWithDefault = function (aName, aDefault) {
let getLocalizedPrefWithDefault = function(aName, aDefault) {
try {
let prefBranch =
Services.prefs.getBranch("messenger.conversations.selections.");
return prefBranch.getComplexValue(aName,
Ci.nsIPrefLocalizedString).data;
} catch(e) {
} catch (e) {
return aDefault;
}
};
@ -935,12 +934,12 @@ SelectedMessage.prototype = {
replacements = {
message: aMsg => text,
sender: aMsg => aMsg.alias || aMsg.who,
__proto__: replacements
__proto__: replacements,
};
// Finally, let the theme system do the magic!
return replaceKeywordsInHTML(html, replacements, msg);
}
},
};
function getMessagesForRange(aRange)
@ -956,7 +955,6 @@ function getMessagesForRange(aRange)
// properties on DOM nodes, and stop when endNode is reached.
// Found nodes are pushed into the rootNodes array.
let processSubtree = function(aNode) {
if (aNode._originalMsg) {
// store the result
if (!(aNode._originalMsg.id in messages)) {

Просмотреть файл

@ -11,7 +11,7 @@ this.EXPORTED_SYMBOLS = [
"EmptyEnumerator",
"ClassInfo",
"l10nHelper",
"initLogModule"
"initLogModule",
];
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
@ -71,7 +71,7 @@ function scriptError(aModule, aLevel, aMessage, aOriginalError) {
if (aOriginalError.fileName)
fileName = aOriginalError.fileName;
if (aOriginalError.lineNumber)
lineNumber = aOriginalError.lineNumber
lineNumber = aOriginalError.lineNumber;
}
scriptError.init(aMessage, fileName, sourceLine, lineNumber, null, flag,
"component javascript");
@ -101,7 +101,7 @@ XPCOMUtils.defineLazyGetter(Cu.getGlobalForObject({}), "gLogLevels", function()
// is necessary to make sure the observe is left alive while being a weak ref
// to avoid cycles with the pref service.
let logLevels = {
observe: function(aSubject, aTopic, aData) {
observe(aSubject, aTopic, aData) {
let module = "level" + aData.substr(kLogLevelPref.length);
if (Services.prefs.getPrefType(aData) == Services.prefs.PREF_INT)
gLogLevels[module] = Services.prefs.getIntPref(aData);
@ -143,7 +143,7 @@ function setTimeout(aFunction, aDelay)
// GC'ed before firing the callback.
let callback = {
_timer: timer,
notify: function (aTimer) { aFunction.apply(null, args); delete this._timer; }
notify(aTimer) { aFunction.apply(null, args); delete this._timer; },
};
timer.initWithCallback(callback, aDelay, Ci.nsITimer.TYPE_ONE_SHOT);
return timer;
@ -179,7 +179,8 @@ function ClassInfo(aInterfaces, aDescription = "JS Proto Object")
this.classDescription = aDescription;
}
ClassInfo.prototype = {
QueryInterface: function ClassInfo_QueryInterface(iid) {
// eslint-disable-next-line mozilla/use-chromeutils-generateqi
QueryInterface(iid) {
if (iid.equals(Ci.nsISupports) || iid.equals(Ci.nsIClassInfo) ||
this._interfaces.some(i => i.equals(iid)))
return this;
@ -192,13 +193,13 @@ ClassInfo.prototype = {
getHelperForLanguage: language => null,
contractID: null,
classID: null,
flags: 0
flags: 0,
};
function l10nHelper(aChromeURL)
{
let bundle = Services.strings.createBundle(aChromeURL);
return function (aStringId) {
return function(aStringId) {
try {
if (arguments.length == 1)
return bundle.GetStringFromName(aStringId);
@ -226,20 +227,20 @@ function nsSimpleEnumerator(items)
this._nextIndex = 0;
}
nsSimpleEnumerator.prototype = {
hasMoreElements: function() { return this._nextIndex < this._items.length; },
getNext: function() {
hasMoreElements() { return this._nextIndex < this._items.length; },
getNext() {
if (!this.hasMoreElements())
throw Cr.NS_ERROR_NOT_AVAILABLE;
return this._items[this._nextIndex++];
},
QueryInterface: ChromeUtils.generateQI([Ci.nsISimpleEnumerator]),
[Symbol.iterator]() { return this._items.values(); }
[Symbol.iterator]() { return this._items.values(); },
};
var EmptyEnumerator = {
hasMoreElements: () => false,
getNext: function() { throw Cr.NS_ERROR_NOT_AVAILABLE; },
getNext() { throw Cr.NS_ERROR_NOT_AVAILABLE; },
QueryInterface: ChromeUtils.generateQI([Ci.nsISimpleEnumerator]),
* [Symbol.iterator]() {}
* [Symbol.iterator]() {},
};

Просмотреть файл

@ -12,7 +12,7 @@ this.EXPORTED_SYMBOLS = [
"GenericMessagePrototype",
"GenericProtocolPrototype",
"Message",
"TooltipInfo"
"TooltipInfo",
];
const {
@ -37,16 +37,16 @@ var GenericAccountPrototype = {
this.imAccount = aImAccount;
initLogModule(aProtocol.id, this);
},
observe: function(aSubject, aTopic, aData) {},
remove: function() { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
unInit: function() { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
connect: function() { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
disconnect: function() { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
createConversation: function(aName) { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
joinChat: function(aComponents) { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
setBool: function(aName, aVal) {},
setInt: function(aName, aVal) {},
setString: function(aName, aVal) {},
observe(aSubject, aTopic, aData) {},
remove() { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
unInit() { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
connect() { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
disconnect() { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
createConversation(aName) { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
joinChat(aComponents) { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
setBool(aName, aVal) {},
setInt(aName, aVal) {},
setString(aName, aVal) {},
get name() { return this.imAccount.name; },
get connected() { return this.imAccount.connected; },
@ -61,7 +61,7 @@ var GenericAccountPrototype = {
* the nsITransportSecurityInfo and the connection location on the account so the
* certificate exception dialog can access the information.
*/
handleBadCertificate: function(aSocket, aIsSslError) {
handleBadCertificate(aSocket, aIsSslError) {
this._connectionTarget = aSocket.host + ":" + aSocket.port;
if (aIsSslError)
@ -97,10 +97,10 @@ var GenericAccountPrototype = {
_secInfo: null,
get secInfo() { return this._secInfo; },
reportConnected: function() {
reportConnected() {
this.imAccount.observe(this, "account-connected", null);
},
reportConnecting: function(aConnectionStateMsg) {
reportConnecting(aConnectionStateMsg) {
// Delete any leftover errors from the previous connection.
delete this._connectionTarget;
delete this._secInfo;
@ -110,22 +110,22 @@ var GenericAccountPrototype = {
if (aConnectionStateMsg)
this.imAccount.observe(this, "account-connect-progress", aConnectionStateMsg);
},
reportDisconnected: function() {
reportDisconnected() {
this.imAccount.observe(this, "account-disconnected", null);
},
reportDisconnecting: function(aConnectionErrorReason, aConnectionErrorMessage) {
reportDisconnecting(aConnectionErrorReason, aConnectionErrorMessage) {
this._connectionErrorReason = aConnectionErrorReason;
this.imAccount.observe(this, "account-disconnecting", aConnectionErrorMessage);
this.cancelPendingBuddyRequests();
},
// Called when the user adds a new buddy from the UI.
addBuddy: function(aTag, aName) {
addBuddy(aTag, aName) {
Services.contacts
.accountBuddyAdded(new AccountBuddy(this, null, aTag, aName));
},
// Called during startup for each of the buddies in the local buddy list.
loadBuddy: function(aBuddy, aTag) {
loadBuddy(aBuddy, aTag) {
try {
return new AccountBuddy(this, aBuddy, aTag);
} catch (x) {
@ -135,7 +135,7 @@ var GenericAccountPrototype = {
},
_pendingBuddyRequests: null,
addBuddyRequest: function(aUserName, aGrantCallback, aDenyCallback) {
addBuddyRequest(aUserName, aGrantCallback, aDenyCallback) {
if (!this._pendingBuddyRequests)
this._pendingBuddyRequests = [];
let buddyRequest = {
@ -144,35 +144,35 @@ var GenericAccountPrototype = {
_account: this,
// Grant and deny callbacks both receive the auth request object as an
// argument for further use.
grant: function() {
grant() {
aGrantCallback(this);
this._remove();
},
deny: function() {
deny() {
aDenyCallback(this);
this._remove();
},
cancel: function() {
cancel() {
Services.obs.notifyObservers(this,
"buddy-authorization-request-canceled");
this._remove();
},
_remove: function() {
_remove() {
this._account.removeBuddyRequest(this);
},
QueryInterface: ChromeUtils.generateQI([Ci.prplIBuddyRequest])
QueryInterface: ChromeUtils.generateQI([Ci.prplIBuddyRequest]),
};
this._pendingBuddyRequests.push(buddyRequest);
Services.obs.notifyObservers(buddyRequest, "buddy-authorization-request");
},
removeBuddyRequest: function(aRequest) {
removeBuddyRequest(aRequest) {
if (!this._pendingBuddyRequests)
return;
this._pendingBuddyRequests =
this._pendingBuddyRequests.filter(r => r !== aRequest);
},
cancelPendingBuddyRequests: function() {
cancelPendingBuddyRequests() {
if (!this._pendingBuddyRequests)
return;
@ -181,10 +181,10 @@ var GenericAccountPrototype = {
delete this._pendingBuddyRequests;
},
requestBuddyInfo: function(aBuddyName) {},
requestBuddyInfo(aBuddyName) {},
get canJoinChat() { return false; },
getChatRoomFields: function() {
getChatRoomFields() {
if (!this.chatRoomFields)
return EmptyEnumerator;
@ -193,7 +193,7 @@ var GenericAccountPrototype = {
fields.push(new ChatRoomField(fieldName, this.chatRoomFields[fieldName]));
return new nsSimpleEnumerator(fields);
},
getChatRoomDefaultFieldValues: function(aDefaultChatName) {
getChatRoomDefaultFieldValues(aDefaultChatName) {
if (!this.chatRoomFields)
return EmptyEnumerator;
@ -209,18 +209,18 @@ var GenericAccountPrototype = {
return new ChatRoomFieldValues(defaultFieldValues);
},
requestRoomInfo: function(aCallback) { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
getRoomInfo: function(aName) { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
requestRoomInfo(aCallback) { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
getRoomInfo(aName) { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
get isRoomInfoStale() { return false; },
getPref: function (aName, aType) {
getPref(aName, aType) {
return this.prefs.prefHasUserValue(aName) ?
this.prefs["get" + aType + "Pref"](aName) :
this.protocol._getOptionDefault(aName);
},
getInt: function(aName) { return this.getPref(aName, "Int"); },
getBool: function(aName) { return this.getPref(aName, "Bool"); },
getString: function(aName) {
getInt(aName) { return this.getPref(aName, "Int"); },
getBool(aName) { return this.getPref(aName, "Bool"); },
getString(aName) {
return this.prefs.prefHasUserValue(aName) ?
this.prefs.getStringPref(aName) :
this.protocol._getOptionDefault(aName);
@ -233,7 +233,7 @@ var GenericAccountPrototype = {
},
get normalizedName() { return this.normalize(this.name); },
normalize: function(aName) { return aName.toLowerCase(); },
normalize(aName) { return aName.toLowerCase(); },
get HTMLEnabled() { return false; },
get HTMLEscapePlainText() { return false; },
@ -242,7 +242,7 @@ var GenericAccountPrototype = {
get singleFormatting() { return false; },
get noFontSizes() { return false; },
get noUrlDesc() { return false; },
get noImages() { return true; }
get noImages() { return true; },
};
@ -253,7 +253,7 @@ var GenericAccountBuddyPrototype = {
get WARN() { return this._account.WARN; },
get ERROR() { return this._account.ERROR; },
_init: function(aAccount, aBuddy, aTag, aUserName) {
_init(aAccount, aBuddy, aTag, aUserName) {
if (!aBuddy && !aUserName)
throw "aUserName is required when aBuddy is null";
@ -267,7 +267,7 @@ var GenericAccountBuddyPrototype = {
}
this._userName = aUserName;
},
unInit: function() {
unInit() {
delete this._tag;
delete this._account;
delete this._buddy;
@ -287,10 +287,10 @@ var GenericAccountBuddyPrototype = {
Services.contacts.accountBuddyMoved(this, oldTag, aNewTag);
},
_notifyObservers: function(aTopic, aData) {
_notifyObservers(aTopic, aData) {
try {
this._buddy.observe(this, "account-buddy-" + aTopic, aData);
} catch(e) {
} catch (e) {
this.ERROR(e);
}
},
@ -307,7 +307,7 @@ var GenericAccountBuddyPrototype = {
this._notifyObservers("display-name-changed", old);
},
remove: function() {
remove() {
Services.contacts.accountBuddyRemoved(this);
},
@ -332,7 +332,7 @@ var GenericAccountBuddyPrototype = {
// imIStatusInfo interface.
// All parameters are optional and will be ignored if they are null
// or undefined.
setStatus: function(aStatusType, aStatusText, aAvailabilityDetails) {
setStatus(aStatusType, aStatusText, aAvailabilityDetails) {
// Ignore omitted parameters.
if (aStatusType === undefined || aStatusType === null)
aStatusType = this._statusType;
@ -368,10 +368,10 @@ var GenericAccountBuddyPrototype = {
_availabilityDetails: 0,
get availabilityDetails() { return this._availabilityDetails; },
get canSendMessage() { return this.online /*|| this.account.canSendOfflineMessage(this) */; },
get canSendMessage() { return this.online; },
getTooltipInfo: () => EmptyEnumerator,
createConversation: function() { throw Cr.NS_ERROR_NOT_IMPLEMENTED; }
createConversation() { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
};
// aUserName is required only if aBuddy is null, i.e., we are adding a buddy.
@ -384,7 +384,7 @@ var GenericMessagePrototype = {
__proto__: ClassInfo("prplIMessage", "generic message object"),
_lastId: 0,
_init: function (aWho, aMessage, aObject) {
_init(aWho, aMessage, aObject) {
this.id = ++GenericMessagePrototype._lastId;
this.time = Math.floor(new Date() / 1000);
this.who = aWho;
@ -431,11 +431,11 @@ var GenericMessagePrototype = {
notification: false,
noLinkification: false,
getActions: function(aCount) {
getActions(aCount) {
if (aCount)
aCount.value = 0;
return [];
}
},
};
function Message(aWho, aMessage, aObject) {
@ -453,7 +453,7 @@ var GenericConversationPrototype = {
get WARN() { return this._account.WARN; },
get ERROR() { return this._account.ERROR; },
_init: function(aAccount, aName) {
_init(aAccount, aName) {
this._account = aAccount;
this._name = aName;
this._observers = [];
@ -469,45 +469,45 @@ var GenericConversationPrototype = {
this._id = aId;
},
addObserver: function(aObserver) {
addObserver(aObserver) {
if (!this._observers.includes(aObserver))
this._observers.push(aObserver);
},
removeObserver: function(aObserver) {
removeObserver(aObserver) {
this._observers = this._observers.filter(o => o !== aObserver);
},
notifyObservers: function(aSubject, aTopic, aData) {
notifyObservers(aSubject, aTopic, aData) {
for (let observer of this._observers) {
try {
observer.observe(aSubject, aTopic, aData);
} catch(e) {
} catch (e) {
this.ERROR(e);
}
}
},
prepareForSending: (aOutgoingMessage, aCount) => null,
prepareForDisplaying: function(aImMessage) {
prepareForDisplaying(aImMessage) {
if (aImMessage.displayMessage !== aImMessage.message) {
this.DEBUG("Preparing:\n" + aImMessage.message + "\nDisplaying:\n" +
aImMessage.displayMessage);
}
},
sendMsg: function(aMsg) {
sendMsg(aMsg) {
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
sendTyping: aString => Ci.prplIConversation.NO_TYPING_LIMIT,
close: function() {
close() {
Services.obs.notifyObservers(this, "closing-conversation");
Services.conversations.removeConversation(this);
},
unInit: function() {
unInit() {
delete this._account;
delete this._observers;
},
writeMessage: function(aWho, aText, aProperties) {
writeMessage(aWho, aText, aProperties) {
(new Message(aWho, aText, aProperties)).conversation = this;
},
@ -515,7 +515,7 @@ var GenericConversationPrototype = {
get name() { return this._name; },
get normalizedName() { return this._account.normalize(this.name); },
get title() { return this.name; },
get startDate() { return this._date; }
get startDate() { return this._date; },
};
var GenericConvIMPrototype = {
@ -523,7 +523,7 @@ var GenericConvIMPrototype = {
_interfaces: [Ci.prplIConversation, Ci.prplIConvIM],
classDescription: "generic ConvIM object",
updateTyping: function(aState, aName) {
updateTyping(aState, aName) {
if (aState == this.typingState)
return;
@ -536,7 +536,7 @@ var GenericConvIMPrototype = {
get isChat() { return false; },
buddy: null,
typingState: Ci.prplIConvIM.NOT_TYPING
typingState: Ci.prplIConvIM.NOT_TYPING,
};
var GenericConvChatPrototype = {
@ -544,7 +544,7 @@ var GenericConvChatPrototype = {
_interfaces: [Ci.prplIConversation, Ci.prplIConvChat],
classDescription: "generic ConvChat object",
_init: function(aAccount, aName, aNick) {
_init(aAccount, aName, aNick) {
this._participants = new Map();
this.nick = aNick;
GenericConversationPrototype._init.call(this, aAccount, aName);
@ -562,7 +562,7 @@ var GenericConvChatPrototype = {
get topic() { return this._topic; },
get topicSettable() { return false; },
get topicSetter() { return this._topicSetter; },
setTopic: function(aTopic, aTopicSetter, aQuiet) {
setTopic(aTopic, aTopicSetter, aQuiet) {
// Only change the topic if the topic and/or topic setter has changed.
if (this._topic == aTopic &&
(!this._topicSetter || this._topicSetter == aTopicSetter))
@ -619,10 +619,10 @@ var GenericConvChatPrototype = {
this.notifyObservers(null, "update-conv-chatjoining");
},
getParticipant: function(aName) {
getParticipant(aName) {
return this._participants.has(aName) ? this._participants.get(aName) : null;
},
getParticipants: function() {
getParticipants() {
// Convert the values of the Map into a nsSimpleEnumerator.
return new nsSimpleEnumerator(
Array.from(this._participants.values())
@ -631,7 +631,7 @@ var GenericConvChatPrototype = {
getNormalizedChatBuddyName: aChatBuddyName => aChatBuddyName,
// Updates the nick of a participant in conversation to a new one.
updateNick: function(aOldNick, aNewNick, isOwnNick) {
updateNick(aOldNick, aNewNick, isOwnNick) {
let message;
let isParticipant = this._participants.has(aOldNick);
if (isOwnNick) {
@ -664,7 +664,7 @@ var GenericConvChatPrototype = {
},
// Removes a participant from conversation.
removeParticipant: function(aNick) {
removeParticipant(aNick) {
if (!this._participants.has(aNick))
return;
@ -677,7 +677,7 @@ var GenericConvChatPrototype = {
},
// Removes all participant in conversation.
removeAllParticipants: function() {
removeAllParticipants() {
let stringNicknames = [];
this._participants.forEach(function(aParticipant) {
let stringNickname = Cc["@mozilla.org/supports-string;1"]
@ -690,11 +690,11 @@ var GenericConvChatPrototype = {
this._participants.clear();
},
writeMessage: function (aWho, aText, aProperties) {
writeMessage(aWho, aText, aProperties) {
aProperties.containsNick =
"incoming" in aProperties && this._pingRegexp.test(aText);
GenericConversationPrototype.writeMessage.apply(this, arguments);
}
},
};
var GenericConvChatBuddyPrototype = {
@ -715,7 +715,7 @@ var GenericConvChatBuddyPrototype = {
halfOp: false,
op: false,
founder: false,
typing: false
typing: false,
};
function TooltipInfo(aLabel, aValue, aType = Ci.prplITooltipInfo.pair) {
@ -780,10 +780,10 @@ purplePref.prototype = {
masked: false,
// Default value
getBool: function() { return this._defaultValue; },
getInt: function() { return this._defaultValue; },
getString: function() { return this._defaultValue; },
getList: function() {
getBool() { return this._defaultValue; },
getInt() { return this._defaultValue; },
getString() { return this._defaultValue; },
getList() {
// Convert a JavaScript object map {"value 1": "label 1", ...}
let keys = Object.keys(this._listValues);
if (!keys.length)
@ -793,7 +793,7 @@ purplePref.prototype = {
keys.map(key => new purpleKeyValuePair(this._listValues[key], key))
);
},
getListDefault: function() { return this._defaultValue; }
getListDefault() { return this._defaultValue; },
};
function purpleKeyValuePair(aName, aValue) {
@ -812,7 +812,7 @@ UsernameSplit.prototype = {
get label() { return this._values.label; },
get separator() { return this._values.separator; },
get defaultValue() { return this._values.defaultValue; },
get reverse() { return !!this._values.reverse; } // Ensure boolean
get reverse() { return !!this._values.reverse; }, // Ensure boolean
};
function ChatRoomField(aIdentifier, aField) {
@ -839,12 +839,12 @@ function ChatRoomFieldValues(aMap) {
ChatRoomFieldValues.prototype = {
__proto__: ClassInfo("prplIChatRoomFieldValues", "ChatRoomFieldValues"),
getValue: function(aIdentifier) {
getValue(aIdentifier) {
return this.values.hasOwnProperty(aIdentifier) ? this.values[aIdentifier] : null;
},
setValue: function(aIdentifier, aValue) {
setValue(aIdentifier, aValue) {
this.values[aIdentifier] = aValue;
}
},
};
// the name getter and the getAccount method need to be implemented by
@ -852,7 +852,7 @@ ChatRoomFieldValues.prototype = {
var GenericProtocolPrototype = {
__proto__: ClassInfo("prplIProtocol", "Generic protocol object"),
init: function(aId) {
init(aId) {
if (aId != this.id)
throw "Creating an instance of " + aId + " but this object implements " + this.id;
},
@ -862,14 +862,14 @@ var GenericProtocolPrototype = {
get normalizedName() { return this.name.replace(/[^a-z0-9]/gi, "").toLowerCase(); },
get iconBaseURI() { return "chrome://chat/skin/prpl-generic/"; },
getAccount: function(aImAccount) { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
getAccount(aImAccount) { throw Cr.NS_ERROR_NOT_IMPLEMENTED; },
_getOptionDefault: function(aName) {
_getOptionDefault(aName) {
if (this.options && this.options.hasOwnProperty(aName))
return this.options[aName].default;
throw aName + " has no default value in " + this.id + ".";
},
getOptions: function() {
getOptions() {
if (!this.options)
return EmptyEnumerator;
@ -878,7 +878,7 @@ var GenericProtocolPrototype = {
purplePrefs.push(new purplePref(name, option));
return new nsSimpleEnumerator(purplePrefs);
},
getUsernameSplit: function() {
getUsernameSplit() {
if (!this.usernameSplits || !this.usernameSplits.length)
return EmptyEnumerator;
@ -886,7 +886,7 @@ var GenericProtocolPrototype = {
this.usernameSplits.map(split => new UsernameSplit(split)));
},
registerCommands: function() {
registerCommands() {
if (!this.commands)
return;
@ -905,7 +905,7 @@ var GenericProtocolPrototype = {
// NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED errors are too noisy
get usernameEmptyText() { return ""; },
accountExists: () => false, //FIXME
accountExists: () => false, // FIXME
get uniqueChatName() { return false; },
get chatHasTopic() { return false; },
@ -919,5 +919,5 @@ var GenericProtocolPrototype = {
get usePurpleProxy() { return false; },
get classDescription() { return this.name + " Protocol"; },
get contractID() { return "@mozilla.org/chat/" + this.normalizedName + ";1"; }
get contractID() { return "@mozilla.org/chat/" + this.normalizedName + ";1"; },
};

Просмотреть файл

@ -158,8 +158,8 @@ var Socket = {
// It connects to aHost and aPort, but uses aOriginHost and aOriginPort for
// checking the certificate for them (see nsIRoutedSocketTransportService
// in nsISocketTransportService.idl).
connect: function(aOriginHost, aOriginPort, aSecurity, aProxy,
aHost = aOriginHost, aPort = aOriginPort) {
connect(aOriginHost, aOriginPort, aSecurity, aProxy,
aHost = aOriginHost, aPort = aOriginPort) {
if (Services.io.offline)
throw Cr.NS_ERROR_FAILURE;
@ -196,7 +196,7 @@ var Socket = {
// This will return null when the result is known immediately and
// the callback will just be dispatched to the current thread.
this._proxyCancel = proxyService.asyncResolve(uri, this.proxyFlags, this);
} catch(e) {
} catch (e) {
Cu.reportError(e);
// We had some error getting the proxy service, just don't use one.
this._createTransport(null);
@ -205,7 +205,7 @@ var Socket = {
},
// Disconnect all open streams.
disconnect: function() {
disconnect() {
this.LOG("Disconnect");
// Don't handle any remaining unhandled data.
@ -246,19 +246,19 @@ var Socket = {
// Send data on the output stream. Provide aLoggedData to log something
// different than what is actually sent.
sendData: function(/* string */ aData, aLoggedData = aData) {
sendData(/* string */ aData, aLoggedData = aData) {
this.LOG("Sending:\n" + aLoggedData);
try {
this._outputStream.write(aData, aData.length);
} catch(e) {
} catch (e) {
Cu.reportError(e);
}
},
// Send a string to the output stream after converting the encoding. Provide
// aLoggedData to log something different than what is actually sent.
sendString: function(aString, aEncoding = "UTF-8", aLoggedData = aString) {
sendString(aString, aEncoding = "UTF-8", aLoggedData = aString) {
this.LOG("Sending:\n" + aLoggedData);
let converter = new ScriptableUnicodeConverter();
@ -266,12 +266,12 @@ var Socket = {
try {
let stream = converter.convertToInputStream(aString);
this._outputStream.writeFrom(stream, stream.available());
} catch(e) {
} catch (e) {
Cu.reportError(e);
}
},
sendBinaryData: function(/* ArrayBuffer */ aData, aLoggedData) {
sendBinaryData(/* ArrayBuffer */ aData, aLoggedData) {
this.LOG("Sending binary data:\n" + (aLoggedData ||
"<" + ArrayBufferToHexString(aData) + ">"));
@ -279,21 +279,21 @@ var Socket = {
try {
// Send the data as a byte array
this._binaryOutputStream.writeByteArray(byteArray, byteArray.length);
} catch(e) {
} catch (e) {
Cu.reportError(e);
}
},
disconnected: true,
startTLS: function() {
startTLS() {
this.transport.securityInfo.QueryInterface(Ci.nsISSLSocketControl).StartTLS();
},
// If using the ping functionality, this should be called whenever a message is
// received (e.g. when it is known the socket is still open). Calling this for
// the first time enables the ping functionality.
resetPingTimer: function() {
resetPingTimer() {
// Clearing and setting timeouts is expensive, so we do it at most
// once per eventloop spin cycle.
if (this._resetPingTimerPending)
@ -303,7 +303,7 @@ var Socket = {
},
kTimeBeforePing: 120000, // 2 min
kTimeAfterPingBeforeDisconnect: 30000, // 30 s
_delayedResetPingTimer: function() {
_delayedResetPingTimer() {
if (!this._resetPingTimerPending)
return;
delete this._resetPingTimerPending;
@ -315,7 +315,7 @@ var Socket = {
// If using the ping functionality, this should be called when a ping receives
// a response.
cancelDisconnectTimer: function() {
cancelDisconnectTimer() {
if (!this._disconnectTimer)
return;
clearTimeout(this._disconnectTimer);
@ -325,7 +325,7 @@ var Socket = {
// Plenty of time may have elapsed if the computer wakes from sleep, so check
// if we should reconnect immediately.
_lastAliveTime: null,
observe: function(aSubject, aTopic, aData) {
observe(aSubject, aTopic, aData) {
if (aTopic != "wake_notification")
return;
let elapsedTime = Date.now() - this._lastAliveTime;
@ -354,7 +354,7 @@ var Socket = {
/*
* nsIProtocolProxyCallback methods
*/
onProxyAvailable: function(aRequest, aURI, aProxyInfo, aStatus) {
onProxyAvailable(aRequest, aURI, aProxyInfo, aStatus) {
if (!("_proxyCancel" in this)) {
this.LOG("onProxyAvailable called, but disconnect() was called before.");
return;
@ -379,7 +379,7 @@ var Socket = {
*/
// onDataAvailable, called by Mozilla's networking code.
// Buffers the data, and parses it into discrete messages.
onDataAvailable: function(aRequest, aContext, aInputStream, aOffset, aCount) {
onDataAvailable(aRequest, aContext, aInputStream, aOffset, aCount) {
if (this.disconnected)
return;
this._lastAliveTime = Date.now();
@ -429,14 +429,14 @@ var Socket = {
_pendingData: [],
_handlingQueue: false,
_activateQueue: function() {
_activateQueue() {
if (this._handlingQueue)
return;
this._handlingQueue =
this.window.requestIdleCallback(this._handleQueue.bind(this));
},
// Asynchronously send each string to the handle data function.
_handleQueue: function(timing) {
_handleQueue(timing) {
while (this._pendingData.length) {
this.onDataReceived(this._pendingData.shift());
// One pendingData entry generally takes less than 1ms to handle.
@ -458,7 +458,7 @@ var Socket = {
* nsIRequestObserver methods
*/
// Signifies the beginning of an async request
onStartRequest: function(aRequest, aContext) {
onStartRequest(aRequest, aContext) {
if (this.disconnected) {
// Ignore this if we're already disconnected.
return;
@ -466,7 +466,7 @@ var Socket = {
this.DEBUG("onStartRequest");
},
// Called to signify the end of an asynchronous request.
onStopRequest: function(aRequest, aContext, aStatus) {
onStopRequest(aRequest, aContext, aStatus) {
if (this.disconnected) {
// We're already disconnected, so nothing left to do here.
return;
@ -478,7 +478,7 @@ var Socket = {
this._activateQueue();
},
// Close the connection after receiving a stop request.
_handleStopRequest: function(aStatus) {
_handleStopRequest(aStatus) {
if (this.disconnected)
return;
this.disconnected = true;
@ -507,7 +507,7 @@ var Socket = {
*/
// Called when there's an error, return true to suppress the modal alert.
// Whatever this function returns, NSS will close the connection.
notifyCertProblem: function(aSocketInfo, aSecInfo, aTargetSite) {
notifyCertProblem(aSocketInfo, aSecInfo, aTargetSite) {
this.secInfo = aSecInfo;
return true;
},
@ -515,7 +515,7 @@ var Socket = {
/*
* nsITransportEventSink methods
*/
onTransportStatus: function(aTransport, aStatus, aProgress, aProgressmax) {
onTransportStatus(aTransport, aStatus, aProgress, aProgressmax) {
// Don't send status change notifications after the socket has been closed.
// The event sink can't be removed after opening the transport, so we can't
// do better than adding a null check here.
@ -529,10 +529,10 @@ var Socket = {
0x804b0004: "STATUS_CONNECTED_TO",
0x804b0005: "STATUS_SENDING_TO",
0x804b000a: "STATUS_WAITING_FOR",
0x804b0006: "STATUS_RECEIVING_FROM"
0x804b0006: "STATUS_RECEIVING_FROM",
};
let status = nsITransportEventSinkStatus[aStatus];
this.DEBUG("onTransportStatus(" + (status || ("0x" + aStatus.toString(16))) +")");
this.DEBUG("onTransportStatus(" + (status || ("0x" + aStatus.toString(16))) + ")");
if (status == "STATUS_CONNECTED_TO") {
// Notify that the connection has been established.
@ -545,12 +545,12 @@ var Socket = {
****************************** Private methods ******************************
*****************************************************************************
*/
_resetBuffers: function() {
_resetBuffers() {
this._incomingDataBuffer = this.binaryMode ? [] : "";
this._outgoingDataBuffer = [];
},
_createTransport: function(aProxy) {
_createTransport(aProxy) {
this.proxy = aProxy;
// Empty incoming and outgoing data storage buffers
@ -571,7 +571,7 @@ var Socket = {
},
// Open the incoming and outgoing streams, and init the nsISocketTransport.
_openStreams: function() {
_openStreams() {
// Security notification callbacks (must support nsIBadCertListener2
// for SSL connections, and possibly other interfaces).
this.transport.securityCallbacks = this;
@ -620,7 +620,7 @@ var Socket = {
_pingTimer: null,
_disconnectTimer: null,
_sendPing: function() {
_sendPing() {
delete this._pingTimer;
this.sendPing();
this._disconnectTimer = setTimeout(this.onConnectionTimedOut.bind(this),
@ -632,30 +632,30 @@ var Socket = {
********************* Methods for subtypes to override **********************
*****************************************************************************
*/
LOG: function(aString) { },
DEBUG: function(aString) { },
LOG(aString) { },
DEBUG(aString) { },
// Called when a connection is established.
onConnection: function() { },
onConnection() { },
// Called when a socket is accepted after listening.
onConnectionHeard: function() { },
onConnectionHeard() { },
// Called when a connection times out.
onConnectionTimedOut: function() { },
onConnectionTimedOut() { },
// Called when a socket request's network is reset.
onConnectionReset: function() { },
onConnectionReset() { },
// Called when the certificate provided by the server didn't satisfy NSS.
onBadCertificate: function(aNSSErrorMessage) { },
onBadCertificate(aNSSErrorMessage) { },
// Called when the other end has closed the connection.
onConnectionClosed: function() { },
onConnectionClosed() { },
// Called when ASCII data is available.
onDataReceived: function(/* string */ aData) { },
onDataReceived(/* string */ aData) { },
// Called when binary data is available.
onBinaryDataReceived: function(/* ArrayBuffer */ aData) { },
onBinaryDataReceived(/* ArrayBuffer */ aData) { },
// If using the ping functionality, this is called when a new ping message
// should be sent on the socket.
sendPing: function() { },
sendPing() { },
/* QueryInterface and nsIInterfaceRequestor implementations */
QueryInterface: ChromeUtils.generateQI(["nsIStreamListener",
@ -664,5 +664,5 @@ var Socket = {
"nsIBadCertListener2",
"nsIProtocolProxyCallback"]),
getInterface: function(iid) { return this.QueryInterface(iid); }
getInterface(iid) { return this.QueryInterface(iid); },
};

Просмотреть файл

@ -37,7 +37,7 @@ function test_plainText() {
"foo",
"foo ", // preserve trailing whitespace
" foo", // preserve leading indent
"&lt;html&gt;&amp;" // keep escaped characters
"&lt;html&gt;&amp;", // keep escaped characters
];
for (let string of strings)
Assert.equal(string, cleanupImMarkup(string));
@ -47,7 +47,7 @@ function test_paragraphs() {
const strings = [
"<p>foo</p><p>bar</p>",
"<p>foo<br>bar</p>",
"foo<br>bar"
"foo<br>bar",
];
for (let string of strings)
Assert.equal(string, cleanupImMarkup(string));
@ -70,7 +70,7 @@ function test_links() {
"http://example.com/",
"https://example.com/",
"ftp://example.com/",
"mailto:foo@example.com"
"mailto:foo@example.com",
];
for (let string of ok) {
string = "<a href=\"" + string + "\">foo</a>";
@ -83,7 +83,7 @@ function test_links() {
"about:",
"about:blank",
"foo://bar/",
""
"",
];
for (let string of bad) {
Assert.equal("<a>foo</a>",
@ -151,7 +151,7 @@ function test_standardMode() {
const okCSS = [
"font-style: italic",
"font-weight: bold"
"font-weight: bold",
];
for (let css of okCSS) {
let string = "<span style=\"" + css + "\">foo</span>";
@ -168,7 +168,7 @@ function test_standardMode() {
"-moz-binding: url('chrome://global/content/bindings/textbox.xml#textbox');",
"display: none",
"visibility: hidden",
"unsupported-by-gecko: blah"
"unsupported-by-gecko: blah",
];
for (let css of badCSS) {
Assert.equal("<span>foo</span>",
@ -203,7 +203,7 @@ function test_permissiveMode() {
const fontAttributes = [
"face=\"Times\"",
"color=\"pink\"",
"size=\"3\""
"size=\"3\"",
];
for (let fontAttribute of fontAttributes) {
let string = "<font " + fontAttribute + ">foo</font>";
@ -221,7 +221,7 @@ function test_permissiveMode() {
"text-decoration: underline",
"color: pink;",
"font-family: Times",
"font-size: larger"
"font-size: larger",
];
for (let css of okCSS) {
let string = "<span style=\"" + css + "\">foo</span>";
@ -239,7 +239,7 @@ function test_permissiveMode() {
"-moz-binding: url('chrome://global/content/bindings/textbox.xml#textbox');",
"display: none",
"visibility: hidden",
"unsupported-by-gecko: blah"
"unsupported-by-gecko: blah",
];
for (let css of badCSS) {
Assert.equal("<span>foo</span>",
@ -327,19 +327,19 @@ function test_createDerivedRuleset() {
let string = "<hr>";
Assert.equal("", cleanupImMarkup(string));
Assert.equal("", cleanupImMarkup(string, rules));
rules.tags["hr"] = true;
rules.tags.hr = true;
Assert.equal(string, cleanupImMarkup(string, rules));
string = "<br id=\"123\">";
Assert.equal("<br>", cleanupImMarkup(string));
Assert.equal("<br>", cleanupImMarkup(string, rules));
rules.attrs["id"] = true;
rules.attrs.id = true;
Assert.equal(string, cleanupImMarkup(string, rules));
string = "<br style=\"clear: both;\">";
Assert.equal("<br>", cleanupImMarkup(string));
Assert.equal("<br>", cleanupImMarkup(string, rules));
rules.styles["clear"] = true;
rules.styles.clear = true;
Assert.equal(string, cleanupImMarkup(string, rules));
run_next_test();