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 #8580 from romamatusevich/bugfix/8357
Browse files Browse the repository at this point in the history
Fix issue with not working select the last tab preference
  • Loading branch information
bsclifton authored May 1, 2017
2 parents a39196b + 8d7ad5d commit e48ca3e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/state/frameStateUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ function getFramePropsIndex (frames, frameProps) {
function getFrameByLastAccessedTime (frames) {
const frameProps = frames.toJS()
.reduce((pre, cur) => {
return (cur.pinnedLocation === undefined &&
return ([undefined, null].includes(cur.pinnedLocation) &&
cur.lastAccessedTime &&
cur.lastAccessedTime > pre.lastAccessedTime
) ? cur : pre
Expand Down Expand Up @@ -768,5 +768,6 @@ module.exports = {
frameStatePathForFrame,
tabStatePath,
tabStatePathForFrame,
getLastCommittedURL
getLastCommittedURL,
getFrameByLastAccessedTime
}
38 changes: 38 additions & 0 deletions test/unit/state/frameStateUtilTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,4 +354,42 @@ describe('frameStateUtil', function () {
})
})
})

describe('getFrameByLastAccessedTime', function () {
let framesWithLastAccessedTime, framesWithoutLastAccessedTime, framesWithNullifiedLastAccessedTime

beforeEach(function () {
framesWithLastAccessedTime = Immutable.fromJS([
{ key: 2, lastAccessedTime: null },
{ key: 3, lastAccessedTime: 1488184050731 },
{ key: 4, lastAccessedTime: 1488184050711 },
{ key: 5 }
])
framesWithoutLastAccessedTime = Immutable.fromJS([
{ key: 2 },
{ key: 3 },
{ key: 4 }
])
framesWithNullifiedLastAccessedTime = Immutable.fromJS([
{ key: 2, lastAccessedTime: null },
{ key: 3, lastAccessedTime: null },
{ key: 4, lastAccessedTime: null }
])
})

it('gets correct frame by last accessed time', function () {
const result = frameStateUtil.getFrameByLastAccessedTime(framesWithLastAccessedTime)
assert.equal(1, result)
})

it('returns -1 for frames without last accessed time', function () {
const result = frameStateUtil.getFrameByLastAccessedTime(framesWithoutLastAccessedTime)
assert.equal(-1, result)
})

it('returns -1 for frames with nullified last accessed time', function () {
const result = frameStateUtil.getFrameByLastAccessedTime(framesWithNullifiedLastAccessedTime)
assert.equal(-1, result)
})
})
})

0 comments on commit e48ca3e

Please sign in to comment.