Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Move incognito newtab check into props
Browse files Browse the repository at this point in the history
Auditors: @bridiver

Related to #7912
  • Loading branch information
bbondy committed Mar 29, 2017
1 parent 0d61173 commit 6ae4e0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions js/about/newtab.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class NewTabPage extends React.Component {
return <div className='empty' />
}

if (window.chrome.extension.inIncognitoContext) {
if (this.props.isIncognito) {
return <div className='empty' />
}

Expand Down Expand Up @@ -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
})
}
9 changes: 8 additions & 1 deletion test/unit/about/newTabPageTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('NewTab component unit tests', function () {
randomSpy.restore()
})

let wrapper
let wrapper, incognitoWrapper
const backgroundImage = {
style: {
backgroundImage: 'url(testing123.jpg)'
Expand Down Expand Up @@ -80,6 +80,9 @@ describe('NewTab component unit tests', function () {
wrapper = shallow(
<NewTabPage />
)
incognitoWrapper = shallow(
<NewTabPage isIncognito />
)
})

describe('Object properties', function () {
Expand Down Expand Up @@ -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 () {
Expand Down

0 comments on commit 6ae4e0d

Please sign in to comment.