From a2215a102c9fd091854ad8e147768331ea0d7044 Mon Sep 17 00:00:00 2001 From: Nicolas Perriault Date: Thu, 5 Jun 2014 15:51:59 +0200 Subject: [PATCH] Bug 1018875 Prevent displaying OT GuM custom dialog. r=Standard8 --- .../loop/content/shared/js/views.js | 13 ++++++ .../components/loop/test/shared/views_test.js | 45 ++++++++++++++++--- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/browser/components/loop/content/shared/js/views.js b/browser/components/loop/content/shared/js/views.js index e9a62c0fafbd..cc78801cd44e 100644 --- a/browser/components/loop/content/shared/js/views.js +++ b/browser/components/loop/content/shared/js/views.js @@ -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); }, diff --git a/browser/components/loop/test/shared/views_test.js b/browser/components/loop/test/shared/views_test.js index a63fed32217e..9f595a066577 100644 --- a/browser/components/loop/test/shared/views_test.js +++ b/browser/components/loop/test/shared/views_test.js @@ -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() {