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 #6922 from NejcZdovc/hotfix/#6913-multiple-homepages
Browse files Browse the repository at this point in the history
Multiple home page URL
  • Loading branch information
bsclifton authored Feb 1, 2017
2 parents 95426b6 + e40840c commit 5561027
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ newTabHomePage=Home page
newTabDefaultSearchEngine=Default search engine
newTabEmpty=Blank page
myHomepage=My home page is
multipleHomePages.title=Multiple home pages
aboutBlank=about:blank
default=Default
searchEngine=Search Engine
Expand Down
9 changes: 8 additions & 1 deletion js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,14 @@ class GeneralTab extends ImmutableComponent {
<option data-l10n-id='newTabEmpty' value={newTabMode.EMPTY_NEW_TAB} />
</SettingDropdown>
</SettingItem>
<SettingItem dataL10nId='myHomepage'>
<div className='iconTitle'>
<span data-l10n-id='myHomepage' />
<span className='fa fa-info-circle iconLink' onClick={aboutActions.newFrame.bind(null, {
location: 'https://github.com/brave/browser-laptop/wiki/End-User-FAQ#how-to-set-up-multiple-home-pages'
}, true)}
data-l10n-id='multipleHomePages' />
</div>
<SettingItem>
<SettingTextbox
spellCheck='false'
data-l10n-id='homepageInput'
Expand Down
3 changes: 2 additions & 1 deletion js/lib/appUrlUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ module.exports.newFrameUrl = function () {

switch (settingValue) {
case newTabMode.HOMEPAGE:
return getSetting(settings.HOMEPAGE) || 'about:blank'
const homePage = (getSetting(settings.HOMEPAGE) || 'about:blank').split('|')
return homePage[0]

case newTabMode.DEFAULT_SEARCH_ENGINE:
const searchProviders = require('../data/searchProviders').providers
Expand Down
2 changes: 1 addition & 1 deletion js/stores/appStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ const handleAppAction = (action) => {

// initialize frames state
let frames = []
if (frameOpts) {
if (frameOpts && Object.keys(frameOpts).length > 0) {
if (frameOpts.forEach) {
frames = frameOpts
} else {
Expand Down
17 changes: 16 additions & 1 deletion less/about/preferences.less
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ span.settingsListCopy {

.settingsList {
.settingItem {

> *:not(.switchControl) {
margin-bottom: 10px;
min-width: 160px;
Expand Down Expand Up @@ -365,6 +364,22 @@ span.settingsListCopy {
.subtext {
font-size: 0.95em;
}

.iconTitle {
margin: 1.2em 2px 7px;
color: #444444;
font-size: 0.9em;

span {
display: inline-block;
}

.iconLink {
margin-left: 5px;
cursor: pointer;
vertical-align: middle;
}
}
}

input[type="checkbox"][disabled] {
Expand Down
20 changes: 20 additions & 0 deletions test/about/newTabTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {getTargetAboutUrl} = require('../../js/lib/appUrlUtil')
const settings = require('../../js/constants/settings')
const {newTabMode} = require('../../app/common/constants/settingsEnums')
const aboutNewTabUrl = getTargetAboutUrl('about:newtab')
const messages = require('../../js/constants/messages')

describe('about:newtab tests', function () {
function * setup (client) {
Expand Down Expand Up @@ -87,6 +88,25 @@ describe('about:newtab tests', function () {
})
})

describe('with NEWTAB_MODE === HOMEPAGE', function () {
const page1 = 'https://start.duckduckgo.com/'
const page2 = 'https://brave.com/'

Brave.beforeAll(this)

before(function * () {
yield setup(this.app.client)
yield this.app.client.changeSetting(settings.NEWTAB_MODE, newTabMode.HOMEPAGE)
yield this.app.client.changeSetting(settings.HOMEPAGE, `${page1}|${page2}`)
})

it('multiple homepages', function * () {
yield this.app.client
.ipcSend(messages.SHORTCUT_NEW_FRAME)
.waitForUrl(page1)
})
})

describe.skip('with NEWTAB_MODE === NEW_TAB_PAGE', function () {
describe('page content', function () {
Brave.beforeAll(this)
Expand Down
45 changes: 44 additions & 1 deletion test/about/preferencesTest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* global describe, it, beforeEach */
/* global describe, it, beforeEach, before, after */

const Brave = require('../lib/brave')
const {urlInput, homepageInput} = require('../lib/selectors')
const settings = require('../../js/constants/settings')
const {startsWithOption, newTabMode} = require('../../app/common/constants/settingsEnums')

const prefsUrl = 'about:preferences'

Expand All @@ -12,6 +14,10 @@ function * setup (client) {
.waitForVisible(urlInput)
}

function * setupBrave (client) {
Brave.addCommands()
}

describe('General Panel', function () {
describe('homepage', function () {
Brave.beforeEach(this)
Expand All @@ -33,4 +39,41 @@ describe('General Panel', function () {
})
})
})

describe('homepage multiple', function () {
Brave.beforeAllServerSetup(this)

before(function * () {
yield Brave.startApp()
yield setupBrave(Brave.app.client)
})

it('from scratch', function * () {
const page1 = 'https://start.duckduckgo.com/'
const page2 = 'https://brave.com/'

yield Brave.app.client.changeSetting(settings.STARTUP_MODE, startsWithOption.HOMEPAGE)
// TODO remove when #6920 is fixed
yield Brave.app.client.changeSetting(settings.NEWTAB_MODE, newTabMode.HOMEPAGE)
yield Brave.app.client.changeSetting(settings.HOMEPAGE, `${page1}|${page2}`)

yield Brave.stopApp(false)
yield Brave.startApp()
yield setupBrave(Brave.app.client)
yield Brave.app.client
.waitForBrowserWindow()
.waitUntil(function () {
return this.getWindowState().then((val) => {
return (val.value.tabs.length === 2 &&
val.value.tabs[0].location === page1 &&
val.value.tabs[1].location === page2
)
})
})
})

after(function * () {
yield Brave.stopApp()
})
})
})

0 comments on commit 5561027

Please sign in to comment.