Bug 1105347 If something goes wrong in a Loop room, ensure that devices are released and the room is left fully. r=nperriault

This commit is contained in:
Mark Banner 2014-11-26 17:52:55 +00:00
parent 098898be85
commit 4d1df5a441
2 changed files with 38 additions and 6 deletions

View File

@ -114,10 +114,11 @@ loop.store.ActiveRoomStore = (function() {
this.setStoreState({
error: actionData.error,
failureReason: getReason(actionData.error.errno),
roomState: actionData.error.errno === SERVER_CODES.ROOM_FULL ?
ROOM_STATES.FULL : ROOM_STATES.FAILED
failureReason: getReason(actionData.error.errno)
});
this._leaveRoom(actionData.error.errno === SERVER_CODES.ROOM_FULL ?
ROOM_STATES.FULL : ROOM_STATES.FAILED);
},
/**

View File

@ -77,7 +77,9 @@ describe("loop.store.ActiveRoomStore", function () {
fakeError = new Error("fake");
store.setStoreState({
roomState: ROOM_STATES.READY
roomState: ROOM_STATES.JOINED,
roomToken: "fakeToken",
sessionToken: "1627384950"
});
});
@ -86,7 +88,7 @@ describe("loop.store.ActiveRoomStore", function () {
sinon.assert.calledOnce(console.error);
sinon.assert.calledWith(console.error,
sinon.match(ROOM_STATES.READY), fakeError);
sinon.match(ROOM_STATES.JOINED), fakeError);
});
it("should set the state to `FULL` on server error room full", function() {
@ -123,6 +125,35 @@ describe("loop.store.ActiveRoomStore", function () {
expect(store._storeState.roomState).eql(ROOM_STATES.FAILED);
expect(store._storeState.failureReason).eql(FAILURE_REASONS.EXPIRED_OR_INVALID);
});
it("should reset the multiplexGum", function() {
store.roomFailure({error: fakeError});
sinon.assert.calledOnce(fakeMultiplexGum.reset);
});
it("should disconnect from the servers via the sdk", function() {
store.roomFailure({error: fakeError});
sinon.assert.calledOnce(fakeSdkDriver.disconnectSession);
});
it("should clear any existing timeout", function() {
sandbox.stub(window, "clearTimeout");
store._timeout = {};
store.roomFailure({error: fakeError});
sinon.assert.calledOnce(clearTimeout);
});
it("should call mozLoop.rooms.leave", function() {
store.roomFailure({error: fakeError});
sinon.assert.calledOnce(fakeMozLoop.rooms.leave);
sinon.assert.calledWithExactly(fakeMozLoop.rooms.leave,
"fakeToken", "1627384950");
});
});
describe("#setupWindowData", function() {
@ -584,7 +615,7 @@ describe("loop.store.ActiveRoomStore", function () {
});
it("should reset the multiplexGum", function() {
store.leaveRoom();
store.windowUnload();
sinon.assert.calledOnce(fakeMultiplexGum.reset);
});