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

Commit

Permalink
Update tab title on back/forward fixes #3200
Browse files Browse the repository at this point in the history
  • Loading branch information
Radoslav Vitanov committed Aug 17, 2016
1 parent 9772ea2 commit e2ddbea
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
5 changes: 5 additions & 0 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ class Frame extends ImmutableComponent {
if (this.props.findbarShown) {
this.onFindHide()
}

for (let message in this.notificationCallbacks) {
appActions.hideMessageBox(message)
}
Expand All @@ -773,6 +774,10 @@ class Frame extends ImmutableComponent {
this.webview.focus()
}
windowActions.setNavigated(e.url, this.props.frameKey, false)
// After navigating to the URL, set correct frame title
let webContents = this.webview.getWebContents()
let title = webContents.getTitleAtIndex(webContents.getCurrentEntryIndex())
windowActions.setFrameTitle(this.frame, title)
})
this.webview.addEventListener('crashed', (e) => {
windowActions.setFrameError(this.frame, {
Expand Down
44 changes: 43 additions & 1 deletion test/components/tabTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const Brave = require('../lib/brave')
const messages = require('../../js/constants/messages')
const settings = require('../../js/constants/settings')
const {urlInput} = require('../lib/selectors')
const {urlInput, backButton, forwardButton, activeTabTitle} = require('../lib/selectors')

describe('tabs', function () {
function * setup (client) {
Expand All @@ -15,6 +15,48 @@ describe('tabs', function () {
.waitForVisible(urlInput)
}

describe('back forward actions', function () {
Brave.beforeAll(this)
before(function * () {
yield setup(this.app.client)
})

it('sets correct title', function * () {
var page1 = Brave.server.url('page1.html')
var page2 = Brave.server.url('page2.html')

yield this.app.client
.tabByIndex(0)
.loadUrl(page1)
.windowByUrl(Brave.browserWindowUrl)
.waitUntil(function () {
return this.getText(activeTabTitle)
.then((title) => title === 'Page 1')
})
.tabByIndex(0)
.loadUrl(page2)
.windowByUrl(Brave.browserWindowUrl)
.waitUntil(function () {
return this.getText(activeTabTitle)
.then((title) => title === 'Page 2')
})
.click(backButton)
.waitForUrl(page1)
.windowByUrl(Brave.browserWindowUrl)
.waitUntil(function () {
return this.getText(activeTabTitle)
.then((title) => title === 'Page 1')
})
.click(forwardButton)
.waitForUrl(page2)
.windowByUrl(Brave.browserWindowUrl)
.waitUntil(function () {
return this.getText(activeTabTitle)
.then((title) => title === 'Page 2')
})
})
})

describe('new tab signal', function () {
Brave.beforeAll(this)
before(function * () {
Expand Down
1 change: 1 addition & 0 deletions test/lib/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
urlInput: '#urlInput',
activeWebview: '.frameWrapper.isActive webview',
activeTab: '.tab.active',
activeTabTitle: '.tab.active .tabTitle',
activeTabFavicon: '.tab.active .tabIcon',
pinnedTabs: '.pinnedTabs',
pinnedTabsTabs: '.pinnedTabs .tab',
Expand Down

0 comments on commit e2ddbea

Please sign in to comment.