Bug 1101494 Fix joining a room in guest mode. r=mikedeboer

This commit is contained in:
Mark Banner 2014-11-19 20:05:56 +00:00
parent 80c87b9ae3
commit 064930b20b
2 changed files with 22 additions and 1 deletions

View File

@ -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);
},

View File

@ -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.