Skip to content

Commit

Permalink
Merge pull request brave#10314 from brave/emoji-titlemode
Browse files Browse the repository at this point in the history
added emoji-regex in package.json, modified urlBar.js to remove emoji
  • Loading branch information
cezaraugusto authored Aug 7, 2017
2 parents 821b207 + c5bcef6 commit 1bab9a7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/renderer/components/navigation/urlBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const historyUtil = require('../../../common/lib/historyUtil')

// Icons
const iconNoScript = require('../../../../img/url-bar-no-script.svg')
const emojiRegex = require('emoji-regex')

class UrlBar extends React.Component {
constructor (props) {
Expand Down Expand Up @@ -376,7 +377,7 @@ class UrlBar extends React.Component {
// For about:newtab we don't want the top of the browser saying New Tab
// Instead just show "Brave"
return ['about:blank', 'about:newtab'].includes(this.props.urlbarLocation)
? '' : this.props.title
? '' : this.props.title.replace(emojiRegex(), '')
}

get loadTime () {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"clipboard-copy": "^1.0.0",
"electron-localshortcut": "^0.6.0",
"electron-squirrel-startup": "brave/electron-squirrel-startup",
"emoji-regex": "^6.5.1",
"file-loader": "^0.8.5",
"font-awesome": "^4.5.0",
"font-awesome-webpack": "0.0.4",
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/title_with_emoji.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>page with 🐉 dragon emoji</title>
</head>
<body>
<h1>wow such 🐉 very amazing</h1>
</body>
</html>
16 changes: 16 additions & 0 deletions test/navbar-components/navigationBarTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,22 @@ describe('navigationBar tests', function () {
.waitForElementCount(titleBar, 0)
yield selectsText(this.app.client, page1Url)
})

it('does not show emoji in title mode', function * () {
const emojiPage = Brave.server.url('title_with_emoji.html')
const emojiPageHost = urlParse(emojiPage).host
yield this.app.client
.tabByUrl(Brave.newTabUrl)
.loadUrl(emojiPage)
.windowParentByUrl(emojiPage)
.activateTitleMode()
.click(activeWebview)
.windowParentByUrl(emojiPage)
.waitForExist(titleBar)
.waitForTextValue(titleBar, `${emojiPageHost} | page with dragon emoji`)
.isExisting('🐉').then((isExisting) => assert(!isExisting))
.isExisting(navigatorLoadTime).then((isExisting) => assert(!isExisting))
})
})

describe('page without a title', function () {
Expand Down

0 comments on commit 1bab9a7

Please sign in to comment.