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

Commit

Permalink
Merge pull request #7467 from brave/fix/7466
Browse files Browse the repository at this point in the history
fix "Cannot read property 'size' of undefined" error when getting persistent state
  • Loading branch information
bsclifton authored Mar 3, 2017
2 parents a3de55a + 0362926 commit 96dfd5c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/common/state/tabState.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ const api = {
state = makeImmutable(state)

let tabs = state.get('tabs')
if (!tabs) {
return state
}
for (let i = 0; i < tabs.size; i++) {
tabs = tabs.deleteIn([i, field])
}
Expand Down
5 changes: 5 additions & 0 deletions test/unit/app/common/state/tabStateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,11 @@ describe('tabState unit tests', function () {
const expectedAppState = defaultAppState.set('tabs', tabsWithoutField)
assert.deepEqual(newAppState, expectedAppState)
})
it('returns the state (unchanged) if tabs is falsey', function () {
const emptyTabState = defaultAppState.delete('tabs')
const newAppState = tabState.removeTabField(emptyTabState, 'loginRequiredDetail')
assert.equal(newAppState, emptyTabState)
})
})

describe('getPersistentState', function () {
Expand Down

0 comments on commit 96dfd5c

Please sign in to comment.