mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-02 07:05:24 +00:00
Bug 1219005 - Open a new tab with the room context when joining an existing room. r=mikedeboer
This commit is contained in:
parent
8602e16806
commit
84ad1ddbd8
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user