mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Backed out 2 changesets (bug 1227539) for Win 7 M(bc4) and likely Win XP opt M(bc6) failures. r=backout
Backed out changeset 48d56e89c482 (bug 1227539) Backed out changeset 0fbd239d0c37 (bug 1227539)
This commit is contained in:
parent
5c2f270233
commit
8007ffbe98
@ -718,7 +718,7 @@ var LoopRoomsInternal = {
|
|||||||
|
|
||||||
eventEmitter.emit("open", roomToken);
|
eventEmitter.emit("open", roomToken);
|
||||||
|
|
||||||
return MozLoopService.openChatWindow(windowData, () => {
|
MozLoopService.openChatWindow(windowData, () => {
|
||||||
eventEmitter.emit("close");
|
eventEmitter.emit("close");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -123,7 +123,7 @@ const updateSocialProvidersCache = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var gAppVersionInfo = null;
|
var gAppVersionInfo = null;
|
||||||
var gBrowserSharingListeners = new Set();
|
var gBrowserSharingListenerCount = 0;
|
||||||
var gBrowserSharingWindows = new Set();
|
var gBrowserSharingWindows = new Set();
|
||||||
var gPageListeners = null;
|
var gPageListeners = null;
|
||||||
var gOriginalPageListeners = null;
|
var gOriginalPageListeners = null;
|
||||||
@ -141,12 +141,10 @@ const kMessageHandlers = {
|
|||||||
/**
|
/**
|
||||||
* Start browser sharing, which basically means to start listening for tab
|
* Start browser sharing, which basically means to start listening for tab
|
||||||
* switches and passing the new window ID to the sender whenever that happens.
|
* switches and passing the new window ID to the sender whenever that happens.
|
||||||
*
|
*
|
||||||
* @param {Object} message Message meant for the handler function, containing
|
* @param {Object} message Message meant for the handler function, containing
|
||||||
* the following parameters in its `data` property:
|
* the following parameters in its `data` property:
|
||||||
* [
|
* [ ]
|
||||||
* {Number} windowId The window ID of the chat window
|
|
||||||
* ]
|
|
||||||
* @param {Function} reply Callback function, invoked with the result of this
|
* @param {Function} reply Callback function, invoked with the result of this
|
||||||
* message handler. The result will be sent back to
|
* message handler. The result will be sent back to
|
||||||
* the senders' channel.
|
* the senders' channel.
|
||||||
@ -171,13 +169,10 @@ const kMessageHandlers = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let [windowId] = message.data;
|
|
||||||
|
|
||||||
win.LoopUI.startBrowserSharing();
|
win.LoopUI.startBrowserSharing();
|
||||||
|
|
||||||
gBrowserSharingWindows.add(Cu.getWeakReference(win));
|
gBrowserSharingWindows.add(Cu.getWeakReference(win));
|
||||||
gBrowserSharingListeners.add(windowId);
|
++gBrowserSharingListenerCount;
|
||||||
reply();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -238,14 +233,13 @@ const kMessageHandlers = {
|
|||||||
* message handler. The result will be sent back to
|
* message handler. The result will be sent back to
|
||||||
* the senders' channel.
|
* the senders' channel.
|
||||||
*/
|
*/
|
||||||
ComposeEmail: function(message, reply) {
|
ComposeEmail: function(message) {
|
||||||
let [subject, body, recipient] = message.data;
|
let [subject, body, recipient] = message.data;
|
||||||
recipient = recipient || "";
|
recipient = recipient || "";
|
||||||
let mailtoURL = "mailto:" + encodeURIComponent(recipient) +
|
let mailtoURL = "mailto:" + encodeURIComponent(recipient) +
|
||||||
"?subject=" + encodeURIComponent(subject) +
|
"?subject=" + encodeURIComponent(subject) +
|
||||||
"&body=" + encodeURIComponent(body);
|
"&body=" + encodeURIComponent(body);
|
||||||
extProtocolSvc.loadURI(CommonUtils.makeURI(mailtoURL));
|
extProtocolSvc.loadURI(CommonUtils.makeURI(mailtoURL));
|
||||||
reply();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -369,7 +363,6 @@ const kMessageHandlers = {
|
|||||||
TWO_WAY_MEDIA_CONN_LENGTH: TWO_WAY_MEDIA_CONN_LENGTH
|
TWO_WAY_MEDIA_CONN_LENGTH: TWO_WAY_MEDIA_CONN_LENGTH
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the app version information for use during feedback.
|
* Returns the app version information for use during feedback.
|
||||||
*
|
*
|
||||||
@ -693,46 +686,9 @@ const kMessageHandlers = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Hangup and close all chat windows that are open.
|
* Hangup and close all chat windows that are open.
|
||||||
*
|
|
||||||
* @param {Object} message Message meant for the handler function, containing
|
|
||||||
* the following parameters in its `data` property:
|
|
||||||
* [ ]
|
|
||||||
* @param {Function} reply Callback function, invoked with the result of this
|
|
||||||
* message handler. The result will be sent back to
|
|
||||||
* the senders' channel.
|
|
||||||
*/
|
*/
|
||||||
HangupAllChatWindows: function(message, reply) {
|
HangupAllChatWindows: function() {
|
||||||
MozLoopService.hangupAllChatWindows();
|
MozLoopService.hangupAllChatWindows();
|
||||||
reply();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hangup a specific chay window or room, by leaving a room, resetting the
|
|
||||||
* screensharing state and removing any active browser switch listeners.
|
|
||||||
*
|
|
||||||
* @param {Object} message Message meant for the handler function, containing
|
|
||||||
* the following parameters in its `data` property:
|
|
||||||
* [
|
|
||||||
* {String} roomToken The token of the room to leave
|
|
||||||
* {Number} windowId The window ID of the chat window
|
|
||||||
* ]
|
|
||||||
* @param {Function} reply Callback function, invoked with the result of this
|
|
||||||
* message handler. The result will be sent back to
|
|
||||||
* the senders' channel.
|
|
||||||
*/
|
|
||||||
HangupNow: function(message, reply) {
|
|
||||||
let [roomToken, sessionToken, windowId] = message.data;
|
|
||||||
if (!windowId) {
|
|
||||||
windowId = sessionToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
LoopRooms.leave(roomToken);
|
|
||||||
MozLoopService.setScreenShareState(windowId, false);
|
|
||||||
LoopAPI.sendMessageToHandler({
|
|
||||||
name: "RemoveBrowserSharingListener",
|
|
||||||
data: [windowId]
|
|
||||||
});
|
|
||||||
reply();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -859,7 +815,6 @@ const kMessageHandlers = {
|
|||||||
let win = Services.wm.getMostRecentWindow("navigator:browser");
|
let win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||||
let url = message.data[0] ? message.data[0] : "about:home";
|
let url = message.data[0] ? message.data[0] : "about:home";
|
||||||
win.openDialog("chrome://browser/content/", "_blank", "chrome,all,dialog=no,non-remote", url);
|
win.openDialog("chrome://browser/content/", "_blank", "chrome,all,dialog=no,non-remote", url);
|
||||||
reply();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -882,27 +837,14 @@ const kMessageHandlers = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a listener that was previously added.
|
* Removes a listener that was previously added.
|
||||||
*
|
|
||||||
* @param {Object} message Message meant for the handler function, containing
|
|
||||||
* the following parameters in its `data` property:
|
|
||||||
* [
|
|
||||||
* {Number} windowId The window ID of the chat
|
|
||||||
* ]
|
|
||||||
* @param {Function} reply Callback function, invoked with the result of this
|
|
||||||
* message handler. The result will be sent back to
|
|
||||||
* the senders' channel.
|
|
||||||
*/
|
*/
|
||||||
RemoveBrowserSharingListener: function(message, reply) {
|
RemoveBrowserSharingListener: function() {
|
||||||
if (!gBrowserSharingListeners.size) {
|
if (!gBrowserSharingListenerCount) {
|
||||||
reply();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let [windowId] = message.data;
|
if (--gBrowserSharingListenerCount > 0) {
|
||||||
gBrowserSharingListeners.delete(windowId);
|
|
||||||
if (gBrowserSharingListeners.size > 0) {
|
|
||||||
// There are still clients listening in, so keep on listening...
|
// There are still clients listening in, so keep on listening...
|
||||||
reply();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -915,7 +857,6 @@ const kMessageHandlers = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gBrowserSharingWindows.clear();
|
gBrowserSharingWindows.clear();
|
||||||
reply();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"Rooms:*": function(action, message, reply) {
|
"Rooms:*": function(action, message, reply) {
|
||||||
@ -1001,10 +942,9 @@ const kMessageHandlers = {
|
|||||||
* message handler. The result will be sent back to
|
* message handler. The result will be sent back to
|
||||||
* the senders' channel.
|
* the senders' channel.
|
||||||
*/
|
*/
|
||||||
SetScreenShareState: function(message, reply) {
|
SetScreenShareState: function(message) {
|
||||||
let [windowId, active] = message.data;
|
let [windowId, active] = message.data;
|
||||||
MozLoopService.setScreenShareState(windowId, active);
|
MozLoopService.setScreenShareState(windowId, active);
|
||||||
reply();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1374,46 +1314,6 @@ this.LoopAPI = Object.freeze({
|
|||||||
destroy: function() {
|
destroy: function() {
|
||||||
LoopAPIInternal.destroy();
|
LoopAPIInternal.destroy();
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Gateway for chrome scripts to send a message to a message handler, when
|
|
||||||
* using the RemotePageManager module is not an option.
|
|
||||||
*
|
|
||||||
* @param {Object} message Message meant for the handler function, containing
|
|
||||||
* the following properties:
|
|
||||||
* - {String} name Name of handler to send this
|
|
||||||
* message to. See `kMessageHandlers`
|
|
||||||
* for the available names.
|
|
||||||
* - {String} [action] Optional action name of the
|
|
||||||
* function to call on a sub-API.
|
|
||||||
* - {Array} data List of arguments that the
|
|
||||||
* handler can use.
|
|
||||||
* @param {Function} [reply] Callback function, invoked with the result of this
|
|
||||||
* message handler. Optional.
|
|
||||||
*/
|
|
||||||
sendMessageToHandler: function(message, reply) {
|
|
||||||
reply = reply || function() {};
|
|
||||||
let handlerName = message.name;
|
|
||||||
let handler = kMessageHandlers[handlerName];
|
|
||||||
if (gStubbedMessageHandlers && gStubbedMessageHandlers[handlerName]) {
|
|
||||||
handler = gStubbedMessageHandlers[handlerName];
|
|
||||||
}
|
|
||||||
if (!handler) {
|
|
||||||
let msg = "Ouch, no message handler available for '" + handlerName + "'";
|
|
||||||
MozLoopService.log.error(msg);
|
|
||||||
reply(cloneableError(msg));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!message.data) {
|
|
||||||
message.data = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (handlerName.endsWith("*")) {
|
|
||||||
handler(message.action, message, reply);
|
|
||||||
} else {
|
|
||||||
handler(message, reply);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// The following functions are only used in unit tests.
|
// The following functions are only used in unit tests.
|
||||||
inspect: function() {
|
inspect: function() {
|
||||||
return [Object.create(LoopAPIInternal), Object.create(kMessageHandlers),
|
return [Object.create(LoopAPIInternal), Object.create(kMessageHandlers),
|
||||||
|
@ -953,10 +953,7 @@ var MozLoopServiceInternal = {
|
|||||||
// NOTE: if you add something here, please also consider if something
|
// NOTE: if you add something here, please also consider if something
|
||||||
// needs to be done on the content side as well (e.g.
|
// needs to be done on the content side as well (e.g.
|
||||||
// activeRoomStore#windowUnload).
|
// activeRoomStore#windowUnload).
|
||||||
LoopAPI.sendMessageToHandler({
|
LoopRooms.leave(conversationWindowData.roomToken);
|
||||||
name: "HangupNow",
|
|
||||||
data: [conversationWindowData.roomToken, windowId]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1207,7 +1204,7 @@ var gServiceInitialized = false;
|
|||||||
*/
|
*/
|
||||||
this.MozLoopService = {
|
this.MozLoopService = {
|
||||||
_DNSService: gDNSService,
|
_DNSService: gDNSService,
|
||||||
_activeScreenShares: new Set(),
|
_activeScreenShares: [],
|
||||||
|
|
||||||
get channelIDs() {
|
get channelIDs() {
|
||||||
// Channel ids that will be registered with the PushServer for notifications
|
// Channel ids that will be registered with the PushServer for notifications
|
||||||
@ -1925,10 +1922,11 @@ this.MozLoopService = {
|
|||||||
*/
|
*/
|
||||||
setScreenShareState: function(windowId, active) {
|
setScreenShareState: function(windowId, active) {
|
||||||
if (active) {
|
if (active) {
|
||||||
this._activeScreenShares.add(windowId);
|
this._activeScreenShares.push(windowId);
|
||||||
} else {
|
} else {
|
||||||
if (this._activeScreenShares.has(windowId)) {
|
var index = this._activeScreenShares.indexOf(windowId);
|
||||||
this._activeScreenShares.delete(windowId);
|
if (index != -1) {
|
||||||
|
this._activeScreenShares.splice(index, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1939,6 +1937,6 @@ this.MozLoopService = {
|
|||||||
* Returns true if screen sharing is active in at least one window.
|
* Returns true if screen sharing is active in at least one window.
|
||||||
*/
|
*/
|
||||||
get screenShareActive() {
|
get screenShareActive() {
|
||||||
return this._activeScreenShares.size > 0;
|
return this._activeScreenShares.length > 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -819,7 +819,7 @@ loop.panel = (function(_, mozL10n) {
|
|||||||
loop.request("GetSelectedTabMetadata").then(function(metadata) {
|
loop.request("GetSelectedTabMetadata").then(function(metadata) {
|
||||||
// Bail out when the component is not mounted (anymore).
|
// Bail out when the component is not mounted (anymore).
|
||||||
// This occurs during test runs. See bug 1174611 for more info.
|
// This occurs during test runs. See bug 1174611 for more info.
|
||||||
if (!this.isMounted() || !metadata) {
|
if (!this.isMounted()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -819,7 +819,7 @@ loop.panel = (function(_, mozL10n) {
|
|||||||
loop.request("GetSelectedTabMetadata").then(function(metadata) {
|
loop.request("GetSelectedTabMetadata").then(function(metadata) {
|
||||||
// Bail out when the component is not mounted (anymore).
|
// Bail out when the component is not mounted (anymore).
|
||||||
// This occurs during test runs. See bug 1174611 for more info.
|
// This occurs during test runs. See bug 1174611 for more info.
|
||||||
if (!this.isMounted() || !metadata) {
|
if (!this.isMounted()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -979,7 +979,7 @@ loop.store.ActiveRoomStore = (function() {
|
|||||||
endScreenShare: function() {
|
endScreenShare: function() {
|
||||||
if (this._browserSharingListener) {
|
if (this._browserSharingListener) {
|
||||||
// Remove the browser sharing listener as we don't need it now.
|
// Remove the browser sharing listener as we don't need it now.
|
||||||
loop.request("RemoveBrowserSharingListener", this.getStoreState().windowId);
|
loop.request("RemoveBrowserSharingListener");
|
||||||
loop.unsubscribe("BrowserSwitch", this._browserSharingListener);
|
loop.unsubscribe("BrowserSwitch", this._browserSharingListener);
|
||||||
this._browserSharingListener = null;
|
this._browserSharingListener = null;
|
||||||
}
|
}
|
||||||
@ -1117,8 +1117,13 @@ loop.store.ActiveRoomStore = (function() {
|
|||||||
loop.standaloneMedia.multiplexGum.reset();
|
loop.standaloneMedia.multiplexGum.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var requests = [
|
||||||
|
["SetScreenShareState", this.getStoreState().windowId, false]
|
||||||
|
];
|
||||||
|
|
||||||
if (this._browserSharingListener) {
|
if (this._browserSharingListener) {
|
||||||
// Remove the browser sharing listener as we don't need it now.
|
// Remove the browser sharing listener as we don't need it now.
|
||||||
|
requests.push(["RemoveBrowserSharingListener"]);
|
||||||
loop.unsubscribe("BrowserSwitch", this._browserSharingListener);
|
loop.unsubscribe("BrowserSwitch", this._browserSharingListener);
|
||||||
this._browserSharingListener = null;
|
this._browserSharingListener = null;
|
||||||
}
|
}
|
||||||
@ -1140,15 +1145,17 @@ loop.store.ActiveRoomStore = (function() {
|
|||||||
delete this._timeout;
|
delete this._timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're not going to close the window, we can hangup the call ourselves.
|
if (!failedJoinRequest &&
|
||||||
// NOTE: when the window _is_ closed, hanging up the call is performed by
|
(this._storeState.roomState === ROOM_STATES.JOINING ||
|
||||||
// MozLoopService, because we can't get a message across to LoopAPI
|
this._storeState.roomState === ROOM_STATES.JOINED ||
|
||||||
// in time whilst a window is closing.
|
this._storeState.roomState === ROOM_STATES.SESSION_CONNECTED ||
|
||||||
if ((nextState === ROOM_STATES.FAILED || !this._isDesktop) && !failedJoinRequest) {
|
this._storeState.roomState === ROOM_STATES.HAS_PARTICIPANTS)) {
|
||||||
loop.request("HangupNow", this._storeState.roomToken,
|
requests.push(["Rooms:Leave", this._storeState.roomToken,
|
||||||
this._storeState.sessionToken, this._storeState.windowId);
|
this._storeState.sessionToken]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loop.requestMulti.apply(null, requests);
|
||||||
|
|
||||||
this.setStoreState({ roomState: nextState });
|
this.setStoreState({ roomState: nextState });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -393,9 +393,6 @@ loop.shared.mixins = (function() {
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!blob) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var url = URL.createObjectURL(blob);
|
var url = URL.createObjectURL(blob);
|
||||||
this.audio = new Audio(url);
|
this.audio = new Audio(url);
|
||||||
@ -414,7 +411,7 @@ loop.shared.mixins = (function() {
|
|||||||
|
|
||||||
if (this._isLoopDesktop()) {
|
if (this._isLoopDesktop()) {
|
||||||
loop.request("GetAudioBlob", name).then(function(result) {
|
loop.request("GetAudioBlob", name).then(function(result) {
|
||||||
if (result && result.isError) {
|
if (result.isError) {
|
||||||
callback(result);
|
callback(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -255,13 +255,6 @@ loop.StandaloneMozLoop = (function(mozL10n) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var kMessageHandlers = {
|
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) {
|
"Rooms:*": function(action, data, reply) {
|
||||||
var funcName = action.split(":").pop();
|
var funcName = action.split(":").pop();
|
||||||
funcName = funcName.charAt(0).toLowerCase() + funcName.substr(1);
|
funcName = funcName.charAt(0).toLowerCase() + funcName.substr(1);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const BASE_URL = Services.prefs.getCharPref("loop.server");
|
const BASE_URL = Services.prefs.getCharPref("loop.server");
|
||||||
|
const { LoopAPI } = Cu.import("chrome://loop/content/modules/MozLoopAPI.jsm", {});
|
||||||
|
|
||||||
function* checkFxA401() {
|
function* checkFxA401() {
|
||||||
let err = MozLoopService.errors.get("login");
|
let err = MozLoopService.errors.get("login");
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
const { LoopAPI } = Cu.import("chrome://loop/content/modules/MozLoopAPI.jsm", {});
|
||||||
var [, gHandlers] = LoopAPI.inspect();
|
var [, gHandlers] = LoopAPI.inspect();
|
||||||
|
|
||||||
add_task(function* test_mozLoop_appVersionInfo() {
|
add_task(function* test_mozLoop_appVersionInfo() {
|
||||||
|
@ -18,17 +18,22 @@ add_task(function* test_mozLoop_nochat() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
add_task(function* test_mozLoop_openchat() {
|
add_task(function* test_mozLoop_openchat() {
|
||||||
let windowId = LoopRooms.open("fake1234");
|
let windowData = {
|
||||||
Assert.ok(isAnyLoopChatOpen(), "chat window should have been opened");
|
roomToken: "fake1234",
|
||||||
|
type: "room"
|
||||||
|
};
|
||||||
|
|
||||||
let chatboxesForRoom = [...Chat.chatboxes].filter(chatbox => {
|
LoopRooms.open(windowData);
|
||||||
return chatbox.src == MozLoopServiceInternal.getChatURL(windowId);
|
Assert.ok(isAnyLoopChatOpen(), "chat window should have been opened");
|
||||||
});
|
|
||||||
Assert.strictEqual(chatboxesForRoom.length, 1, "Only one chatbox should be open");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function* test_mozLoop_hangupAllChatWindows() {
|
add_task(function* test_mozLoop_hangupAllChatWindows() {
|
||||||
LoopRooms.open("fake2345");
|
let windowData = {
|
||||||
|
roomToken: "fake2345",
|
||||||
|
type: "room"
|
||||||
|
};
|
||||||
|
|
||||||
|
LoopRooms.open(windowData);
|
||||||
|
|
||||||
yield promiseWaitForCondition(() => {
|
yield promiseWaitForCondition(() => {
|
||||||
MozLoopService.hangupAllChatWindows();
|
MozLoopService.hangupAllChatWindows();
|
||||||
@ -37,30 +42,3 @@ add_task(function* test_mozLoop_hangupAllChatWindows() {
|
|||||||
|
|
||||||
Assert.ok(!isAnyLoopChatOpen(), "chat window should have been closed");
|
Assert.ok(!isAnyLoopChatOpen(), "chat window should have been closed");
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function* test_mozLoop_hangupOnClose() {
|
|
||||||
let roomToken = "fake1234";
|
|
||||||
|
|
||||||
let hangupNowCalls = [];
|
|
||||||
LoopAPI.stubMessageHandlers({
|
|
||||||
HangupNow: function(message, reply) {
|
|
||||||
hangupNowCalls.push(message);
|
|
||||||
reply();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let windowId = LoopRooms.open(roomToken);
|
|
||||||
|
|
||||||
yield promiseWaitForCondition(() => {
|
|
||||||
MozLoopService.hangupAllChatWindows();
|
|
||||||
return !isAnyLoopChatOpen();
|
|
||||||
});
|
|
||||||
|
|
||||||
Assert.strictEqual(hangupNowCalls.length, 1, "HangupNow handler should be called once");
|
|
||||||
Assert.deepEqual(hangupNowCalls.pop(), {
|
|
||||||
name: "HangupNow",
|
|
||||||
data: [roomToken, windowId]
|
|
||||||
}, "Messages should be the same");
|
|
||||||
|
|
||||||
LoopAPI.restore();
|
|
||||||
});
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
const { LoopAPI } = Cu.import("chrome://loop/content/modules/MozLoopAPI.jsm", {});
|
||||||
var [, gHandlers] = LoopAPI.inspect();
|
var [, gHandlers] = LoopAPI.inspect();
|
||||||
|
|
||||||
function promiseGetMetadata() {
|
function promiseGetMetadata() {
|
||||||
|
@ -6,15 +6,13 @@
|
|||||||
*/
|
*/
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
const { LoopAPI } = Cu.import("chrome://loop/content/modules/MozLoopAPI.jsm", {});
|
||||||
var [, gHandlers] = LoopAPI.inspect();
|
var [, gHandlers] = LoopAPI.inspect();
|
||||||
|
|
||||||
var handlers = [
|
var handlers = [
|
||||||
{ windowId: null }, { windowId: null }
|
{ windowId: null }, { windowId: null }
|
||||||
];
|
];
|
||||||
|
|
||||||
var listenerCount = 41;
|
|
||||||
var listenerIds = [];
|
|
||||||
|
|
||||||
function promiseWindowId() {
|
function promiseWindowId() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
LoopAPI.stub([{
|
LoopAPI.stub([{
|
||||||
@ -26,8 +24,7 @@ function promiseWindowId() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
listenerIds.push(++listenerCount);
|
gHandlers.AddBrowserSharingListener({}, () => {});
|
||||||
gHandlers.AddBrowserSharingListener({ data: [listenerCount] }, () => {});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +78,7 @@ add_task(function* test_singleListener() {
|
|||||||
Assert.notEqual(initialWindowId, newWindowId, "Tab contentWindow IDs shouldn't be the same");
|
Assert.notEqual(initialWindowId, newWindowId, "Tab contentWindow IDs shouldn't be the same");
|
||||||
|
|
||||||
// Now remove the listener.
|
// Now remove the listener.
|
||||||
gHandlers.RemoveBrowserSharingListener({ data: [listenerIds.pop()] }, function() {});
|
gHandlers.RemoveBrowserSharingListener();
|
||||||
|
|
||||||
yield removeTabs();
|
yield removeTabs();
|
||||||
});
|
});
|
||||||
@ -111,7 +108,7 @@ add_task(function* test_multipleListener() {
|
|||||||
Assert.notEqual(initialWindowId0, newWindowId0, "Tab contentWindow IDs shouldn't be the same");
|
Assert.notEqual(initialWindowId0, newWindowId0, "Tab contentWindow IDs shouldn't be the same");
|
||||||
|
|
||||||
// Now remove the first listener.
|
// Now remove the first listener.
|
||||||
gHandlers.RemoveBrowserSharingListener({ data: [listenerIds.pop()] }, function() {});
|
gHandlers.RemoveBrowserSharingListener();
|
||||||
|
|
||||||
// Check that a new tab updates the window id.
|
// Check that a new tab updates the window id.
|
||||||
yield promiseWindowIdReceivedNewTab([handlers[1]]);
|
yield promiseWindowIdReceivedNewTab([handlers[1]]);
|
||||||
@ -124,7 +121,7 @@ add_task(function* test_multipleListener() {
|
|||||||
Assert.notEqual(newWindowId1, nextWindowId1, "Second listener should have updated");
|
Assert.notEqual(newWindowId1, nextWindowId1, "Second listener should have updated");
|
||||||
|
|
||||||
// Cleanup.
|
// Cleanup.
|
||||||
gHandlers.RemoveBrowserSharingListener({ data: [listenerIds.pop()] }, function() {});
|
gHandlers.RemoveBrowserSharingListener();
|
||||||
|
|
||||||
yield removeTabs();
|
yield removeTabs();
|
||||||
});
|
});
|
||||||
@ -181,9 +178,7 @@ add_task(function* test_infoBar() {
|
|||||||
Assert.equal(getInfoBar(), null, "The notification should still be hidden");
|
Assert.equal(getInfoBar(), null, "The notification should still be hidden");
|
||||||
|
|
||||||
// Cleanup.
|
// Cleanup.
|
||||||
for (let listenerId of listenerIds) {
|
gHandlers.RemoveBrowserSharingListener();
|
||||||
gHandlers.RemoveBrowserSharingListener({ data: [listenerId] }, function() {});
|
|
||||||
}
|
|
||||||
yield removeTabs();
|
yield removeTabs();
|
||||||
Services.prefs.clearUserPref(kPrefBrowserSharingInfoBar);
|
Services.prefs.clearUserPref(kPrefBrowserSharingInfoBar);
|
||||||
});
|
});
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
Cu.import("resource://gre/modules/Promise.jsm");
|
Cu.import("resource://gre/modules/Promise.jsm");
|
||||||
const { SocialService } = Cu.import("resource://gre/modules/SocialService.jsm", {});
|
const { SocialService } = Cu.import("resource://gre/modules/SocialService.jsm", {});
|
||||||
|
const { LoopAPI } = Cu.import("chrome://loop/content/modules/MozLoopAPI.jsm", {});
|
||||||
|
|
||||||
var [, gHandlers] = LoopAPI.inspect();
|
var [, gHandlers] = LoopAPI.inspect();
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
const { LoopAPI } = Cu.import("chrome://loop/content/modules/MozLoopAPI.jsm", {});
|
||||||
var [, gHandlers] = LoopAPI.inspect();
|
var [, gHandlers] = LoopAPI.inspect();
|
||||||
var gConstants;
|
var gConstants;
|
||||||
gHandlers.GetAllConstants({}, constants => gConstants = constants);
|
gHandlers.GetAllConstants({}, constants => gConstants = constants);
|
||||||
|
@ -9,7 +9,6 @@ const {
|
|||||||
MozLoopServiceInternal,
|
MozLoopServiceInternal,
|
||||||
MozLoopService
|
MozLoopService
|
||||||
} = Cu.import("chrome://loop/content/modules/MozLoopService.jsm", {});
|
} = Cu.import("chrome://loop/content/modules/MozLoopService.jsm", {});
|
||||||
const { LoopAPI } = Cu.import("chrome://loop/content/modules/MozLoopAPI.jsm", {});
|
|
||||||
const { LoopRooms } = Cu.import("chrome://loop/content/modules/LoopRooms.jsm", {});
|
const { LoopRooms } = Cu.import("chrome://loop/content/modules/LoopRooms.jsm", {});
|
||||||
|
|
||||||
// Cache this value only once, at the beginning of a
|
// Cache this value only once, at the beginning of a
|
||||||
|
@ -27,13 +27,13 @@ describe("loop.store.ActiveRoomStore", function() {
|
|||||||
SetLoopPref: sinon.stub(),
|
SetLoopPref: sinon.stub(),
|
||||||
AddConversationContext: sinon.stub(),
|
AddConversationContext: sinon.stub(),
|
||||||
AddBrowserSharingListener: sinon.stub().returns(42),
|
AddBrowserSharingListener: sinon.stub().returns(42),
|
||||||
HangupNow: sinon.stub(),
|
|
||||||
RemoveBrowserSharingListener: sinon.stub(),
|
RemoveBrowserSharingListener: sinon.stub(),
|
||||||
"Rooms:Get": sinon.stub().returns({
|
"Rooms:Get": sinon.stub().returns({
|
||||||
roomUrl: "http://invalid"
|
roomUrl: "http://invalid"
|
||||||
}),
|
}),
|
||||||
"Rooms:Join": sinon.stub().returns({}),
|
"Rooms:Join": sinon.stub().returns({}),
|
||||||
"Rooms:RefreshMembership": sinon.stub().returns({ expires: 42 }),
|
"Rooms:RefreshMembership": sinon.stub().returns({ expires: 42 }),
|
||||||
|
"Rooms:Leave": sinon.stub(),
|
||||||
"Rooms:SendConnectionStatus": sinon.stub(),
|
"Rooms:SendConnectionStatus": sinon.stub(),
|
||||||
"Rooms:PushSubscription": sinon.stub(),
|
"Rooms:PushSubscription": sinon.stub(),
|
||||||
SetScreenShareState: sinon.stub(),
|
SetScreenShareState: sinon.stub(),
|
||||||
@ -95,8 +95,7 @@ describe("loop.store.ActiveRoomStore", function() {
|
|||||||
store.setStoreState({
|
store.setStoreState({
|
||||||
roomState: ROOM_STATES.JOINED,
|
roomState: ROOM_STATES.JOINED,
|
||||||
roomToken: "fakeToken",
|
roomToken: "fakeToken",
|
||||||
sessionToken: "1627384950",
|
sessionToken: "1627384950"
|
||||||
windowId: "42"
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -179,6 +178,18 @@ describe("loop.store.ActiveRoomStore", function() {
|
|||||||
sinon.assert.calledOnce(fakeMultiplexGum.reset);
|
sinon.assert.calledOnce(fakeMultiplexGum.reset);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should set screen sharing inactive", function() {
|
||||||
|
store.setStoreState({ windowId: "1234" });
|
||||||
|
|
||||||
|
store.roomFailure(new sharedActions.RoomFailure({
|
||||||
|
error: fakeError,
|
||||||
|
failedJoinRequest: false
|
||||||
|
}));
|
||||||
|
|
||||||
|
sinon.assert.calledOnce(requestStubs.SetScreenShareState);
|
||||||
|
sinon.assert.calledWithExactly(requestStubs.SetScreenShareState, "1234", false);
|
||||||
|
});
|
||||||
|
|
||||||
it("should disconnect from the servers via the sdk", function() {
|
it("should disconnect from the servers via the sdk", function() {
|
||||||
store.roomFailure(new sharedActions.RoomFailure({
|
store.roomFailure(new sharedActions.RoomFailure({
|
||||||
error: fakeError,
|
error: fakeError,
|
||||||
@ -201,8 +212,6 @@ describe("loop.store.ActiveRoomStore", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should remove the sharing listener", function() {
|
it("should remove the sharing listener", function() {
|
||||||
sandbox.stub(loop, "unsubscribe");
|
|
||||||
|
|
||||||
// Setup the listener.
|
// Setup the listener.
|
||||||
store.startBrowserShare(new sharedActions.StartBrowserShare());
|
store.startBrowserShare(new sharedActions.StartBrowserShare());
|
||||||
|
|
||||||
@ -212,28 +221,27 @@ describe("loop.store.ActiveRoomStore", function() {
|
|||||||
failedJoinRequest: false
|
failedJoinRequest: false
|
||||||
}));
|
}));
|
||||||
|
|
||||||
sinon.assert.calledOnce(loop.unsubscribe);
|
sinon.assert.calledOnce(requestStubs.RemoveBrowserSharingListener);
|
||||||
sinon.assert.calledWith(loop.unsubscribe, "BrowserSwitch");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should call 'HangupNow' Loop API", function() {
|
it("should call mozLoop.rooms.leave", function() {
|
||||||
store.roomFailure(new sharedActions.RoomFailure({
|
store.roomFailure(new sharedActions.RoomFailure({
|
||||||
error: fakeError,
|
error: fakeError,
|
||||||
failedJoinRequest: false
|
failedJoinRequest: false
|
||||||
}));
|
}));
|
||||||
|
|
||||||
sinon.assert.calledOnce(requestStubs["HangupNow"]);
|
sinon.assert.calledOnce(requestStubs["Rooms:Leave"]);
|
||||||
sinon.assert.calledWithExactly(requestStubs["HangupNow"],
|
sinon.assert.calledWithExactly(requestStubs["Rooms:Leave"],
|
||||||
"fakeToken", "1627384950", "42");
|
"fakeToken", "1627384950");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not call 'HangupNow' Loop API if failedJoinRequest is true", function() {
|
it("should not call mozLoop.rooms.leave if failedJoinRequest is true", function() {
|
||||||
store.roomFailure(new sharedActions.RoomFailure({
|
store.roomFailure(new sharedActions.RoomFailure({
|
||||||
error: fakeError,
|
error: fakeError,
|
||||||
failedJoinRequest: true
|
failedJoinRequest: true
|
||||||
}));
|
}));
|
||||||
|
|
||||||
sinon.assert.notCalled(requestStubs["HangupNow"]);
|
sinon.assert.notCalled(requestStubs["Rooms:Leave"]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1207,8 +1215,7 @@ describe("loop.store.ActiveRoomStore", function() {
|
|||||||
store.setStoreState({
|
store.setStoreState({
|
||||||
roomState: ROOM_STATES.JOINED,
|
roomState: ROOM_STATES.JOINED,
|
||||||
roomToken: "fakeToken",
|
roomToken: "fakeToken",
|
||||||
sessionToken: "1627384950",
|
sessionToken: "1627384950"
|
||||||
windowId: "42"
|
|
||||||
});
|
});
|
||||||
|
|
||||||
connectionFailureAction = new sharedActions.ConnectionFailure({
|
connectionFailureAction = new sharedActions.ConnectionFailure({
|
||||||
@ -1228,6 +1235,15 @@ describe("loop.store.ActiveRoomStore", function() {
|
|||||||
sinon.assert.calledOnce(fakeMultiplexGum.reset);
|
sinon.assert.calledOnce(fakeMultiplexGum.reset);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should set screen sharing inactive", function() {
|
||||||
|
store.setStoreState({ windowId: "1234" });
|
||||||
|
|
||||||
|
store.connectionFailure(connectionFailureAction);
|
||||||
|
|
||||||
|
sinon.assert.calledOnce(requestStubs.SetScreenShareState);
|
||||||
|
sinon.assert.calledWithExactly(requestStubs.SetScreenShareState, "1234", false);
|
||||||
|
});
|
||||||
|
|
||||||
it("should disconnect from the servers via the sdk", function() {
|
it("should disconnect from the servers via the sdk", function() {
|
||||||
store.connectionFailure(connectionFailureAction);
|
store.connectionFailure(connectionFailureAction);
|
||||||
|
|
||||||
@ -1243,25 +1259,22 @@ describe("loop.store.ActiveRoomStore", function() {
|
|||||||
sinon.assert.calledOnce(clearTimeout);
|
sinon.assert.calledOnce(clearTimeout);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should call 'HangupNow' Loop API", function() {
|
it("should call mozLoop.rooms.leave", function() {
|
||||||
store.connectionFailure(connectionFailureAction);
|
store.connectionFailure(connectionFailureAction);
|
||||||
|
|
||||||
sinon.assert.calledOnce(requestStubs["HangupNow"]);
|
sinon.assert.calledOnce(requestStubs["Rooms:Leave"]);
|
||||||
sinon.assert.calledWithExactly(requestStubs["HangupNow"],
|
sinon.assert.calledWithExactly(requestStubs["Rooms:Leave"],
|
||||||
"fakeToken", "1627384950", "42");
|
"fakeToken", "1627384950");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should remove the sharing listener", function() {
|
it("should remove the sharing listener", function() {
|
||||||
sandbox.stub(loop, "unsubscribe");
|
|
||||||
|
|
||||||
// Setup the listener.
|
// Setup the listener.
|
||||||
store.startBrowserShare(new sharedActions.StartBrowserShare());
|
store.startBrowserShare(new sharedActions.StartBrowserShare());
|
||||||
|
|
||||||
// Now simulate connection failure.
|
// Now simulate connection failure.
|
||||||
store.connectionFailure(connectionFailureAction);
|
store.connectionFailure(connectionFailureAction);
|
||||||
|
|
||||||
sinon.assert.calledOnce(loop.unsubscribe);
|
sinon.assert.calledOnce(requestStubs.RemoveBrowserSharingListener);
|
||||||
sinon.assert.calledWith(loop.unsubscribe, "BrowserSwitch");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set the state to `FAILED`", function() {
|
it("should set the state to `FAILED`", function() {
|
||||||
@ -1807,36 +1820,33 @@ describe("loop.store.ActiveRoomStore", function() {
|
|||||||
sinon.assert.calledOnce(clearTimeout);
|
sinon.assert.calledOnce(clearTimeout);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should call 'HangupNow' Loop API", function() {
|
it("should call mozLoop.rooms.leave", function() {
|
||||||
store.windowUnload();
|
store.windowUnload();
|
||||||
|
|
||||||
sinon.assert.calledOnce(requestStubs["HangupNow"]);
|
sinon.assert.calledOnce(requestStubs["Rooms:Leave"]);
|
||||||
sinon.assert.calledWith(requestStubs["HangupNow"], "fakeToken",
|
sinon.assert.calledWithExactly(requestStubs["Rooms:Leave"],
|
||||||
"1627384950", "1234");
|
"fakeToken", "1627384950");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should call 'HangupNow' Loop API if the room state is JOINING",
|
it("should call mozLoop.rooms.leave if the room state is JOINING",
|
||||||
function() {
|
function() {
|
||||||
store.setStoreState({ roomState: ROOM_STATES.JOINING });
|
store.setStoreState({ roomState: ROOM_STATES.JOINING });
|
||||||
|
|
||||||
store.windowUnload();
|
store.windowUnload();
|
||||||
|
|
||||||
sinon.assert.calledOnce(requestStubs["HangupNow"]);
|
sinon.assert.calledOnce(requestStubs["Rooms:Leave"]);
|
||||||
sinon.assert.calledWith(requestStubs["HangupNow"], "fakeToken",
|
sinon.assert.calledWithExactly(requestStubs["Rooms:Leave"],
|
||||||
"1627384950", "1234");
|
"fakeToken", "1627384950");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should remove the sharing listener", function() {
|
it("should remove the sharing listener", function() {
|
||||||
sandbox.stub(loop, "unsubscribe");
|
|
||||||
|
|
||||||
// Setup the listener.
|
// Setup the listener.
|
||||||
store.startBrowserShare(new sharedActions.StartBrowserShare());
|
store.startBrowserShare(new sharedActions.StartBrowserShare());
|
||||||
|
|
||||||
// Now unload the window.
|
// Now unload the window.
|
||||||
store.windowUnload();
|
store.windowUnload();
|
||||||
|
|
||||||
sinon.assert.calledOnce(loop.unsubscribe);
|
sinon.assert.calledOnce(requestStubs.RemoveBrowserSharingListener);
|
||||||
sinon.assert.calledWith(loop.unsubscribe, "BrowserSwitch");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set the state to CLOSING", function() {
|
it("should set the state to CLOSING", function() {
|
||||||
@ -1876,32 +1886,22 @@ describe("loop.store.ActiveRoomStore", function() {
|
|||||||
sinon.assert.calledOnce(clearTimeout);
|
sinon.assert.calledOnce(clearTimeout);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should call 'HangupNow' Loop API", function() {
|
it("should call mozLoop.rooms.leave", function() {
|
||||||
store.leaveRoom();
|
store.leaveRoom();
|
||||||
|
|
||||||
sinon.assert.calledOnce(requestStubs["HangupNow"]);
|
sinon.assert.calledOnce(requestStubs["Rooms:Leave"]);
|
||||||
sinon.assert.calledWith(requestStubs["HangupNow"], "fakeToken", "1627384950");
|
sinon.assert.calledWithExactly(requestStubs["Rooms:Leave"],
|
||||||
});
|
"fakeToken", "1627384950");
|
||||||
|
|
||||||
it("should not call 'HangupNow' Loop API when _isDesktop is true", function() {
|
|
||||||
store._isDesktop = true;
|
|
||||||
|
|
||||||
store.leaveRoom();
|
|
||||||
|
|
||||||
sinon.assert.notCalled(requestStubs["HangupNow"]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should remove the sharing listener", function() {
|
it("should remove the sharing listener", function() {
|
||||||
sandbox.stub(loop, "unsubscribe");
|
|
||||||
|
|
||||||
// Setup the listener.
|
// Setup the listener.
|
||||||
store.startBrowserShare(new sharedActions.StartBrowserShare());
|
store.startBrowserShare(new sharedActions.StartBrowserShare());
|
||||||
|
|
||||||
// Now leave the room.
|
// Now leave the room.
|
||||||
store.leaveRoom();
|
store.leaveRoom();
|
||||||
|
|
||||||
sinon.assert.calledOnce(loop.unsubscribe);
|
sinon.assert.calledOnce(requestStubs.RemoveBrowserSharingListener);
|
||||||
sinon.assert.calledWith(loop.unsubscribe, "BrowserSwitch");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set the state to ENDED", function() {
|
it("should set the state to ENDED", function() {
|
||||||
|
@ -45,22 +45,6 @@ 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() {
|
describe("#setLoopPref", function() {
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
localStorage.removeItem("fakePref");
|
localStorage.removeItem("fakePref");
|
||||||
|
@ -60,40 +60,6 @@ add_test(function test_handleMessage() {
|
|||||||
run_next_test();
|
run_next_test();
|
||||||
});
|
});
|
||||||
|
|
||||||
add_test(function test_sendMessageToHandler() {
|
|
||||||
// Testing error branches.
|
|
||||||
LoopAPI.sendMessageToHandler({
|
|
||||||
name: "WellThisDoesNotExist"
|
|
||||||
}, err => {
|
|
||||||
Assert.ok(err.isError, "An error should be returned");
|
|
||||||
Assert.strictEqual(err.message,
|
|
||||||
"Ouch, no message handler available for 'WellThisDoesNotExist'",
|
|
||||||
"Error messages should match");
|
|
||||||
});
|
|
||||||
|
|
||||||
// Testing correct flow branches.
|
|
||||||
let hangupNowCalls = [];
|
|
||||||
LoopAPI.stubMessageHandlers({
|
|
||||||
HangupNow: function(message, reply) {
|
|
||||||
hangupNowCalls.push(message);
|
|
||||||
reply();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let message = {
|
|
||||||
name: "HangupNow",
|
|
||||||
data: ["fakeToken", 42]
|
|
||||||
};
|
|
||||||
LoopAPI.sendMessageToHandler(message);
|
|
||||||
|
|
||||||
Assert.strictEqual(hangupNowCalls.length, 1, "HangupNow handler should be called once");
|
|
||||||
Assert.deepEqual(hangupNowCalls.pop(), message, "Messages should be the same");
|
|
||||||
|
|
||||||
LoopAPI.restore();
|
|
||||||
|
|
||||||
run_next_test();
|
|
||||||
});
|
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
do_register_cleanup(function() {
|
do_register_cleanup(function() {
|
||||||
LoopAPI.destroy();
|
LoopAPI.destroy();
|
||||||
|
Loading…
Reference in New Issue
Block a user