mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1227539: Part 2 - implement the new HangupNow action on standalone too so that leaving a room will still work. r=Standard8
This commit is contained in:
parent
dbb224d42d
commit
c2b51485b8
@ -721,7 +721,10 @@ const kMessageHandlers = {
|
||||
* the senders' channel.
|
||||
*/
|
||||
HangupNow: function(message, reply) {
|
||||
let [roomToken, windowId] = message.data;
|
||||
let [roomToken, sessionToken, windowId] = message.data;
|
||||
if (!windowId) {
|
||||
windowId = sessionToken;
|
||||
}
|
||||
|
||||
LoopRooms.leave(roomToken);
|
||||
MozLoopService.setScreenShareState(windowId, false);
|
||||
|
@ -1144,9 +1144,9 @@ loop.store.ActiveRoomStore = (function() {
|
||||
// NOTE: when the window _is_ closed, hanging up the call is performed by
|
||||
// MozLoopService, because we can't get a message across to LoopAPI
|
||||
// in time whilst a window is closing.
|
||||
if (nextState === ROOM_STATES.FAILED && !failedJoinRequest) {
|
||||
if ((nextState === ROOM_STATES.FAILED || !this._isDesktop) && !failedJoinRequest) {
|
||||
loop.request("HangupNow", this._storeState.roomToken,
|
||||
this._storeState.windowId);
|
||||
this._storeState.sessionToken, this._storeState.windowId);
|
||||
}
|
||||
|
||||
this.setStoreState({ roomState: nextState });
|
||||
|
@ -255,6 +255,13 @@ loop.StandaloneMozLoop = (function(mozL10n) {
|
||||
};
|
||||
|
||||
var kMessageHandlers = {
|
||||
AddConversationContext: function() {},
|
||||
HangupNow: function(data, reply) {
|
||||
var roomToken = data[0];
|
||||
var sessionToken = data[1];
|
||||
StandaloneLoopRooms.leave(roomToken, sessionToken, reply);
|
||||
},
|
||||
|
||||
"Rooms:*": function(action, data, reply) {
|
||||
var funcName = action.split(":").pop();
|
||||
funcName = funcName.charAt(0).toLowerCase() + funcName.substr(1);
|
||||
|
@ -224,7 +224,7 @@ describe("loop.store.ActiveRoomStore", function() {
|
||||
|
||||
sinon.assert.calledOnce(requestStubs["HangupNow"]);
|
||||
sinon.assert.calledWithExactly(requestStubs["HangupNow"],
|
||||
"fakeToken", "42");
|
||||
"fakeToken", "1627384950", "42");
|
||||
});
|
||||
|
||||
it("should not call 'HangupNow' Loop API if failedJoinRequest is true", function() {
|
||||
@ -1248,7 +1248,7 @@ describe("loop.store.ActiveRoomStore", function() {
|
||||
|
||||
sinon.assert.calledOnce(requestStubs["HangupNow"]);
|
||||
sinon.assert.calledWithExactly(requestStubs["HangupNow"],
|
||||
"fakeToken", "42");
|
||||
"fakeToken", "1627384950", "42");
|
||||
});
|
||||
|
||||
it("should remove the sharing listener", function() {
|
||||
@ -1807,19 +1807,23 @@ describe("loop.store.ActiveRoomStore", function() {
|
||||
sinon.assert.calledOnce(clearTimeout);
|
||||
});
|
||||
|
||||
it("should not call 'HangupNow' Loop API", function() {
|
||||
it("should call 'HangupNow' Loop API", function() {
|
||||
store.windowUnload();
|
||||
|
||||
sinon.assert.notCalled(requestStubs["HangupNow"]);
|
||||
sinon.assert.calledOnce(requestStubs["HangupNow"]);
|
||||
sinon.assert.calledWith(requestStubs["HangupNow"], "fakeToken",
|
||||
"1627384950", "1234");
|
||||
});
|
||||
|
||||
it("should call not call 'HangupNow' Loop API if the room state is JOINING",
|
||||
it("should call 'HangupNow' Loop API if the room state is JOINING",
|
||||
function() {
|
||||
store.setStoreState({ roomState: ROOM_STATES.JOINING });
|
||||
|
||||
store.windowUnload();
|
||||
|
||||
sinon.assert.notCalled(requestStubs["HangupNow"]);
|
||||
sinon.assert.calledOnce(requestStubs["HangupNow"]);
|
||||
sinon.assert.calledWith(requestStubs["HangupNow"], "fakeToken",
|
||||
"1627384950", "1234");
|
||||
});
|
||||
|
||||
it("should remove the sharing listener", function() {
|
||||
@ -1872,7 +1876,16 @@ describe("loop.store.ActiveRoomStore", function() {
|
||||
sinon.assert.calledOnce(clearTimeout);
|
||||
});
|
||||
|
||||
it("should not call 'HangupNow' Loop API", function() {
|
||||
it("should call 'HangupNow' Loop API", function() {
|
||||
store.leaveRoom();
|
||||
|
||||
sinon.assert.calledOnce(requestStubs["HangupNow"]);
|
||||
sinon.assert.calledWith(requestStubs["HangupNow"], "fakeToken", "1627384950");
|
||||
});
|
||||
|
||||
it("should not call 'HangupNow' Loop API when _isDesktop is true", function() {
|
||||
store._isDesktop = true;
|
||||
|
||||
store.leaveRoom();
|
||||
|
||||
sinon.assert.notCalled(requestStubs["HangupNow"]);
|
||||
|
@ -45,6 +45,22 @@ describe("loop.StandaloneMozLoop", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("#hangupNow", function() {
|
||||
it("should call rooms.leave", function() {
|
||||
loop.request("HangupNow", "fakeToken", "fakeSessionToken");
|
||||
|
||||
expect(requests).to.have.length.of(1);
|
||||
expect(requests[0].async).eql(false);
|
||||
expect(requests[0].url).eql(fakeBaseServerUrl + "/rooms/fakeToken");
|
||||
expect(requests[0].method).eql("POST");
|
||||
expect(requests[0].requestHeaders.Authorization)
|
||||
.eql("Basic " + btoa("fakeSessionToken"));
|
||||
|
||||
var requestData = JSON.parse(requests[0].requestBody);
|
||||
expect(requestData.action).eql("leave");
|
||||
});
|
||||
});
|
||||
|
||||
describe("#setLoopPref", function() {
|
||||
afterEach(function() {
|
||||
localStorage.removeItem("fakePref");
|
||||
|
Loading…
Reference in New Issue
Block a user