[tor-commits] [tor-messenger-build/master] Remove upstreamed patches

arlo at torproject.org arlo at torproject.org
Mon Jan 5 19:52:38 UTC 2015


commit 3b5da55f65f6ac0dc4bc348240e4b3897860e4f9
Author: Arlo Breault <arlolra at gmail.com>
Date:   Mon Jan 5 11:50:34 2015 -0800

    Remove upstreamed patches
    
     * These were merged in,
       https://hg.mozilla.org/comm-central/rev/90bc651566be
       https://hg.mozilla.org/comm-central/rev/d6f2f1a42c74
       https://hg.mozilla.org/users/florian_queze.net/purple/rev/d44192a91176
---
 projects/instantbird/config                        |    2 -
 .../prepare-messages-for-displaying.patch          |  288 ---------------
 projects/instantbird/test-transformation-api.patch |  367 --------------------
 3 files changed, 657 deletions(-)

diff --git a/projects/instantbird/config b/projects/instantbird/config
index 66a2a99..cbae1a1 100644
--- a/projects/instantbird/config
+++ b/projects/instantbird/config
@@ -58,8 +58,6 @@ input_files:
     pkg_type: src
   - filename: spi-cacert.der
   - filename: preferences.patch
-  - filename: prepare-messages-for-displaying.patch
-  - filename: test-transformation-api.patch
   - filename: slashme.patch
   - filename: irc.patch
   - filename: xmpp.patch
diff --git a/projects/instantbird/prepare-messages-for-displaying.patch b/projects/instantbird/prepare-messages-for-displaying.patch
deleted file mode 100644
index c9dc42b..0000000
--- a/projects/instantbird/prepare-messages-for-displaying.patch
+++ /dev/null
@@ -1,288 +0,0 @@
-# HG changeset patch
-# User Arlo Breault <arlolra at gmail.com>
-# Date 1417196598 28800
-#      Fri Nov 28 09:43:18 2014 -0800
-# Node ID ddcfdad3c07c6304ce3de53f38ba0adec98ea53a
-# Parent  523fa3fa1fd619423f7267fdd2b3b215bcb93d1b
-Prepare messages for displaying
-
- * Adds a converse method to prepareForSending.
-
-Bug: 1071166
-
-diff --git a/chat/components/public/imIConversationsService.idl b/chat/components/public/imIConversationsService.idl
---- a/chat/components/public/imIConversationsService.idl
-+++ b/chat/components/public/imIConversationsService.idl
-@@ -64,16 +64,21 @@ interface imIConversationsService: nsISu
- 
-   nsISimpleEnumerator getConversations();
-   prplIConversation getConversationById(in unsigned long aId);
-   prplIConversation getConversationByNameAndAccount(in AUTF8String aName,
-                                                     in imIAccount aAccount,
-                                                     in boolean aIsChat);
- };
- 
-+// Because of limitations in libpurple (write_conv is called without context),
-+// there's an implicit contract that whatever message string the conversation
-+// service passes to a protocol, it'll get back as the originalMessage when
-+// "new-text" is notified. This is required for the OTR extensions to work.
-+
- // A cancellable outgoing message. Before handing a message off to a protocol,
- // the conversation service notifies observers (typically add-ons) of an
- // outgoing message, which can be transformed or cancelled.
- [scriptable, uuid(4391ba5c-9566-41a9-bb9b-fd0a0a490c2c)]
- interface imIOutgoingMessage: nsISupports {
-            attribute AUTF8String message;
-            attribute boolean cancelled;
-   readonly attribute prplIConversation conversation;
-diff --git a/chat/components/public/prplIConversation.idl b/chat/components/public/prplIConversation.idl
---- a/chat/components/public/prplIConversation.idl
-+++ b/chat/components/public/prplIConversation.idl
-@@ -5,16 +5,17 @@
- 
- #include "nsISupports.idl"
- #include "nsISimpleEnumerator.idl"
- #include "nsIObserver.idl"
- 
- interface prplIAccountBuddy;
- interface imIAccount;
- interface imIOutgoingMessage;
-+interface imIMessage;
- interface nsIURI;
- interface nsIDOMDocument;
- interface prplIChatRoomFieldValues;
- 
- /*
-  * This is the XPCOM purple conversation component, a proxy for PurpleConversation.
-  */
- 
-@@ -47,16 +48,21 @@ interface prplIConversation: nsISupports
-   void sendMsg(in AUTF8String aMsg);
- 
-   /* Preprocess messages before they are sent (eg. split long messages).
-      Can return null if no changes are to be made. */
-   void prepareForSending(in imIOutgoingMessage aMsg,
-                          [optional] out unsigned long aMsgCount,
-                          [retval, array, size_is(aMsgCount)] out wstring aMsgs);
- 
-+  /* Postprocess messages before they are displayed (eg. escaping). The
-+     implementation can set aMsg.displayMessage, otherwise the originalMessage
-+     is used. */
-+  void prepareForDisplaying(in imIMessage aMsg);
-+
-   /* Send information about the current typing state to the server.
-      aString should contain the content currently in the text field. The
-      protocol should return the number of characters that can still be typed. */
-   long sendTyping(in AUTF8String aString);
-   const long NO_TYPING_LIMIT = 2147483647; // max int = 2 ^ 31 - 1
- 
-   /* Un-initialize the conversation. Will be called by
-      purpleCoreService::RemoveConversation when the conversation is
-diff --git a/chat/components/src/imConversations.js b/chat/components/src/imConversations.js
---- a/chat/components/src/imConversations.js
-+++ b/chat/components/src/imConversations.js
-@@ -403,16 +403,17 @@ UIConversation.prototype = {
-     this._observers = this._observers.filter(function(o) o !== aObserver);
-   },
-   notifyObservers: function(aSubject, aTopic, aData) {
-     if (aTopic == "new-text") {
-       aSubject = new imMessage(aSubject);
-       this.notifyObservers(aSubject, "received-message");
-       if (aSubject.cancelled)
-         return;
-+      aSubject.conversation.prepareForDisplaying(aSubject);
- 
-       this._messages.push(aSubject);
-       ++this._unreadMessageCount;
-       if (aSubject.incoming && !aSubject.system) {
-         ++this._unreadIncomingMessageCount;
-         if (!this.isChat || aSubject.containsNick)
-           ++this._unreadTargetedMessageCount;
-       }
-@@ -430,16 +431,21 @@ UIConversation.prototype = {
-       if (aSubject.incoming && !aSubject.system &&
-           (!this.isChat || aSubject.containsNick)) {
-         this.notifyObservers(aSubject, "new-directed-incoming-message", aData);
-         Services.obs.notifyObservers(aSubject, "new-directed-incoming-message", aData);
-       }
-     }
-   },
- 
-+  // Used above when notifying of new-texts originating in the
-+  // UIConversation. The happens when this.systemMessage() is called. The
-+  // conversation for the message is set as the UIConversation. 
-+  prepareForDisplaying: function(aMsg) {},
-+
-   // prplIConvIM
-   get buddy() this.target.buddy,
-   get typingState() this.target.typingState,
-   sendTyping: function(aString) this.target.sendTyping(aString),
- 
-   // Chat only
-   getParticipants: function() this.target.getParticipants(),
-   get topic() this.target.topic,
-diff --git a/chat/modules/jsProtoHelper.jsm b/chat/modules/jsProtoHelper.jsm
---- a/chat/modules/jsProtoHelper.jsm
-+++ b/chat/modules/jsProtoHelper.jsm
-@@ -477,16 +477,17 @@ const GenericConversationPrototype = {
-         observer.observe(aSubject, aTopic, aData);
-       } catch(e) {
-         this.ERROR(e);
-       }
-     }
-   },
- 
-   prepareForSending: function(aOutgoingMessage, aCount) null,
-+  prepareForDisplaying: function(aImMessage) {},
-   sendMsg: function(aMsg) {
-     throw Cr.NS_ERROR_NOT_IMPLEMENTED;
-   },
-   sendTyping: function(aString) Ci.prplIConversation.NO_TYPING_LIMIT,
- 
-   close: function() {
-     Services.obs.notifyObservers(this, "closing-conversation", null);
-     Services.conversations.removeConversation(this);
-diff --git a/chat/protocols/irc/irc.js b/chat/protocols/irc/irc.js
---- a/chat/protocols/irc/irc.js
-+++ b/chat/protocols/irc/irc.js
-@@ -126,16 +126,20 @@ const GenericIRCConversation = {
-   getMaxMessageLength: function() {
-     // Build the shortest possible message that could be sent to other users.
-     let baseMessage = ":" + this._account._nickname + this._account.prefix +
-                       " " + this._account.buildMessage("PRIVMSG", this.name) +
-                       " :\r\n";
-     return this._account.maxMessageLength -
-            this._account.countBytes(baseMessage);
-   },
-+  // Apply CTCP formatting before displaying.
-+  prepareForDisplaying: function(aMsg) {
-+    aMsg.displayMessage = ctcpFormatToHTML(aMsg.displayMessage);
-+  },
-   prepareForSending: function(aOutgoingMessage, aCount) {
-     // Split the message by line breaks and send each one individually.
-     let messages = aOutgoingMessage.message.split(/[\r\n]+/);
- 
-     let maxLength = this.getMaxMessageLength();
- 
-     // Attempt to smartly split a string into multiple lines (based on the
-     // maximum number of characters the message can contain).
-@@ -274,24 +278,16 @@ ircChannel.prototype = {
-   _receivedInitialMode: false,
-   // For IRC you're not in a channel until the JOIN command is received, open
-   // all channels (initially) as left.
-   _left: true,
-   // True while we are rejoining a channel previously parted by the user.
-   _rejoined: false,
-   banMasks: [],
- 
--  // Overwrite the writeMessage function to apply CTCP formatting before
--  // display.
--  writeMessage: function(aWho, aText, aProperties) {
--    GenericConvChatPrototype.writeMessage.call(this, aWho,
--                                               ctcpFormatToHTML(aText),
--                                               aProperties);
--  },
--
-   // Section 3.2.2 of RFC 2812.
-   part: function(aMessage) {
-     let params = [this.name];
- 
-     // If a valid message was given, use it as the part message.
-     // Otherwise, fall back to the default part message, if it exists.
-     let msg = aMessage || this._account.getString("partmsg");
-     if (msg)
-@@ -595,24 +591,16 @@ function ircConversation(aAccount, aName
-   // Always request the info as it may be out of date.
-   this._waitingForNick = true;
-   this.requestBuddyInfo(aName);
- }
- ircConversation.prototype = {
-   __proto__: GenericConvIMPrototype,
-   get buddy() this._account.buddies.get(this.name),
- 
--  // Overwrite the writeMessage function to apply CTCP formatting before
--  // display.
--  writeMessage: function(aWho, aText, aProperties) {
--    GenericConvIMPrototype.writeMessage.call(this, aWho,
--                                             ctcpFormatToHTML(aText),
--                                             aProperties);
--  },
--
-   unInit: function() {
-     this.unInitIRCConversation();
-     GenericConvIMPrototype.unInit.call(this);
-   },
- 
-   updateNick: function(aNewNick) {
-     this._name = aNewNick;
-     this.notifyObservers(null, "update-conv-title");
-diff --git a/chat/protocols/xmpp/xmpp.jsm b/chat/protocols/xmpp/xmpp.jsm
---- a/chat/protocols/xmpp/xmpp.jsm
-+++ b/chat/protocols/xmpp/xmpp.jsm
-@@ -32,16 +32,21 @@ XPCOMUtils.defineLazyServiceGetter(this,
- XPCOMUtils.defineLazyServiceGetter(this, "UuidGenerator",
-                                    "@mozilla.org/uuid-generator;1",
-                                    "nsIUUIDGenerator");
- 
- XPCOMUtils.defineLazyGetter(this, "_", function()
-   l10nHelper("chrome://chat/locale/xmpp.properties")
- );
- 
-+XPCOMUtils.defineLazyGetter(this, "TXTToHTML", function() {
-+  let cs = Cc["@mozilla.org/txttohtmlconv;1"].getService(Ci.mozITXTToHTMLConv);
-+  return function(aTxt) cs.scanTXT(aTxt, cs.kEntities);
-+});
-+
- /* This is an ordered list, used to determine chat buddy flags:
-  *  index < member    -> noFlags
-  *  index = member    -> voiced
-  *          moderator -> halfOp
-  *          admin     -> op
-  *          owner     -> founder
-  */
- const kRoles = ["outcast", "visitor", "participant", "member", "moderator",
-@@ -255,16 +260,23 @@ const XMPPConversationPrototype = {
-       who = this._account._connection._jid.jid;
-     if (!who)
-       who = this._account.name;
-     let alias = this.account.alias || this.account.statusInfo.displayName;
-     this.writeMessage(who, aMsg, {outgoing: true, _alias: alias});
-     delete this._typingState;
-   },
- 
-+  /* Perform entity escaping before displaying the message. We assume incoming
-+     messages have already been escaped, and will otherwise be filtered. */
-+  prepareForDisplaying: function(aMsg) {
-+    if (aMsg.outgoing && !aMsg.system)
-+      aMsg.displayMessage = TXTToHTML(aMsg.displayMessage);
-+  },
-+
-   /* Called by the account when a messsage is received from the buddy */
-   incomingMessage: function(aMsg, aStanza, aDate) {
-     let from = aStanza.attributes["from"];
-     this._targetResource = this._account._parseJID(from).resource;
-     let flags = {};
-     if (aStanza.attributes["type"] == "error") {
-       aMsg = _("conversation.error.notDelivered", aMsg);
-       flags.system = true;
-@@ -889,19 +901,17 @@ const XMPPAccountPrototype = {
-       // Prefer HTML (in <html><body>) and use plain text (<body>) as fallback.
-       let htmlBody = aStanza.getElement(["html", "body"]);
-       if (htmlBody)
-         body = htmlBody.innerXML;
-       else {
-         // Even if the message is in plain text, the prplIMessage
-         // should contain a string that's correctly escaped for
-         // insertion in an HTML document.
--        body = Cc["@mozilla.org/txttohtmlconv;1"]
--                 .getService(Ci.mozITXTToHTMLConv)
--                 .scanTXT(b.innerText, Ci.mozITXTToHTMLConv.kEntities);
-+        body = TXTToHTML(b.innerText);
-       }
-     }
-     if (body) {
-       let date;
-       let delay = aStanza.getElement(["delay"]);
-       if (delay && delay.uri == Stanza.NS.delay) {
-         if (delay.attributes["stamp"])
-           date = new Date(delay.attributes["stamp"]);
diff --git a/projects/instantbird/test-transformation-api.patch b/projects/instantbird/test-transformation-api.patch
deleted file mode 100644
index f43fcbc..0000000
--- a/projects/instantbird/test-transformation-api.patch
+++ /dev/null
@@ -1,367 +0,0 @@
-# HG changeset patch
-# User Arlo Breault <arlolra at gmail.com>
-# Date 1414370632 25200
-#      Sun Oct 26 17:43:52 2014 -0700
-# Node ID 49fc79e39b9c292d182a46aa800135bd65b6c38f
-# Parent  030063bcb41284997f862b9b2d12e93bfc0b121a
-Add tests for new messaging pipeline
-
- * Tests for bugs 1071166, 1088772, and 983347.
-
-diff --git a/chat/components/public/imIConversationsService.idl b/chat/components/public/imIConversationsService.idl
---- a/chat/components/public/imIConversationsService.idl
-+++ b/chat/components/public/imIConversationsService.idl
-@@ -70,29 +70,31 @@ interface imIConversationsService: nsISu
- };
- 
- // Because of limitations in libpurple (write_conv is called without context),
- // there's an implicit contract that whatever message string the conversation
- // service passes to a protocol, it'll get back as the originalMessage when
- // "new-text" is notified. This is required for the OTR extensions to work.
- 
- // A cancellable outgoing message. Before handing a message off to a protocol,
--// the conversation service notifies observers (typically add-ons) of an
--// outgoing message, which can be transformed or cancelled.
-+// the conversation service notifies observers of `preparing-message` and
-+// `sending-message` (typically add-ons) of an outgoing message, which can be
-+// transformed or cancelled.
- [scriptable, uuid(4391ba5c-9566-41a9-bb9b-fd0a0a490c2c)]
- interface imIOutgoingMessage: nsISupports {
-            attribute AUTF8String message;
-            attribute boolean cancelled;
-   readonly attribute prplIConversation conversation;
- };
- 
- // A cancellable message to be displayed. When the conversation service is
--// notified of a new-text (ie. an incoming or outgoing message to be displayed),
--// it in turn notifies observers (again, typically add-ons), which have the
--// opportunity to swap or cancel the message.
-+// notified of a `new-text` (ie. an incoming or outgoing message to be
-+// displayed), it in turn notifies observers of `received-message`
-+// (again, typically add-ons), which have the opportunity to swap or cancel
-+// the message.
- [scriptable, uuid(3f88cc5c-6940-4eb5-a576-c65770f49ce9)]
- interface imIMessage: prplIMessage {
-            attribute boolean cancelled;
-            // Holds the sender color for Chats.
-            // Empty string by default, it is set by the conversation binding.
-            attribute AUTF8String color;
- 
-            // What eventually gets shown to the user.
-diff --git a/chat/components/src/imConversations.js b/chat/components/src/imConversations.js
---- a/chat/components/src/imConversations.js
-+++ b/chat/components/src/imConversations.js
-@@ -59,16 +59,17 @@ imMessage.prototype = {
-   get containsNick() this.prplMessage.containsNick,
-   get noLog() this.prplMessage.noLog,
-   get error() this.prplMessage.error,
-   get delayed() this.prplMessage.delayed,
-   get noFormat() this.prplMessage.noFormat,
-   get containsImages() this.prplMessage.containsImages,
-   get notification() this.prplMessage.notification,
-   get noLinkification() this.prplMessage.noLinkification,
-+  get originalMessage() this.prplMessage.originalMessage,
-   getActions: function(aCount) this.prplMessage.getActions(aCount || {})
- };
- 
- function UIConversation(aPrplConversation)
- {
-   this._prplConv = {};
-   this.id = ++gLastUIConvId;
-   this._observers = [];
-@@ -120,17 +121,21 @@ UIConversation.prototype = {
-   _currentTargetId: 0,
-   changeTargetTo: function(aPrplConversation) {
-     let id = aPrplConversation.id;
-     if (this._currentTargetId == id)
-       return;
- 
-     if (!(id in this._prplConv)) {
-       this._prplConv[id] = aPrplConversation;
--      aPrplConversation.addObserver(this.observeConv.bind(this, id));
-+      // Pass an object here, instead of just a function, because coercion
-+      // to an nsIObserver won't happen in the JS tests.
-+      aPrplConversation.addObserver({
-+        observe: this.observeConv.bind(this, id)
-+      });
-     }
- 
-     let shouldNotify = this._currentTargetId;
-     this._currentTargetId = id;
-     if (!this.isChat) {
-       let buddy = this.buddy;
-       if (buddy)
-         ({statusType: this.statusType, statusText: this.statusText}) = buddy;
-@@ -356,17 +361,17 @@ UIConversation.prototype = {
- 
-     // Protocols have an opportunity here to preprocess messages before they are
-     // sent (eg. split long messages). If a message is split here, the split
-     // will be visible in the UI.
-     let messages = this.target.prepareForSending(om);
- 
-     // Protocols can return null if they don't need to make any changes.
-     // (nb. passing null with retval array results in an empty array)
--    if (!messages.length)
-+    if (!messages || !messages.length)
-       messages = [om.message];
- 
-     for (let msg of messages) {
-       // Add-ons (eg. OTR) have an opportunity to tweak or cancel the message
-       // at this point.
-       om = new OutgoingMessage(msg, this.target);
-       this.notifyObservers(om, "sending-message");
-       if (om.cancelled)
-diff --git a/chat/components/src/test/test_conversations.js b/chat/components/src/test/test_conversations.js
-new file mode 100644
---- /dev/null
-+++ b/chat/components/src/test/test_conversations.js
-@@ -0,0 +1,235 @@
-+/* Any copyright is dedicated to the Public Domain.
-+ * http://creativecommons.org/publicdomain/zero/1.0/ */
-+
-+const Cu = Components.utils;
-+Cu.import("resource:///modules/imServices.jsm");
-+Cu.import("resource:///modules/jsProtoHelper.jsm");
-+
-+let imConversations = {};
-+Services.scriptloader.loadSubScript(
-+  "resource:///components/imConversations.js", imConversations
-+);
-+
-+// Fake prplConversation
-+let _id = 0;
-+function Conversation(aName) {
-+  this._name = aName;
-+  this._observers = [];
-+  this._date = Date.now() * 1000;
-+  this.id = ++_id;
-+}
-+Conversation.prototype = {
-+  __proto__: GenericConvIMPrototype,
-+  _account: {
-+    imAccount: {
-+      protocol: {name: "Fake Protocol"},
-+      alias: "",
-+      name: "Fake Account"
-+    },
-+    ERROR: function(e) {throw e;}
-+  }
-+};
-+
-+// Ensure that when iMsg.message is set to a message (including the empty
-+// string), it returns that message. If not, it should return the original
-+// message. This prevents regressions due to JS coercions.
-+let test_null_message = function() {
-+  let originalMessage = "Hi!";
-+  let pMsg = new Message("buddy", originalMessage, {
-+    outgoing: true, _alias: "buddy", time: Date.now()
-+  });
-+  let iMsg = new imConversations.imMessage(pMsg);
-+  equal(iMsg.message, originalMessage);
-+  // Setting the message should prevent a fallback to the original.
-+  iMsg.message = "";
-+  equal(iMsg.message, "");
-+  equal(iMsg.originalMessage, originalMessage);
-+};
-+
-+// ROT13, used as an example transformation.
-+function rot13(aString) {
-+  return aString.replace(/[a-zA-Z]/g, function(c) {
-+    return String.fromCharCode(c.charCodeAt(0) + (c.toLowerCase() < "n" ? 1 : -1) * 13);
-+  });
-+}
-+
-+// A test that exercises the message transformation pipeline.
-+//
-+// From the sending users perspective, this looks like:
-+//   -> UIConv sendMsg
-+//   -> UIConv notifyObservers `preparing-message`
-+//   -> protocol prepareForSending
-+//   -> UIConv notifyObservers `sending-message`
-+//   -> protocol sendMsg
-+//   -> protocol writeMessage
-+//   -> protocol notifyObservers `new-text`
-+//   -> UIConv notifyObservers `received-message`
-+//   -> protocol prepareForDisplaying
-+//   -> UIConv notifyObservers `new-text`
-+//
-+// From the receiving users perspective, they get:
-+//   -> protocol writeMessage
-+//   -> protocol notifyObservers `new-text`
-+//   -> UIConv notifyObservers `received-message`
-+//   -> protocol prepareForDisplaying
-+//   -> UIConv notifyObservers `new-text`
-+//
-+// The test walks the sending path, which covers both.
-+let test_message_transformation = function() {
-+  let conv = new Conversation();
-+  conv.sendMsg = function(aMsg) {
-+    this.writeMessage("user", aMsg, {outgoing: true});
-+  };
-+
-+  let uiConv = new imConversations.UIConversation(conv);
-+  let message = "Hello!";
-+  let receivedMsg = false, newTxt = false;
-+
-+  uiConv.addObserver({
-+    observe: function(aObject, aTopic, aMsg) {
-+      switch(aTopic) {
-+        case "sending-message":
-+          ok(!newTxt);
-+          ok(!receivedMsg);
-+          ok(aObject instanceof imConversations.OutgoingMessage);
-+          aObject.message = rot13(aObject.message);
-+          break;
-+        case "received-message":
-+          ok(!newTxt);
-+          ok(!receivedMsg);
-+          ok(aObject.outgoing);
-+          ok(aObject instanceof imConversations.imMessage);
-+          equal(aObject.displayMessage, rot13(message));
-+          aObject.displayMessage = rot13(aObject.displayMessage);
-+          receivedMsg = true;
-+          break;
-+        case "new-text":
-+          ok(!newTxt);
-+          ok(receivedMsg);
-+          ok(aObject.outgoing);
-+          ok(aObject instanceof imConversations.imMessage);
-+          equal(aObject.displayMessage, message);
-+          newTxt = true;
-+          break;
-+      }
-+    }
-+  });
-+  uiConv.sendMsg(message);
-+
-+  ok(newTxt);
-+};
-+
-+// A test that cancels a message before it can be sent.
-+let test_cancel_send_message = function() {
-+    let conv = new Conversation();
-+    conv.sendMsg = function(aMsg) {
-+      ok(false);
-+    };
-+
-+    let uiConv = new imConversations.UIConversation(conv);
-+    uiConv.addObserver({
-+      observe: function(aObject, aTopic, aMsg) {
-+        if (aTopic === "sending-message") {
-+          ok(aObject instanceof imConversations.OutgoingMessage);
-+          aObject.cancelled = true;
-+        }
-+      }
-+    });
-+    uiConv.sendMsg("Hi!");
-+};
-+
-+// A test that cancels a message before it gets displayed.
-+let test_cancel_display_message = function() {
-+    let conv = new Conversation();
-+    conv.sendMsg = function(aMsg) {
-+      this.writeMessage("user", aMsg, {outgoing: true});
-+    };
-+
-+    let uiConv = new imConversations.UIConversation(conv);
-+    uiConv.addObserver({
-+      observe: function(aObject, aTopic, aMsg) {
-+        switch(aTopic) {
-+          case "received-message":
-+            ok(aObject instanceof imConversations.imMessage);
-+            aObject.cancelled = true;
-+            break;
-+          case "new-text":
-+            ok(false);
-+            break;
-+        }
-+      }
-+    });
-+    uiConv.sendMsg("Hi!");
-+};
-+
-+// A test that ensures protocols get a chance to prepare a message before
-+// sending and displaying.
-+let test_prpl_message_prep = function() {
-+    let conv = new Conversation();
-+    conv.sendMsg = function(aMsg) {
-+      this.writeMessage("user", aMsg, {outgoing: true});
-+    };
-+
-+    let msg = "Hi!";
-+    let prefix = "test> ";
-+
-+    let prepared = false;
-+    conv.prepareForSending = function(aMsg) {
-+      ok(aMsg instanceof imConversations.OutgoingMessage);
-+      equal(aMsg.message, msg);
-+      aMsg.message = prefix + aMsg.message;
-+      prepared = true;
-+    };
-+
-+    conv.prepareForDisplaying = function(aMsg) {
-+      ok(aMsg instanceof imConversations.imMessage);
-+      equal(aMsg.displayMessage, prefix + msg);
-+      aMsg.displayMessage = aMsg.displayMessage.slice(prefix.length);
-+    };
-+
-+    let receivedMsg = false;
-+    let uiConv = new imConversations.UIConversation(conv);
-+    uiConv.addObserver({
-+      observe: function(aObject, aTopic, aMsg) {
-+        if (aTopic === "new-text") {
-+          equal(aObject.displayMessage, msg);
-+          receivedMsg = true;
-+        }
-+      }
-+    });
-+    uiConv.sendMsg(msg);
-+    ok(prepared);
-+    ok(receivedMsg);
-+};
-+
-+// A test that ensures protocols can split messages before they are sent.
-+let test_split_message_before_sending = function() {
-+    let msgCount = 0;
-+    let prepared = false;
-+
-+    let conv = new Conversation();
-+    conv.sendMsg = function(aMsg) {
-+      ++msgCount;
-+    };
-+    conv.prepareForSending = function(aMsg) {
-+      ok(aMsg instanceof imConversations.OutgoingMessage);
-+      prepared = true;
-+      return aMsg.message.split("\n");
-+    };
-+
-+    let uiConv = new imConversations.UIConversation(conv);
-+    uiConv.sendMsg("This is a looo\nooong message.");
-+
-+    ok(prepared);
-+    equal(msgCount, 2);
-+};
-+
-+function run_test() {
-+  test_null_message();
-+  test_message_transformation();
-+  test_cancel_send_message();
-+  test_cancel_display_message();
-+  test_prpl_message_prep();
-+  test_split_message_before_sending();
-+  run_next_test();
-+}
-diff --git a/chat/components/src/test/xpcshell.ini b/chat/components/src/test/xpcshell.ini
---- a/chat/components/src/test/xpcshell.ini
-+++ b/chat/components/src/test/xpcshell.ini
-@@ -3,9 +3,10 @@
- ; file, You can obtain one at http://mozilla.org/MPL/2.0/.
- 
- [DEFAULT]
- head = 
- tail = 
- 
- [test_accounts.js]
- [test_commands.js]
-+[test_conversations.js]
- [test_logger.js]



More information about the tor-commits mailing list