Bug 1159199 - Clicking the context indicator in the Loop panel should close the panel after opening the url. r=mikedeboer

This commit is contained in:
Mark Banner 2015-04-28 13:51:27 +01:00
parent ce4b360fc0
commit 5f9517ba60
3 changed files with 20 additions and 0 deletions

View File

@ -432,6 +432,8 @@ loop.panel = (function(_, mozL10n) {
}); });
var RoomEntryContextItem = React.createClass({displayName: "RoomEntryContextItem", var RoomEntryContextItem = React.createClass({displayName: "RoomEntryContextItem",
mixins: [loop.shared.mixins.WindowCloseMixin],
propTypes: { propTypes: {
mozLoop: React.PropTypes.object.isRequired, mozLoop: React.PropTypes.object.isRequired,
roomUrls: React.PropTypes.object roomUrls: React.PropTypes.object
@ -441,6 +443,7 @@ loop.panel = (function(_, mozL10n) {
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
this.props.mozLoop.openURL(event.currentTarget.href); this.props.mozLoop.openURL(event.currentTarget.href);
this.closeWindow();
}, },
render: function() { render: function() {

View File

@ -432,6 +432,8 @@ loop.panel = (function(_, mozL10n) {
}); });
var RoomEntryContextItem = React.createClass({ var RoomEntryContextItem = React.createClass({
mixins: [loop.shared.mixins.WindowCloseMixin],
propTypes: { propTypes: {
mozLoop: React.PropTypes.object.isRequired, mozLoop: React.PropTypes.object.isRequired,
roomUrls: React.PropTypes.object roomUrls: React.PropTypes.object
@ -441,6 +443,7 @@ loop.panel = (function(_, mozL10n) {
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
this.props.mozLoop.openURL(event.currentTarget.href); this.props.mozLoop.openURL(event.currentTarget.href);
this.closeWindow();
}, },
render: function() { render: function() {

View File

@ -614,6 +614,20 @@ describe("loop.panel", function() {
sinon.assert.calledOnce(fakeMozLoop.openURL); sinon.assert.calledOnce(fakeMozLoop.openURL);
sinon.assert.calledWithExactly(fakeMozLoop.openURL, "http://invalid/"); sinon.assert.calledWithExactly(fakeMozLoop.openURL, "http://invalid/");
}); });
it("should call close the panel after opening a url", function() {
roomData.decryptedContext.urls = [{
description: "invalid entry",
location: "http://invalid/",
thumbnail: "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
}];
roomEntry = mountEntryForContext();
TestUtils.Simulate.click(roomEntry.getDOMNode().querySelector("a"));
sinon.assert.calledOnce(fakeWindow.close);
});
}); });
describe("Room Entry click", function() { describe("Room Entry click", function() {