From e2ddbea9d81cd0e0965334fd7e67e423af0c4fa3 Mon Sep 17 00:00:00 2001 From: Radoslav Vitanov Date: Tue, 16 Aug 2016 09:01:45 +0300 Subject: [PATCH] Update tab title on back/forward fixes #3200 --- js/components/frame.js | 5 +++++ test/components/tabTest.js | 44 +++++++++++++++++++++++++++++++++++++- test/lib/selectors.js | 1 + 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/js/components/frame.js b/js/components/frame.js index 83a217d0a65..b878d2cdd4c 100644 --- a/js/components/frame.js +++ b/js/components/frame.js @@ -764,6 +764,7 @@ class Frame extends ImmutableComponent { if (this.props.findbarShown) { this.onFindHide() } + for (let message in this.notificationCallbacks) { appActions.hideMessageBox(message) } @@ -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, { diff --git a/test/components/tabTest.js b/test/components/tabTest.js index 693e9c64360..adb283b7e61 100644 --- a/test/components/tabTest.js +++ b/test/components/tabTest.js @@ -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) { @@ -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 * () { diff --git a/test/lib/selectors.js b/test/lib/selectors.js index 21cb70802fc..dd4a4ab2e90 100644 --- a/test/lib/selectors.js +++ b/test/lib/selectors.js @@ -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',