Bug 1105520 - Open Loop room conversation window right after it's created. r=mikedeboer
This commit is contained in:
@@ -51,7 +51,7 @@ const cloneErrorObject = function(error, targetWindow) {
|
||||
if (typeof value != "string" && typeof value != "number") {
|
||||
value = String(value);
|
||||
}
|
||||
|
||||
|
||||
Object.defineProperty(Cu.waiveXrays(obj), prop, {
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
@@ -115,6 +115,8 @@ const injectObjectAPI = function(api, targetWindow) {
|
||||
injectedAPI[func] = function(...params) {
|
||||
let lastParam = params.pop();
|
||||
let callbackIsFunction = (typeof lastParam == "function");
|
||||
// Clone params coming from content to the current scope.
|
||||
params = [cloneValueInto(p, api) for (p of params)];
|
||||
|
||||
// If the last parameter is a function, assume its a callback
|
||||
// and wrap it differently.
|
||||
@@ -134,6 +136,7 @@ const injectObjectAPI = function(api, targetWindow) {
|
||||
});
|
||||
} else {
|
||||
try {
|
||||
lastParam = cloneValueInto(lastParam, api);
|
||||
return cloneValueInto(api[func](...params, lastParam), targetWindow);
|
||||
} catch (ex) {
|
||||
return cloneValueInto(ex, targetWindow);
|
||||
|
||||
@@ -239,11 +239,16 @@ loop.store = loop.store || {};
|
||||
expiresIn: this.defaultExpiresIn
|
||||
};
|
||||
|
||||
this._mozLoop.rooms.create(roomCreationData, function(err) {
|
||||
this._mozLoop.rooms.create(roomCreationData, function(err, createdRoom) {
|
||||
this.setStoreState({pendingCreation: false});
|
||||
if (err) {
|
||||
this.dispatchAction(new sharedActions.CreateRoomError({error: err}));
|
||||
return;
|
||||
}
|
||||
// Opens the newly created room
|
||||
this.dispatchAction(new sharedActions.OpenRoom({
|
||||
roomToken: createdRoom.roomToken
|
||||
}));
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ describe("loop.store.RoomStore", function () {
|
||||
rooms: {
|
||||
create: function() {},
|
||||
getAll: function() {},
|
||||
open: function() {},
|
||||
on: sandbox.stub()
|
||||
}
|
||||
};
|
||||
@@ -230,13 +231,28 @@ describe("loop.store.RoomStore", function () {
|
||||
it("should switch the pendingCreation state flag to false once the " +
|
||||
"operation is done", function() {
|
||||
sandbox.stub(fakeMozLoop.rooms, "create", function(data, cb) {
|
||||
cb();
|
||||
cb(null, {roomToken: "fakeToken"});
|
||||
});
|
||||
|
||||
store.createRoom(new sharedActions.CreateRoom(fakeRoomCreationData));
|
||||
|
||||
expect(store.getStoreState().pendingCreation).eql(false);
|
||||
});
|
||||
|
||||
it("should dispatch an OpenRoom action once the operation is done",
|
||||
function() {
|
||||
var dispatch = sandbox.stub(dispatcher, "dispatch");
|
||||
sandbox.stub(fakeMozLoop.rooms, "create", function(data, cb) {
|
||||
cb(null, {roomToken: "fakeToken"});
|
||||
});
|
||||
|
||||
store.createRoom(new sharedActions.CreateRoom(fakeRoomCreationData));
|
||||
|
||||
sinon.assert.calledOnce(dispatch);
|
||||
sinon.assert.calledWithExactly(dispatch, new sharedActions.OpenRoom({
|
||||
roomToken: "fakeToken"
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe("#copyRoomUrl", function() {
|
||||
|
||||
Reference in New Issue
Block a user