mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1101494 Fix joining a room in guest mode. r=mikedeboer
This commit is contained in:
parent
80c87b9ae3
commit
064930b20b
@ -6,6 +6,7 @@
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
const {MozLoopService, LOOP_SESSION_TYPE} = Cu.import("resource:///modules/loop/MozLoopService.jsm", {});
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
|
||||
"resource://gre/modules/Promise.jsm");
|
||||
@ -15,6 +16,9 @@ XPCOMUtils.defineLazyGetter(this, "eventEmitter", function() {
|
||||
const {EventEmitter} = Cu.import("resource://gre/modules/devtools/event-emitter.js", {});
|
||||
return new EventEmitter();
|
||||
});
|
||||
XPCOMUtils.defineLazyGetter(this, "gLoopBundle", function() {
|
||||
return Services.strings.createBundle('chrome://browser/locale/loop/loop.properties');
|
||||
});
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["LoopRooms", "roomsPushNotification"];
|
||||
|
||||
@ -327,9 +331,16 @@ let LoopRoomsInternal = {
|
||||
* `Error` object or `null`.
|
||||
*/
|
||||
join: function(roomToken, callback) {
|
||||
let displayName;
|
||||
if (MozLoopService.userProfile && MozLoopService.userProfile.email) {
|
||||
displayName = MozLoopService.userProfile.email;
|
||||
} else {
|
||||
displayName = gLoopBundle.GetStringFromName("display_name_guest");
|
||||
}
|
||||
|
||||
this._postToRoom(roomToken, {
|
||||
action: "join",
|
||||
displayName: MozLoopService.userProfile.email,
|
||||
displayName: displayName,
|
||||
clientMaxSize: CLIENT_MAX_SIZE
|
||||
}, callback);
|
||||
},
|
||||
|
@ -337,6 +337,13 @@ add_task(function* test_roomUpdates() {
|
||||
});
|
||||
|
||||
// Test if joining a room works as expected.
|
||||
add_task(function* test_joinRoomGuest() {
|
||||
// We need these set up for getting the email address.
|
||||
let roomToken = "_nxD4V4FflQ";
|
||||
let joinedData = yield LoopRooms.promise("join", roomToken);
|
||||
Assert.equal(joinedData.action, "join");
|
||||
});
|
||||
|
||||
add_task(function* test_joinRoom() {
|
||||
// We need these set up for getting the email address.
|
||||
Services.prefs.setCharPref("loop.fxa_oauth.profile", JSON.stringify({
|
||||
@ -350,6 +357,9 @@ add_task(function* test_joinRoom() {
|
||||
let joinedData = yield LoopRooms.promise("join", roomToken);
|
||||
Assert.equal(joinedData.action, "join");
|
||||
Assert.equal(joinedData.displayName, "fake@invalid.com");
|
||||
|
||||
Services.prefs.clearUserPref("loop.fxa_oauth.profile");
|
||||
Services.prefs.clearUserPref("loop.fxa_oauth.tokendata");
|
||||
});
|
||||
|
||||
// Test if refreshing a room works as expected.
|
||||
|
Loading…
Reference in New Issue
Block a user