From 587fa154634801045a952a92f161d49850e3c851 Mon Sep 17 00:00:00 2001 From: prasanthp96 Date: Thu, 3 Aug 2017 23:57:44 +0530 Subject: [PATCH 1/2] added emoji-regex in package.json, modified urlBar.js to remove emoji --- app/renderer/components/navigation/urlBar.js | 3 ++- package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/renderer/components/navigation/urlBar.js b/app/renderer/components/navigation/urlBar.js index 624c0592ee4..68488629191 100644 --- a/app/renderer/components/navigation/urlBar.js +++ b/app/renderer/components/navigation/urlBar.js @@ -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) { @@ -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 () { diff --git a/package.json b/package.json index c6fe0870633..f0ae3e5b9fc 100644 --- a/package.json +++ b/package.json @@ -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", From c5bcef68cb4be361d62a2c669ea356667e1f140d Mon Sep 17 00:00:00 2001 From: Cezar Augusto Date: Mon, 7 Aug 2017 01:07:59 -0300 Subject: [PATCH 2/2] add test for titlemode regarding emoji in page title --- test/fixtures/title_with_emoji.html | 10 ++++++++++ test/navbar-components/navigationBarTest.js | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test/fixtures/title_with_emoji.html diff --git a/test/fixtures/title_with_emoji.html b/test/fixtures/title_with_emoji.html new file mode 100644 index 00000000000..ef43899b94b --- /dev/null +++ b/test/fixtures/title_with_emoji.html @@ -0,0 +1,10 @@ + + + + + page with 🐉 dragon emoji + + +

wow such 🐉 very amazing

+ + diff --git a/test/navbar-components/navigationBarTest.js b/test/navbar-components/navigationBarTest.js index d54749830f8..01d9e1216d8 100644 --- a/test/navbar-components/navigationBarTest.js +++ b/test/navbar-components/navigationBarTest.js @@ -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 () {