From 545c7a62e3e10a962ad04481e122cdb4e47b56e7 Mon Sep 17 00:00:00 2001 From: yan Date: Mon, 8 Feb 2016 13:41:13 -0800 Subject: [PATCH] fixes to showing page host in titleMode Auditors: @bbondy --- js/components/urlBar.js | 24 ++++++++++-------------- test/lib/selectors.js | 3 ++- test/navigationBarTest.js | 9 ++++----- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/js/components/urlBar.js b/js/components/urlBar.js index 8f70c6a9ad6..8ed1608581f 100644 --- a/js/components/urlBar.js +++ b/js/components/urlBar.js @@ -173,17 +173,16 @@ class UrlBar extends ImmutableComponent { this.updateDOM() } - get titleValue () { - const parsedUrl = urlParse(this.props.activeFrameProps.get('location')) - let titlePrefix = '' - if (parsedUrl.protocol !== 'about:') { - titlePrefix += parsedUrl.host + ' | ' - } + get hostValue () { + const parsed = urlParse(this.props.activeFrameProps.get('location')) + return parsed.host && parsed.protocol !== 'about:' ? parsed.host : '' + } + get titleValue () { // 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.urlbar.get('location')) - ? '' : titlePrefix + this.props.activeFrameProps.get('title') + ? '' : this.props.activeFrameProps.get('title') } get locationValue () { @@ -191,11 +190,6 @@ class UrlBar extends ImmutableComponent { ? '' : this.props.urlbar.get('location') } - get inputValue () { - return this.props.titleMode - ? this.titleValue : this.locationValue - } - get loadTime () { let loadTime = '' if (this.props.activeFrameProps.get('startLoadTime') && @@ -248,7 +242,9 @@ class UrlBar extends ImmutableComponent { extendedValidation: this.extendedValidationSSL })}/>
- {this.titleValue} + {this.hostValue} + {this.hostValue && this.titleValue ? ' | ' : ''} + {this.titleValue}
val === host + ' | Page 1') + return this.getText(titleBar).then(val => val === host + ' | Page 1') }) .isExisting(navigatorLoadTime).then(isExisting => assert(!isExisting)) }) @@ -86,7 +86,7 @@ describe('urlbar', function () { yield this.app.client .ipcSend('shortcut-focus-url', false) .waitUntil(function () { - return this.getValue(urlInput).then(val => val === page1Url) + return this.getCssProperty(titleBar, 'display').then(display => display.value === 'none') }) yield selectsText(this.app.client, page1Url) }) @@ -102,10 +102,9 @@ describe('urlbar', function () { }) it('does not have title mode', function *() { - let page_no_title = this.page_no_title yield this.app.client .waitUntil(function () { - return this.getValue(urlInput).then(val => val === page_no_title) + return this.getCssProperty(titleBar, 'display').then(display => display.value === 'none') }) .waitForExist(navigatorLoadTime) })