Bug 1018875 Prevent displaying OT GuM custom dialog. r=Standard8

This commit is contained in:
Nicolas Perriault 2014-06-05 15:51:59 +02:00
parent 579f9a8d9f
commit a2215a102c
2 changed files with 52 additions and 6 deletions

View File

@ -178,7 +178,16 @@ loop.shared.views = (function(_, OT, l10n) {
*/
publish: function(event) {
var outgoing = this.$(".outgoing").get(0);
this.publisher = this.sdk.initPublisher(outgoing, this.videoStyles);
// Suppress OT GuM custom dialog, see bug 1018875
function preventOpeningAccessDialog(event) {
event.preventDefault();
}
this.publisher.on("accessDialogOpened", preventOpeningAccessDialog);
this.publisher.on("accessDenied", preventOpeningAccessDialog);
this.model.session.publish(this.publisher);
},
@ -186,6 +195,10 @@ loop.shared.views = (function(_, OT, l10n) {
* Unpublishes local stream.
*/
unpublish: function() {
// Unregister access OT GuM custom dialog listeners, see bug 1018875
this.publisher.off("accessDialogOpened");
this.publisher.off("accessDenied");
this.model.session.unpublish(this.publisher);
},

View File

@ -41,7 +41,7 @@ describe("loop.shared.views", function() {
});
describe("ConversationView", function() {
var fakeSDK, fakeSessionData, fakeSession, model;
var fakeSDK, fakeSessionData, fakeSession, fakePublisher, model;
beforeEach(function() {
fakeSessionData = {
@ -57,8 +57,12 @@ describe("loop.shared.views", function() {
unpublish: sandbox.spy(),
subscribe: sandbox.spy()
}, Backbone.Events);
fakePublisher = {
on: sandbox.spy(),
off: sandbox.spy()
};
fakeSDK = {
initPublisher: sandbox.spy(),
initPublisher: sandbox.stub().returns(fakePublisher),
initSession: sandbox.stub().returns(fakeSession)
};
model = new sharedModels.ConversationModel(fakeSessionData, {
@ -90,6 +94,7 @@ describe("loop.shared.views", function() {
model: model
});
sandbox.stub(model, "endSession");
view.publish();
view.hangup({preventDefault: function() {}});
@ -98,30 +103,58 @@ describe("loop.shared.views", function() {
});
describe("#publish", function() {
it("should publish local stream", function() {
var view = new sharedViews.ConversationView({
var view;
beforeEach(function() {
view = new sharedViews.ConversationView({
sdk: fakeSDK,
model: model
});
});
it("should publish local stream", function() {
view.publish();
sinon.assert.calledOnce(fakeSDK.initPublisher);
sinon.assert.calledOnce(fakeSession.publish);
});
it("should start listening to OT publisher accessDialogOpened and " +
" accessDenied events",
function() {
view.publish();
sinon.assert.calledTwice(fakePublisher.on);
sinon.assert.calledWith(fakePublisher.on, "accessDialogOpened");
sinon.assert.calledWith(fakePublisher.on, "accessDenied");
});
});
describe("#unpublish", function() {
it("should unpublish local stream", function() {
var view = new sharedViews.ConversationView({
var view;
beforeEach(function() {
view = new sharedViews.ConversationView({
sdk: fakeSDK,
model: model
});
view.publish();
});
it("should unpublish local stream", function() {
view.unpublish();
sinon.assert.calledOnce(fakeSession.unpublish);
});
it("should unsubscribe from accessDialogOpened and accessDenied events",
function() {
view.unpublish();
sinon.assert.calledTwice(fakePublisher.off);
sinon.assert.calledWith(fakePublisher.off, "accessDialogOpened");
sinon.assert.calledWith(fakePublisher.off, "accessDenied");
});
});
describe("Model events", function() {