Bug 1219005 - Open a new tab with the room context when joining an existing room. r=mikedeboer

This commit is contained in:
Manuel Casas 2015-11-24 01:03:00 +01:00
parent 8602e16806
commit 84ad1ddbd8
3 changed files with 62 additions and 4 deletions

View File

@ -440,7 +440,16 @@ loop.panel = (function(_, mozL10n) {
this.props.dispatcher.dispatch(new sharedActions.OpenRoom({
roomToken: this.props.room.roomToken
}));
this.closeWindow();
// Open url if needed.
loop.request("getSelectedTabMetadata").then(function(metadata) {
var contextURL = this.props.room.decryptedContext.urls &&
this.props.room.decryptedContext.urls[0].location;
if (contextURL && metadata.url !== contextURL) {
loop.request("OpenURL", contextURL);
}
this.closeWindow();
}.bind(this));
},
handleClick: function(e) {

View File

@ -440,7 +440,16 @@ loop.panel = (function(_, mozL10n) {
this.props.dispatcher.dispatch(new sharedActions.OpenRoom({
roomToken: this.props.room.roomToken
}));
this.closeWindow();
// Open url if needed.
loop.request("getSelectedTabMetadata").then(function(metadata) {
var contextURL = this.props.room.decryptedContext.urls &&
this.props.room.decryptedContext.urls[0].location;
if (contextURL && metadata.url !== contextURL) {
loop.request("OpenURL", contextURL);
}
this.closeWindow();
}.bind(this));
},
handleClick: function(e) {

View File

@ -82,7 +82,10 @@ describe("loop.panel", function() {
roomToken: "QzBbvGmIZWU",
roomUrl: "http://sample/QzBbvGmIZWU",
decryptedContext: {
roomName: roomName
roomName: roomName,
urls: [{
location: "http://testurl.com"
}]
},
maxSize: 2,
participants: [{
@ -665,12 +668,23 @@ describe("loop.panel", function() {
});
describe("Copy button", function() {
var roomEntry;
var roomEntry, openURLStub;
beforeEach(function() {
// Stub to prevent warnings where no stores are set up to handle the
// actions we are testing.
sandbox.stub(dispatcher, "dispatch");
openURLStub = sinon.stub();
LoopMochaUtils.stubLoopRequest({
GetSelectedTabMetadata: function() {
return {
url: "http://invalid.com",
description: "fakeSite"
};
},
OpenURL: openURLStub
});
roomEntry = mountRoomEntry({
deleteRoom: sandbox.stub(),
@ -717,6 +731,32 @@ describe("loop.panel", function() {
sinon.assert.notCalled(dispatcher.dispatch);
});
it("should open a new tab with the room context if it is not the same as the currently open tab", function() {
TestUtils.Simulate.click(roomEntry.refs.roomEntry.getDOMNode());
sinon.assert.calledOnce(openURLStub);
sinon.assert.calledWithExactly(openURLStub, "http://testurl.com");
});
it("should not open a new tab if the context is the same as the currently open tab", function() {
LoopMochaUtils.stubLoopRequest({
GetSelectedTabMetadata: function() {
return {
url: "http://testurl.com",
description: "fakeSite"
};
}
});
roomEntry = mountRoomEntry({
deleteRoom: sandbox.stub(),
isOpenedRoom: false,
room: new loop.store.Room(roomData)
});
TestUtils.Simulate.click(roomEntry.refs.roomEntry.getDOMNode());
sinon.assert.notCalled(openURLStub);
});
});
});