зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1074823 - Infinite ringing if the caller cancels the call in the 'connecting' state. Handle the initial state returned from the websocket. r=dmose
This commit is contained in:
Родитель
122e4eddcd
Коммит
062a92d254
|
@ -368,8 +368,10 @@ loop.conversation = (function(mozL10n) {
|
|||
websocketToken: this.props.conversation.get("websocketToken"),
|
||||
callId: this.props.conversation.get("callId"),
|
||||
});
|
||||
this._websocket.promiseConnect().then(function() {
|
||||
this.setState({callStatus: "incoming"});
|
||||
this._websocket.promiseConnect().then(function(progressStatus) {
|
||||
this.setState({
|
||||
callStatus: progressStatus === "terminated" ? "close" : "incoming"
|
||||
});
|
||||
}.bind(this), function() {
|
||||
this._handleSessionError();
|
||||
return;
|
||||
|
|
|
@ -368,8 +368,10 @@ loop.conversation = (function(mozL10n) {
|
|||
websocketToken: this.props.conversation.get("websocketToken"),
|
||||
callId: this.props.conversation.get("callId"),
|
||||
});
|
||||
this._websocket.promiseConnect().then(function() {
|
||||
this.setState({callStatus: "incoming"});
|
||||
this._websocket.promiseConnect().then(function(progressStatus) {
|
||||
this.setState({
|
||||
callStatus: progressStatus === "terminated" ? "close" : "incoming"
|
||||
});
|
||||
}.bind(this), function() {
|
||||
this._handleSessionError();
|
||||
return;
|
||||
|
|
|
@ -99,10 +99,13 @@ loop.CallConnectionWebSocket = (function() {
|
|||
* Internal function called to resolve the connection promise.
|
||||
*
|
||||
* It will log an error if no promise is found.
|
||||
*
|
||||
* @param {String} progressState The current state of progress of the
|
||||
* websocket.
|
||||
*/
|
||||
_completeConnection: function() {
|
||||
_completeConnection: function(progressState) {
|
||||
if (this.connectDetails && this.connectDetails.resolve) {
|
||||
this.connectDetails.resolve();
|
||||
this.connectDetails.resolve(progressState);
|
||||
this._clearConnectionFlags();
|
||||
return;
|
||||
}
|
||||
|
@ -227,7 +230,7 @@ loop.CallConnectionWebSocket = (function() {
|
|||
|
||||
switch(msg.messageType) {
|
||||
case "hello":
|
||||
this._completeConnection();
|
||||
this._completeConnection(msg.state);
|
||||
break;
|
||||
case "progress":
|
||||
this.trigger("progress:" + msg.state);
|
||||
|
|
|
@ -295,7 +295,7 @@ describe("loop.conversation", function() {
|
|||
|
||||
it("should set the state to incoming on success", function(done) {
|
||||
icView = mountTestComponent();
|
||||
resolveWebSocketConnect();
|
||||
resolveWebSocketConnect("incoming");
|
||||
|
||||
promise.then(function () {
|
||||
expect(icView.state.callStatus).eql("incoming");
|
||||
|
@ -303,6 +303,17 @@ describe("loop.conversation", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it("should set the state to close on success if the progress " +
|
||||
"state is terminated", function(done) {
|
||||
icView = mountTestComponent();
|
||||
resolveWebSocketConnect("terminated");
|
||||
|
||||
promise.then(function () {
|
||||
expect(icView.state.callStatus).eql("close");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("should display an error if the websocket failed to connect", function(done) {
|
||||
sandbox.stub(notifications, "errorL10n");
|
||||
|
||||
|
|
|
@ -128,8 +128,11 @@ describe("loop.CallConnectionWebSocket", function() {
|
|||
data: '{"messageType":"hello", "state":"init"}'
|
||||
});
|
||||
|
||||
promise.then(function() {
|
||||
promise.then(function(state) {
|
||||
expect(state).eql("init");
|
||||
done();
|
||||
}, function() {
|
||||
done(new Error("shouldn't have rejected the promise"));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче