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 #5728 from cezaraugusto/feature/newtab/5638
Browse files Browse the repository at this point in the history
Stop about pages from being shown on topSites
  • Loading branch information
bsclifton authored Nov 21, 2016
2 parents 2239454 + bbf0851 commit 99aadab
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/common/state/aboutNewTabState.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const Immutable = require('immutable')
const {makeImmutable} = require('./immutableUtil')
const siteUtil = require('../../../js/state/siteUtil')
const {isSourceAboutUrl} = require('../../../js/lib/appUrlUtil')
const aboutNewTabMaxEntries = 100

const compareSites = (site1, site2) => {
Expand Down Expand Up @@ -67,6 +68,7 @@ const getTopSites = (state) => {
// remove folders; sort by visit count; enforce a max limit
const sites = (state.get('sites') || new Immutable.List())
.filter((site) => !siteUtil.isFolder(site))
.filter((site) => !isSourceAboutUrl(site.get('location')))
.sort(sortCountDescending)
.slice(0, aboutNewTabMaxEntries)

Expand Down
50 changes: 49 additions & 1 deletion test/about/newTabTest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global describe, it, before, beforeEach */

const Brave = require('../lib/brave')
const {urlInput} = require('../lib/selectors')
const {urlInput, navigator, navigatorBookmarked, navigatorNotBookmarked, doneButton} = require('../lib/selectors')
const {getTargetAboutUrl} = require('../../js/lib/appUrlUtil')
const aboutNewTabUrl = getTargetAboutUrl('about:newtab')

Expand Down Expand Up @@ -36,6 +36,31 @@ describe('about:newtab tests', function () {
.loadUrl(aboutNewTabUrl)
}

function * addDemoAboutPages (client) {
yield client
.addSite({ location: 'about:about' })
.addSite({ location: 'about:adblock' })
.addSite({ location: 'about:autofill' })
.addSite({ location: 'about:blank' })
.addSite({ location: 'about:bookmarks' })
.addSite({ location: 'about:brave' })
.addSite({ location: 'about:certerror' })
.addSite({ location: 'about:config' })
.addSite({ location: 'about:downloads' })
.addSite({ location: 'about:error' })
.addSite({ location: 'about:extensions' })
.addSite({ location: 'about:flash' })
.addSite({ location: 'about:history' })
.addSite({ location: 'about:newtab' })
.addSite({ location: 'about:passwords' })
.addSite({ location: 'about:preferences' })
.addSite({ location: 'about:safebrowsing' })
.addSite({ location: 'about:styles' })
.waitForExist('.tab[data-frame-key="1"]')
.tabByIndex(0)
.url(aboutNewTabUrl)
}

describe('page content', function () {
Brave.beforeAll(this)

Expand Down Expand Up @@ -133,5 +158,28 @@ describe('about:newtab tests', function () {
.moveToObject('.timeSaved')
.waitForVisible('.pinnedTopSite')
})

it('doesn\'t show about pages on topSites grid', function * () {
// Adding about pages shouldn't add them to topSites grid
yield addDemoAboutPages(this.app.client)

// Bookmarking an about:page should not add it to grid as well
yield this.app.client
.tabByUrl(aboutNewTabUrl)
.windowParentByUrl(aboutNewTabUrl)
.waitForVisible(navigator)
.moveToObject(navigator)
.waitForVisible(navigatorNotBookmarked)
.click(navigatorNotBookmarked)
.waitForVisible(doneButton)
.click(doneButton)
.moveToObject(navigator)
.waitForVisible(navigatorBookmarked)

yield reloadNewTab(this.app.client)

yield this.app.client
.waitForExist('.topSitesElementFavicon', 3000, true)
})
})
})

0 comments on commit 99aadab

Please sign in to comment.