From e3b0b8f9aba94ab0b283ace0a057481d9c9ee4fb Mon Sep 17 00:00:00 2001 From: Romain Gauthier Date: Fri, 17 Oct 2014 16:11:41 +0100 Subject: [PATCH] Bug 1079811 - A new call won't start if the outgoing call window is opened (showing feedback or retry/cancel). r=Standard8 --- .../content/shared/js/conversationStore.js | 6 +++ .../test/shared/conversationStore_test.js | 41 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/browser/components/loop/content/shared/js/conversationStore.js b/browser/components/loop/content/shared/js/conversationStore.js index 9524bbfd7d9..8afc871d570 100644 --- a/browser/components/loop/content/shared/js/conversationStore.js +++ b/browser/components/loop/content/shared/js/conversationStore.js @@ -406,6 +406,12 @@ loop.store.ConversationStore = (function() { this._websocket.close(); delete this._websocket; } + + // XXX: The internal callId is different from + // this.get("callId"), see bug 1084228 for more info. + var locationHash = new loop.shared.utils.Helper().locationHash(); + var callId = locationHash.match(/\#outgoing\/(.*)/)[1]; + navigator.mozLoop.releaseCallData(callId); }, /** diff --git a/browser/components/loop/test/shared/conversationStore_test.js b/browser/components/loop/test/shared/conversationStore_test.js index ff4d9e2398b..44cb0ee2a40 100644 --- a/browser/components/loop/test/shared/conversationStore_test.js +++ b/browser/components/loop/test/shared/conversationStore_test.js @@ -36,6 +36,11 @@ describe("loop.store.ConversationStore", function () { }] }; + navigator.mozLoop = { + getLoopBoolPref: sandbox.stub(), + releaseCallData: sandbox.stub() + }; + dispatcher = new loop.Dispatcher(); client = { setupOutgoingCall: sinon.stub(), @@ -120,6 +125,8 @@ describe("loop.store.ConversationStore", function () { describe("#connectionFailure", function() { beforeEach(function() { store._websocket = fakeWebsocket; + sandbox.stub(loop.shared.utils.Helper.prototype, "locationHash") + .returns("#outgoing/42"); }); it("should disconnect the session", function() { @@ -145,6 +152,14 @@ describe("loop.store.ConversationStore", function () { expect(store.get("callState")).eql(CALL_STATES.TERMINATED); expect(store.get("callStateReason")).eql("fake"); }); + + it("should release mozLoop callsData", function() { + dispatcher.dispatch( + new sharedActions.ConnectionFailure({reason: "fake"})); + + sinon.assert.calledOnce(navigator.mozLoop.releaseCallData); + sinon.assert.calledWithExactly(navigator.mozLoop.releaseCallData, "42"); + }); }); describe("#connectionProgress", function() { @@ -481,6 +496,8 @@ describe("loop.store.ConversationStore", function () { close: wsCloseSpy }; store.set({callState: CALL_STATES.ONGOING}); + sandbox.stub(loop.shared.utils.Helper.prototype, "locationHash") + .returns("#outgoing/42"); }); it("should disconnect the session", function() { @@ -506,6 +523,13 @@ describe("loop.store.ConversationStore", function () { expect(store.get("callState")).eql(CALL_STATES.FINISHED); }); + + it("should release mozLoop callsData", function() { + dispatcher.dispatch(new sharedActions.HangupCall()); + + sinon.assert.calledOnce(navigator.mozLoop.releaseCallData); + sinon.assert.calledWithExactly(navigator.mozLoop.releaseCallData, "42"); + }); }); describe("#peerHungupCall", function() { @@ -519,6 +543,8 @@ describe("loop.store.ConversationStore", function () { close: wsCloseSpy }; store.set({callState: CALL_STATES.ONGOING}); + sandbox.stub(loop.shared.utils.Helper.prototype, "locationHash") + .returns("#outgoing/42"); }); it("should disconnect the session", function() { @@ -538,6 +564,13 @@ describe("loop.store.ConversationStore", function () { expect(store.get("callState")).eql(CALL_STATES.FINISHED); }); + + it("should release mozLoop callsData", function() { + dispatcher.dispatch(new sharedActions.PeerHungupCall()); + + sinon.assert.calledOnce(navigator.mozLoop.releaseCallData); + sinon.assert.calledWithExactly(navigator.mozLoop.releaseCallData, "42"); + }); }); describe("#cancelCall", function() { @@ -545,6 +578,8 @@ describe("loop.store.ConversationStore", function () { store._websocket = fakeWebsocket; store.set({callState: CALL_STATES.CONNECTING}); + sandbox.stub(loop.shared.utils.Helper.prototype, "locationHash") + .returns("#outgoing/42"); }); it("should disconnect the session", function() { @@ -579,6 +614,12 @@ describe("loop.store.ConversationStore", function () { expect(store.get("callState")).eql(CALL_STATES.CLOSE); }); + it("should release mozLoop callsData", function() { + dispatcher.dispatch(new sharedActions.CancelCall()); + + sinon.assert.calledOnce(navigator.mozLoop.releaseCallData); + sinon.assert.calledWithExactly(navigator.mozLoop.releaseCallData, "42"); + }); }); describe("#retryCall", function() {