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

Update tab title on back/forward fixes #3200 #3202

Merged
merged 1 commit into from
Aug 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bsclifton - if you add these methods to https://github.com/brave/electron/blob/master/lib/renderer/web-view/web-view.js#L391 they can be called directly on the webview

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