remove page-title-updated workaround for #3380
This commit is contained in:
parent
e4524ce42e
commit
5e976be43b
4 changed files with 8 additions and 16 deletions
|
@ -829,10 +829,8 @@ void WebContents::DidFinishNavigation(
|
||||||
|
|
||||||
void WebContents::TitleWasSet(content::NavigationEntry* entry,
|
void WebContents::TitleWasSet(content::NavigationEntry* entry,
|
||||||
bool explicit_set) {
|
bool explicit_set) {
|
||||||
if (entry)
|
auto title = entry ? entry->GetTitle() : base::string16();
|
||||||
Emit("-page-title-updated", entry->GetTitle(), explicit_set);
|
Emit("page-title-updated", title, explicit_set);
|
||||||
else
|
|
||||||
Emit("-page-title-updated", "", explicit_set);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::DidUpdateFaviconURL(
|
void WebContents::DidUpdateFaviconURL(
|
||||||
|
|
|
@ -76,13 +76,9 @@ BrowserWindow.prototype._init = function () {
|
||||||
|
|
||||||
// Change window title to page title.
|
// Change window title to page title.
|
||||||
this.webContents.on('page-title-updated', (event, title) => {
|
this.webContents.on('page-title-updated', (event, title) => {
|
||||||
// The page-title-updated event is not emitted immediately (see #3645), so
|
|
||||||
// when the callback is called the BrowserWindow might have been closed.
|
|
||||||
if (this.isDestroyed()) return
|
|
||||||
|
|
||||||
// Route the event to BrowserWindow.
|
// Route the event to BrowserWindow.
|
||||||
this.emit('page-title-updated', event, title)
|
this.emit('page-title-updated', event, title)
|
||||||
if (!event.defaultPrevented) this.setTitle(title)
|
if (!this.isDestroyed() && !event.defaultPrevented) this.setTitle(title)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Sometimes the webContents doesn't get focus when window is shown, so we
|
// Sometimes the webContents doesn't get focus when window is shown, so we
|
||||||
|
|
|
@ -268,13 +268,6 @@ WebContents.prototype._init = function () {
|
||||||
this.reload()
|
this.reload()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Delays the page-title-updated event to next tick.
|
|
||||||
this.on('-page-title-updated', function (...args) {
|
|
||||||
setImmediate(() => {
|
|
||||||
this.emit('page-title-updated', ...args)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
app.emit('web-contents-created', {}, this)
|
app.emit('web-contents-created', {}, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,10 @@ describe('BrowserWindow module', function () {
|
||||||
response.statusCode = '200'
|
response.statusCode = '200'
|
||||||
response.end('hello')
|
response.end('hello')
|
||||||
break
|
break
|
||||||
|
case '/title':
|
||||||
|
response.statusCode = '200'
|
||||||
|
response.end('<title>Hello</title>')
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
done('unsupported endpoint')
|
done('unsupported endpoint')
|
||||||
}
|
}
|
||||||
|
@ -148,6 +152,7 @@ describe('BrowserWindow module', function () {
|
||||||
{ name: 'did-get-redirect-request', url: `${server.url}/301` },
|
{ name: 'did-get-redirect-request', url: `${server.url}/301` },
|
||||||
{ name: 'did-get-response-details', url: `${server.url}/200` },
|
{ name: 'did-get-response-details', url: `${server.url}/200` },
|
||||||
{ name: 'dom-ready', url: `${server.url}/200` },
|
{ name: 'dom-ready', url: `${server.url}/200` },
|
||||||
|
{ name: 'page-title-updated', url: `${server.url}/title` },
|
||||||
{ name: 'did-stop-loading', url: `${server.url}/200` },
|
{ name: 'did-stop-loading', url: `${server.url}/200` },
|
||||||
{ name: 'did-finish-load', url: `${server.url}/200` },
|
{ name: 'did-finish-load', url: `${server.url}/200` },
|
||||||
{ name: 'did-frame-finish-load', url: `${server.url}/200` },
|
{ name: 'did-frame-finish-load', url: `${server.url}/200` },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue