Bug 1088346 - Handle "answered-elsewhere" on incoming calls for desktop on Loop. r=nperriault
This commit is contained in:
@@ -394,19 +394,25 @@ loop.conversation = (function(mozL10n) {
|
|||||||
if (progressData.state !== "terminated")
|
if (progressData.state !== "terminated")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (progressData.reason === "cancel" ||
|
// XXX This would be nicer in the _abortIncomingCall function, but we need to stop
|
||||||
progressData.reason === "closed") {
|
// it here for now due to server-side issues that are being fixed in bug 1088351.
|
||||||
|
// This is before the abort call to ensure that it happens before the window is
|
||||||
|
// closed.
|
||||||
|
navigator.mozLoop.stopAlerting();
|
||||||
|
|
||||||
|
// If we hit any of the termination reasons, and the user hasn't accepted
|
||||||
|
// then it seems reasonable to close the window/abort the incoming call.
|
||||||
|
//
|
||||||
|
// If the user has accepted the call, and something's happened, display
|
||||||
|
// the call failed view.
|
||||||
|
//
|
||||||
|
// https://wiki.mozilla.org/Loop/Architecture/MVP#Termination_Reasons
|
||||||
|
if (previousState === "init" || previousState === "alerting") {
|
||||||
this._abortIncomingCall();
|
this._abortIncomingCall();
|
||||||
return;
|
} else {
|
||||||
|
this.setState({callFailed: true, callStatus: "end"});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progressData.reason === "timeout") {
|
|
||||||
if (previousState === "init" || previousState === "alerting") {
|
|
||||||
this._abortIncomingCall();
|
|
||||||
} else {
|
|
||||||
this.setState({callFailed: true, callStatus: "end"});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -414,7 +420,6 @@ loop.conversation = (function(mozL10n) {
|
|||||||
* closes the websocket.
|
* closes the websocket.
|
||||||
*/
|
*/
|
||||||
_abortIncomingCall: function() {
|
_abortIncomingCall: function() {
|
||||||
navigator.mozLoop.stopAlerting();
|
|
||||||
this._websocket.close();
|
this._websocket.close();
|
||||||
// Having a timeout here lets the logging for the websocket complete and be
|
// Having a timeout here lets the logging for the websocket complete and be
|
||||||
// displayed on the console if both are on.
|
// displayed on the console if both are on.
|
||||||
|
|||||||
@@ -394,19 +394,25 @@ loop.conversation = (function(mozL10n) {
|
|||||||
if (progressData.state !== "terminated")
|
if (progressData.state !== "terminated")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (progressData.reason === "cancel" ||
|
// XXX This would be nicer in the _abortIncomingCall function, but we need to stop
|
||||||
progressData.reason === "closed") {
|
// it here for now due to server-side issues that are being fixed in bug 1088351.
|
||||||
|
// This is before the abort call to ensure that it happens before the window is
|
||||||
|
// closed.
|
||||||
|
navigator.mozLoop.stopAlerting();
|
||||||
|
|
||||||
|
// If we hit any of the termination reasons, and the user hasn't accepted
|
||||||
|
// then it seems reasonable to close the window/abort the incoming call.
|
||||||
|
//
|
||||||
|
// If the user has accepted the call, and something's happened, display
|
||||||
|
// the call failed view.
|
||||||
|
//
|
||||||
|
// https://wiki.mozilla.org/Loop/Architecture/MVP#Termination_Reasons
|
||||||
|
if (previousState === "init" || previousState === "alerting") {
|
||||||
this._abortIncomingCall();
|
this._abortIncomingCall();
|
||||||
return;
|
} else {
|
||||||
|
this.setState({callFailed: true, callStatus: "end"});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progressData.reason === "timeout") {
|
|
||||||
if (previousState === "init" || previousState === "alerting") {
|
|
||||||
this._abortIncomingCall();
|
|
||||||
} else {
|
|
||||||
this.setState({callFailed: true, callStatus: "end"});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -414,7 +420,6 @@ loop.conversation = (function(mozL10n) {
|
|||||||
* closes the websocket.
|
* closes the websocket.
|
||||||
*/
|
*/
|
||||||
_abortIncomingCall: function() {
|
_abortIncomingCall: function() {
|
||||||
navigator.mozLoop.stopAlerting();
|
|
||||||
this._websocket.close();
|
this._websocket.close();
|
||||||
// Having a timeout here lets the logging for the websocket complete and be
|
// Having a timeout here lets the logging for the websocket complete and be
|
||||||
// displayed on the console if both are on.
|
// displayed on the console if both are on.
|
||||||
|
|||||||
@@ -431,87 +431,7 @@ describe("loop.conversation", function() {
|
|||||||
sandbox.stub(window, "close");
|
sandbox.stub(window, "close");
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("progress - terminated - cancel", function() {
|
describe("progress - terminated (previousState = alerting)", function() {
|
||||||
it("should stop alerting", function(done) {
|
|
||||||
promise.then(function() {
|
|
||||||
icView._websocket.trigger("progress", {
|
|
||||||
state: "terminated",
|
|
||||||
reason: "cancel"
|
|
||||||
});
|
|
||||||
|
|
||||||
sinon.assert.calledOnce(navigator.mozLoop.stopAlerting);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should close the websocket", function(done) {
|
|
||||||
promise.then(function() {
|
|
||||||
icView._websocket.trigger("progress", {
|
|
||||||
state: "terminated",
|
|
||||||
reason: "cancel"
|
|
||||||
});
|
|
||||||
|
|
||||||
sinon.assert.calledOnce(icView._websocket.close);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should close the window", function(done) {
|
|
||||||
promise.then(function() {
|
|
||||||
icView._websocket.trigger("progress", {
|
|
||||||
state: "terminated",
|
|
||||||
reason: "cancel"
|
|
||||||
});
|
|
||||||
|
|
||||||
sandbox.clock.tick(1);
|
|
||||||
|
|
||||||
sinon.assert.calledOnce(window.close);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("progress - terminated - closed", function() {
|
|
||||||
it("should stop alerting", function(done) {
|
|
||||||
promise.then(function() {
|
|
||||||
icView._websocket.trigger("progress", {
|
|
||||||
state: "terminated",
|
|
||||||
reason: "closed"
|
|
||||||
});
|
|
||||||
|
|
||||||
sinon.assert.calledOnce(navigator.mozLoop.stopAlerting);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should close the websocket", function(done) {
|
|
||||||
promise.then(function() {
|
|
||||||
icView._websocket.trigger("progress", {
|
|
||||||
state: "terminated",
|
|
||||||
reason: "closed"
|
|
||||||
});
|
|
||||||
|
|
||||||
sinon.assert.calledOnce(icView._websocket.close);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should close the window", function(done) {
|
|
||||||
promise.then(function() {
|
|
||||||
icView._websocket.trigger("progress", {
|
|
||||||
state: "terminated",
|
|
||||||
reason: "closed"
|
|
||||||
});
|
|
||||||
|
|
||||||
sandbox.clock.tick(1);
|
|
||||||
|
|
||||||
sinon.assert.calledOnce(window.close);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("progress - terminated - timeout (previousState = alerting)", function() {
|
|
||||||
it("should stop alerting", function(done) {
|
it("should stop alerting", function(done) {
|
||||||
promise.then(function() {
|
promise.then(function() {
|
||||||
icView._websocket.trigger("progress", {
|
icView._websocket.trigger("progress", {
|
||||||
@@ -528,7 +448,7 @@ describe("loop.conversation", function() {
|
|||||||
promise.then(function() {
|
promise.then(function() {
|
||||||
icView._websocket.trigger("progress", {
|
icView._websocket.trigger("progress", {
|
||||||
state: "terminated",
|
state: "terminated",
|
||||||
reason: "timeout"
|
reason: "closed"
|
||||||
}, "alerting");
|
}, "alerting");
|
||||||
|
|
||||||
sinon.assert.calledOnce(icView._websocket.close);
|
sinon.assert.calledOnce(icView._websocket.close);
|
||||||
@@ -540,7 +460,7 @@ describe("loop.conversation", function() {
|
|||||||
promise.then(function() {
|
promise.then(function() {
|
||||||
icView._websocket.trigger("progress", {
|
icView._websocket.trigger("progress", {
|
||||||
state: "terminated",
|
state: "terminated",
|
||||||
reason: "timeout"
|
reason: "answered-elsewhere"
|
||||||
}, "alerting");
|
}, "alerting");
|
||||||
|
|
||||||
sandbox.clock.tick(1);
|
sandbox.clock.tick(1);
|
||||||
@@ -551,21 +471,33 @@ describe("loop.conversation", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("progress - terminated - timeout (previousState not init" +
|
describe("progress - terminated (previousState not init" +
|
||||||
" nor alerting)",
|
" nor alerting)",
|
||||||
function() {
|
function() {
|
||||||
it("should set the state to end", function(done) {
|
it("should set the state to end", function(done) {
|
||||||
promise.then(function() {
|
promise.then(function() {
|
||||||
icView._websocket.trigger("progress", {
|
icView._websocket.trigger("progress", {
|
||||||
state: "terminated",
|
state: "terminated",
|
||||||
reason: "timeout"
|
reason: "media-fail"
|
||||||
}, "connecting");
|
}, "connecting");
|
||||||
|
|
||||||
expect(icView.state.callStatus).eql("end");
|
expect(icView.state.callStatus).eql("end");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
it("should stop alerting", function(done) {
|
||||||
|
promise.then(function() {
|
||||||
|
icView._websocket.trigger("progress", {
|
||||||
|
state: "terminated",
|
||||||
|
reason: "media-fail"
|
||||||
|
}, "connecting");
|
||||||
|
|
||||||
|
sinon.assert.calledOnce(navigator.mozLoop.stopAlerting);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user