Skip to content

Commit

Permalink
Fixed display for multiplehomepages
Browse files Browse the repository at this point in the history
Resolves brave#7442

Auditors: @darkdh

Test Plan:
- described in brave#7442
  • Loading branch information
NejcZdovc committed Mar 2, 2017
1 parent 793c175 commit 3e7999c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 13 deletions.
8 changes: 6 additions & 2 deletions js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,17 +561,21 @@ class GeneralTab extends ImmutableComponent {
}

render () {
var languageOptions = this.props.languageCodes.map(function (lc) {
const languageOptions = this.props.languageCodes.map(function (lc) {
return (
<option data-l10n-id={lc} value={lc} />
)
})
var homepageValue = getSetting(settings.HOMEPAGE, this.props.settings)

let homepageValue = getSetting(settings.HOMEPAGE, this.props.settings)
if (typeof homepageValue === 'string') {
const punycodeUrl = UrlUtil.getPunycodeUrl(homepageValue)
if (punycodeUrl.replace(/\/$/, '') !== homepageValue) {
homepageValue = UrlUtil.getPunycodeUrl(homepageValue)
}

// we use | as a separator for multiple home pages
homepageValue = homepageValue.replace(/%7C/g, '|')
}
const homepage = homepageValue && homepageValue.trim()
const disableShowHomeButton = !homepage || !homepage.length
Expand Down
20 changes: 18 additions & 2 deletions test/about/preferencesTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,22 @@ describe('General Panel', function () {
.loadUrl(prefsUrl)
.waitForVisible(homepageInput)
.click(homepageInput)
.keys('\uE010') // send END key
.keys(Brave.keys.END)
.keys('а')
.waitUntil(function () {
return this.getValue(homepageInput).then((val) => {
return val === 'https://www.brave.xn--com-8cd/'
})
})
})

it('homepage can be backspaced', function * () {
yield this.app.client
.tabByIndex(0)
.loadUrl(prefsUrl)
.waitForVisible(homepageInput)
.click(homepageInput)
.keys('\uE010') // send END key
.keys(Brave.keys.END)
.keys('/')
.keys('1')
.keys(Brave.keys.BACKSPACE)
Expand All @@ -57,6 +58,21 @@ describe('General Panel', function () {
})
})
})

it('direct input', function * () {
yield this.app.client
.tabByIndex(0)
.loadUrl(prefsUrl)
.waitForVisible(homepageInput)
.click(homepageInput)
.keys(Brave.keys.END)
.keys('|https://duckduckgo.com')
.waitUntil(function () {
return this.getValue(homepageInput).then((val) => {
return val === 'https://www.brave.com/|https://duckduckgo.com'
})
})
})
})

describe('homepage multiple', function () {
Expand Down
8 changes: 4 additions & 4 deletions test/components/autofillTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ describe('Autofill', function () {
.windowByUrl(Brave.browserWindowUrl)
.waitForVisible(autofillAddressPanel)
.click('#phone')
.keys('\uE010') // send END key
.keys(Brave.keys.END)
.keys('123')
.click('#email')
.keys('\uE010') // send END key
.keys(Brave.keys.END)
.keys('mm')
.click(saveAddressButton)
.waitUntil(function () {
Expand Down Expand Up @@ -254,10 +254,10 @@ describe('Autofill', function () {
.windowByUrl(Brave.browserWindowUrl)
.waitForVisible(autofillCreditCardPanel)
.click('#nameOnCard')
.keys('\uE010') // send END key
.keys(Brave.keys.END)
.keys('123')
.click('#creditCardNumber')
.keys('\uE010') // send END key
.keys(Brave.keys.END)
.keys('123')
.selectByValue('.expMonthSelect', (expMonth + 1).toString())
.selectByValue('.expYearSelect', (expYear + 1).toString())
Expand Down
8 changes: 4 additions & 4 deletions test/components/bookmarksTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ describe('bookmark tests', function () {
.click(navigatorBookmarked)
.waitForVisible(doneButton)
.setValue('#bookmarkName input', 'https://www.brave.com')
.keys('\uE010') // send END key
.keys(Brave.keys.END)
.keys('а')
.getValue('#bookmarkName input').should.eventually.be.equal('https://www.brave.xn--com-8cd/')
.setValue('#bookmarkLocation input', 'https://www.brave.com')
.keys('\uE010') // send END key
.keys(Brave.keys.END)
.keys('а')
.getValue('#bookmarkLocation input').should.eventually.be.equal('https://www.brave.xn--com-8cd/')
.click(removeButton)
Expand All @@ -81,13 +81,13 @@ describe('bookmark tests', function () {
.click(navigatorBookmarked)
.waitForVisible(doneButton)
.setValue('#bookmarkName input', 'https://www.brave.com/1')
.keys('\uE010') // send END key
.keys(Brave.keys.END)
.keys(Brave.keys.BACKSPACE)
.keys(Brave.keys.BACKSPACE)
.keys(Brave.keys.BACKSPACE)
.getValue('#bookmarkName input').should.eventually.be.equal('https://www.brave.co')
.setValue('#bookmarkLocation input', 'https://www.brave.com/1')
.keys('\uE010') // send END key
.keys(Brave.keys.END)
.keys(Brave.keys.BACKSPACE)
.keys(Brave.keys.BACKSPACE)
.keys(Brave.keys.BACKSPACE)
Expand Down
3 changes: 2 additions & 1 deletion test/lib/brave.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ var exports = {
DELETE: '\ue017',
DOWN: '\ue015',
UP: '\ue013',
PAGEDOWN: '\uE00F'
PAGEDOWN: '\uE00F',
END: '\uE010'
},

defaultTimeout: 10000,
Expand Down

0 comments on commit 3e7999c

Please sign in to comment.