Bug 1193665 - Entering a conversation multiple times from link-clicker UI causes duplicated received text messages. r=mikedeboer

This commit is contained in:
Mark Banner 2015-08-25 14:01:06 +01:00
Родитель ef981d378b
Коммит 9c5cc9de92
2 изменённых файлов: 65 добавлений и 2 удалений

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

@ -272,14 +272,17 @@ loop.OTSdkDriver = (function() {
}));
if (this.session) {
this.session.off("sessionDisconnected streamCreated streamDestroyed connectionCreated connectionDestroyed streamPropertyChanged");
this.session.off("sessionDisconnected streamCreated streamDestroyed " +
"connectionCreated connectionDestroyed " +
"streamPropertyChanged signal:readyForDataChannel");
this.session.disconnect();
delete this.session;
this._notifyMetricsEvent("Session.connectionDestroyed", "local");
}
if (this.publisher) {
this.publisher.off("accessAllowed accessDenied accessDialogOpened streamCreated");
this.publisher.off("accessAllowed accessDenied accessDialogOpened " +
"streamCreated streamDestroyed");
this.publisher.destroy();
delete this.publisher;
}

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

@ -413,6 +413,66 @@ describe("loop.OTSdkDriver", function () {
sinon.assert.calledOnce(session.disconnect);
});
it("should unsubscribe to all the publisher events that were subscribed to in #setupStreamElements", function() {
var subscribedEvents = [];
// First find out which events were subscribed to.
sandbox.stub(publisher, "on", function(eventName) {
subscribedEvents.push(eventName);
});
driver.setupStreamElements(new sharedActions.SetupStreamElements({
publisherConfig: publisherConfig
}));
// Now disconnect, checking for any unexpected unsubscribes, or any missed
// unsubscribes.
sandbox.stub(publisher, "off", function(eventNames) {
var events = eventNames.split(" ");
events.forEach(function(eventName) {
var index = subscribedEvents.indexOf(eventName);
expect(index).not.eql(-1);
subscribedEvents.splice(index, 1);
});
});
driver.disconnectSession();
expect(subscribedEvents).eql([]);
});
it("should unsubscribe to all the subscriber events that were subscribed to in #connectSession", function() {
var subscribedEvents = [];
// First find out which events were subscribed to.
sandbox.stub(session, "on", function(eventName) {
subscribedEvents.push(eventName);
});
driver.connectSession(sessionData);
// Now disconnect, checking for any unexpected unsubscribes, or any missed
// unsubscribes.
sandbox.stub(session, "off", function(eventNames) {
var events = eventNames.split(" ");
events.forEach(function(eventName) {
var index = subscribedEvents.indexOf(eventName);
expect(index).not.eql(-1);
subscribedEvents.splice(index, 1);
});
});
driver.disconnectSession();
expect(subscribedEvents).eql([]);
});
it("should dispatch a DataChannelsAvailable action with available = false", function() {
driver.disconnectSession();