зеркало из https://github.com/electron/electron.git
remove page-title-updated workaround for #3380
This commit is contained in:
Родитель
e4524ce42e
Коммит
5e976be43b
|
@ -829,10 +829,8 @@ void WebContents::DidFinishNavigation(
|
|||
|
||||
void WebContents::TitleWasSet(content::NavigationEntry* entry,
|
||||
bool explicit_set) {
|
||||
if (entry)
|
||||
Emit("-page-title-updated", entry->GetTitle(), explicit_set);
|
||||
else
|
||||
Emit("-page-title-updated", "", explicit_set);
|
||||
auto title = entry ? entry->GetTitle() : base::string16();
|
||||
Emit("page-title-updated", title, explicit_set);
|
||||
}
|
||||
|
||||
void WebContents::DidUpdateFaviconURL(
|
||||
|
|
|
@ -76,13 +76,9 @@ BrowserWindow.prototype._init = function () {
|
|||
|
||||
// Change window title to page 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.
|
||||
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
|
||||
|
|
|
@ -268,13 +268,6 @@ WebContents.prototype._init = function () {
|
|||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -104,6 +104,10 @@ describe('BrowserWindow module', function () {
|
|||
response.statusCode = '200'
|
||||
response.end('hello')
|
||||
break
|
||||
case '/title':
|
||||
response.statusCode = '200'
|
||||
response.end('<title>Hello</title>')
|
||||
break
|
||||
default:
|
||||
done('unsupported endpoint')
|
||||
}
|
||||
|
@ -148,6 +152,7 @@ describe('BrowserWindow module', function () {
|
|||
{ name: 'did-get-redirect-request', url: `${server.url}/301` },
|
||||
{ name: 'did-get-response-details', 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-finish-load', url: `${server.url}/200` },
|
||||
{ name: 'did-frame-finish-load', url: `${server.url}/200` },
|
||||
|
|
Загрузка…
Ссылка в новой задаче