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

Commit

Permalink
Show punycode URL in homepage
Browse files Browse the repository at this point in the history
Fix #4747

Auditors: @bbondy

Test Plan: covered by automated test
  • Loading branch information
diracdeltas committed Oct 19, 2016
1 parent e12fca0 commit c061ebc
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
8 changes: 6 additions & 2 deletions js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const SortableTable = require('../components/sortableTable')
const Button = require('../components/button')
const searchProviders = require('../data/searchProviders')
const moment = require('moment')
const punycode = require('punycode')

const adblock = appConfig.resourceNames.ADBLOCK
const cookieblock = appConfig.resourceNames.COOKIEBLOCK
Expand Down Expand Up @@ -613,7 +614,10 @@ class GeneralTab extends ImmutableComponent {
<option data-l10n-id={lc} value={lc} />
)
})
const homepageValue = getSetting(settings.HOMEPAGE, this.props.settings)
var homepageValue = getSetting(settings.HOMEPAGE, this.props.settings)
if (typeof homepageValue === 'string') {
homepageValue = punycode.toASCII(homepageValue)
}
const homepage = homepageValue && homepageValue.trim()
const disableShowHomeButton = !homepage || !homepage.length
const defaultLanguage = this.props.languageCodes.find((lang) => lang.includes(navigator.language)) || 'en-US'
Expand All @@ -638,7 +642,7 @@ class GeneralTab extends ImmutableComponent {
<SettingItem dataL10nId='myHomepage'>
<input spellCheck='false'
data-l10n-id='homepageInput'
value={getSetting(settings.HOMEPAGE, this.props.settings)}
value={homepageValue}
onChange={changeSetting.bind(null, this.onChangeSetting, settings.HOMEPAGE)} />
</SettingItem>
<SettingCheckbox dataL10nId='showHomeButton' prefKey={settings.SHOW_HOME_BUTTON}
Expand Down
36 changes: 36 additions & 0 deletions test/about/preferencesTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* global describe, it, beforeEach */

const Brave = require('../lib/brave')
const {urlInput, homepageInput} = require('../lib/selectors')

const prefsUrl = 'about:preferences'

function * setup (client) {
yield client
.waitForUrl(Brave.newTabUrl)
.waitForBrowserWindow()
.waitForVisible(urlInput)
}

describe('General Panel', function () {
describe('homepage', function () {
Brave.beforeEach(this)
beforeEach(function * () {
yield setup(this.app.client)
})

it('homepage displays punycode', function * () {
yield this.app.client
.tabByIndex(0)
.loadUrl(prefsUrl)
.waitForVisible(homepageInput)
.click(homepageInput)
.keys('а')
.waitUntil(function () {
return this.getValue(homepageInput).then((val) => {
return val === 'https://www.brave.xn--com-7cd'
})
})
})
})
})
1 change: 1 addition & 0 deletions test/lib/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module.exports = {
securityTab: '[data-l10n-id="security"]',
paymentsTab: '[data-l10n-id="payments"]',
saveButton: '[data-l10n-id="save"]',
homepageInput: '[data-l10n-id="homepageInput"]',
walletSwitch: '.enablePaymentsSwitch .switchBackground',
addFundsButton: '.addFunds',
fundsSelectBox: '#fundsSelectBox',
Expand Down

0 comments on commit c061ebc

Please sign in to comment.