From ecca4ff873f143e9d52a5944575988aafecb576b Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Tue, 28 Mar 2017 22:29:02 -0400 Subject: [PATCH] Move incognito newtab check into props Auditors: @bridiver Related to #7912 --- js/about/newtab.js | 6 ++++-- test/unit/about/newTabPageTest.js | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/js/about/newtab.js b/js/about/newtab.js index 6097cde692e..13bcbddaa19 100644 --- a/js/about/newtab.js +++ b/js/about/newtab.js @@ -235,7 +235,7 @@ class NewTabPage extends React.Component { return
} - if (window.chrome.extension.inIncognitoContext) { + if (this.props.isIncognito) { return
} @@ -312,5 +312,7 @@ class NewTabPage extends React.Component { module.exports = { component: NewTabPage, - AboutNewTab: React.createElement(DragDropContext(HTML5Backend)(NewTabPage)) + AboutNewTab: React.createElement(DragDropContext(HTML5Backend)(NewTabPage), { + isIncognito: window.chrome && window.chrome.extension && window.chrome.extension.inIncognitoContext + }) } diff --git a/test/unit/about/newTabPageTest.js b/test/unit/about/newTabPageTest.js index 81005d2e334..775f630e6ad 100644 --- a/test/unit/about/newTabPageTest.js +++ b/test/unit/about/newTabPageTest.js @@ -42,7 +42,7 @@ describe('NewTab component unit tests', function () { randomSpy.restore() }) - let wrapper + let wrapper, incognitoWrapper const backgroundImage = { style: { backgroundImage: 'url(testing123.jpg)' @@ -80,6 +80,9 @@ describe('NewTab component unit tests', function () { wrapper = shallow( ) + incognitoWrapper = shallow( + + ) }) describe('Object properties', function () { @@ -148,6 +151,10 @@ describe('NewTab component unit tests', function () { wrapper.setState({showEmptyPage: true}) assert.equal(wrapper.find('div.empty').length, 1) }) + + it('renders an empty div if isIncognito props is true', function () { + assert.equal(incognitoWrapper.find('div.empty').length, 1) + }) }) describe('dashboard', function () {