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

Fix issue with not working select the last tab preference #8580

Merged
merged 1 commit into from
May 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
})
})
})